#173 ArrayIndexOutOfBounds in JavadocStyle

release_3.3
closed
Other (70)
5
2012-10-10
2003-11-14
Lars Kühne
No

Checking the following sourcecode with a configuration
that contains only the JavadocStyle check results in

InputJavadocStyle.java:0: Got an exception -
java.lang.ArrayIndexOutOfBoundsException: 0

package com.puppycrawl.tools.checkstyle.javadoc;

/
Create a new InputJavadocStyle. Sample usage:
<blockquote><pre>
InputJavadocStyle s = new InputJavadocStyle();
</blockquote></pre>
*/
public class InputJavadocStyle
{

}

This should be covered by a unit test.

Discussion

  • Logged In: YES
    user_id=746148

    I've just tried this code with the following check on
    current development
    version and all works fine.

    <module name="JavadocStyle">
    <property name="scope" value="public"/>
    </module>

    Perhaps there is something that I con not copy/paste from
    brouser :(

     
  • Lars Kühne
    Lars Kühne
    2003-11-15

    Input file that causes the failure

     
  • Lars Kühne
    Lars Kühne
    2003-11-15

     
    Attachments
  • Lars Kühne
    Lars Kühne
    2003-11-15

    Logged In: YES
    user_id=401384

    I have uploaded the input file and config file. With these
    files in the checkstyle main directory, I get

    [checkstyle]$ java -Dbasedir=pwd -jar
    target/dist/checkstyle-3.3/checkstyle-all-3.3.jar -c
    test.xml InputJavadocStyle.java
    Starting audit...
    InputJavadocStyle.java:0: Got an exception -
    java.lang.ArrayIndexOutOfBoundsException: 3
    Audit done.

     
  • Logged In: YES
    user_id=746148

    The problem is in empty lines between javadoc and class
    declaration.
    The check calculate line number of javadoc using the
    following formula:
    JavadocLineNo = classDefLineNo - numberOfJavdocLines.
    So, it's not ready for empty lines.
    And the obvious workaround is remove empty lines between
    class definition and javadoc.

     
  • Logged In: YES
    user_id=746148

    We need a way to get correct location of javadoc.

     
  • Logged In: YES
    user_id=746148

    Fix committed to CVS for 3.3