Menu

#1298 Member variable int type with value 0xff000000 causes processing error

PMD-5.3.0
closed
None
PMD
3-Major
Bug
5.2.3
2015-04-01
2014-12-28
No

The following java class causes a NumberFormatException in the RedundantFieldInitializerRule:

public class LinePoint {
    private int mColor = 0xFF000000;
}

The stacktrace is:

Error while processing file: /tmp/LinePoint.java
java.lang.NumberFormatException: For input string: "FF000000"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:495)
at java.lang.Integer.valueOf(Integer.java:556)
at java.lang.Integer.decode(Integer.java:984)
at net.sourceforge.pmd.lang.java.rule.optimizations.RedundantFieldInitializerRule.visit(RedundantFieldInitializerRule.java:79)
at net.sourceforge.pmd.lang.java.ast.ASTFieldDeclaration.jjtAccept(ASTFieldDeclaration.java:23)
at net.sourceforge.pmd.lang.java.rule.JavaRuleChainVisitor.visit(JavaRuleChainVisitor.java:40)
at net.sourceforge.pmd.lang.rule.AbstractRuleChainVisitor.visitAll(AbstractRuleChainVisitor.java:85)
at net.sourceforge.pmd.RuleChain.apply(RuleChain.java:66)
at net.sourceforge.pmd.RuleSets.apply(RuleSets.java:122)
at net.sourceforge.pmd.SourceCodeProcessor.processSource(SourceCodeProcessor.java:146)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:76)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:43)
at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:78)
at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:25)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

The int declaration overflows and would be negative, but it compiles OK and is valid Java code.

Discussion

  • Andreas Dangel

    Andreas Dangel - 2015-01-16
    • status: open --> closed
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-Next
     
  • Andreas Dangel

    Andreas Dangel - 2015-01-16

    Will be fixed with the next version.

     
  • Richard Quirk

    Richard Quirk - 2015-01-18

    Thanks!

     

Log in to post a comment.