Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#454 [indentation]AOOB exception on Runnable with inner switch

release_4.2
open
nobody
5
2012-10-10
2006-11-02
No

Attached class leads to:

checkstyle-must-have-rules:
[checkstyle] Running Checkstyle 4.1 on 1 files
[checkstyle]
src/main/net/eads/space/lapap/plugin/clsw/CheckstyleBug.java:0:
Got an exception -
java.lang.ArrayIndexOutOfBoundsException: 2147483647

When moving the switch part to separat method the
AOOB exception disappears.

Discussion

  • Example class leading to AOOB exception of checkstyle

     
    Attachments
  • Oliver Burn
    Oliver Burn
    2006-11-02

    Logged In: YES
    user_id=218824

    also need the configuration file you are using for the checks.

     
  • Oliver Burn
    Oliver Burn
    2006-11-02

    Logged In: YES
    user_id=218824

    and could you test with 4.2 release.

     
  • Checkstyle config leading to warnings

     
  • Logged In: YES
    user_id=1521016

    Sorry, but it is not that easy for me to switch the checkstyle installation as it
    is in controlled automated build environment. Please request again if you cannot
    reproduce this bug, I will then spent some more effort on this.

     
  • Oliver Burn
    Oliver Burn
    2006-11-02

    Logged In: YES
    user_id=218824

    this may be a silly question, but if you cannot update the
    version of Checkstyle, then how would you be able to take a
    patch to fix the problem?

    Please verify if it is a problem under 4.2 as there are a
    number of bug fixes in that release.

    Also, please attached a full stack track so I can see where
    the AOOB is being generated.

     
  • Logged In: YES
    user_id=1521016

    Sorry, if we have the need to change our build env then we may do this.

    But this is a shared build productive environment (automated builds on a perforce
    server checking for compilation, code style, metrics, unit tests, ...) for a large
    team that I may not change just for testing a newer release. For that purpose I
    have to setup a copy of that server, update the checkstyle and then may test it.
    And before using the changed configuration we would observe the copy build server
    some time before switching our configuration (if the problem solving is not a
    blocker, as it is here as we now use the workaround).

    But anyway, I will see if I can test for it locally.

     
  • Logged In: YES
    user_id=746148

    The problem is in IndentationCheck andit isreproduciblewith 4.2.
    Here is a stack trace:
    java.lang.ArrayIndexOutOfBoundsException: 2147483647
    at
    com.puppycrawl.tools.checkstyle.checks.indentation.ExpressionHandler.checkExpressionSubtree(ExpressionHandler.java:434)
    at
    com.puppycrawl.tools.checkstyle.checks.indentation.ExpressionHandler.checkChildren(ExpressionHandler.java:410)
    at
    com.puppycrawl.tools.checkstyle.checks.indentation.BlockParentHandler.checkIndentation(BlockParentHandler.java:298)
    at
    com.puppycrawl.tools.checkstyle.checks.indentation.MethodDefHandler.checkIndentation(MethodDefHandler.java:131)
    at
    com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck.visitToken(IndentationCheck.java:256)
    at
    com.puppycrawl.tools.checkstyle.TreeWalker.notifyVisit(TreeWalker.java:500)
    at
    com.puppycrawl.tools.checkstyle.TreeWalker.processIter(TreeWalker.java:625)
    at
    com.puppycrawl.tools.checkstyle.TreeWalker.walk(TreeWalker.java:426)
    at
    com.puppycrawl.tools.checkstyle.TreeWalker.process(TreeWalker.java:244)
    at
    com.puppycrawl.tools.checkstyle.TreeWalker.process(TreeWalker.java:590)
    at
    com.puppycrawl.tools.checkstyle.Checker.process(Checker.java:239)
    at com.puppycrawl.tools.checkstyle.Main.main(Main.java:127)

     
  • chaosdeathfish
    chaosdeathfish
    2006-12-07

    Logged In: YES
    user_id=1297990
    Originator: NO

    The problem appears to be in com.puppycrawl.tools.checkstyle.checks.indentation.ExpressionHandler#getFirstLine (line 450). I've fixed the problem in by adding the following before line 462:

    if (currLine < aStartLine) {
    aStartLine = currLine;
    }

    This seems to have fixed the problem, but I have no idea if this is correct behaviour.

     
  • Tomaszewski P.
    Tomaszewski P.
    2011-10-03

    Happens with
    Eclipse Checkstyle Plugin 5.4.1.201109192037
    also.

     
  • joba01
    joba01
    2012-04-19

    Hey,

    seems to be an old bug but is still not fixed, are there any attempts to fix it?
    I'm using: Eclipse Checkstyle Plug-in 5.5.0.201111092104

    In case the first line of a file is emtpy an ArrayOutOfBound exception occurs.

    I use the following rule:

    <module name="RegexpMultiline"><property name="id" value="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpMultilineCheck_1334841628"/><property name="severity" value="warning"/><property name="format" value="@SimpleValue(\(.*?\))?(&lt;span&gt;[klzzwxh:0003klzzwxh:0004klzzwxh:0005]&lt;/span&gt;)*(&lt;span&gt;[(private)(public)(protected)(static)([klzzwxh:0006klzzwxh:0007klzzwxh:0008]&lt;/span&gt;)*])*(&lt;span&gt;[klzzwxh:0009klzzwxh:0010klzzwxh:0011]&lt;/span&gt;)*final"/><property name="message" value="KiSImpleValue Injections may not be 'final'"/></module

    cheers Joe