#1490 [java] PMD Error while processing - NullPointerException

PMD-5.4.3
closed
None
PMD
3-Major
Bug
5.4.1
2016-11-04
2016-06-02
No

When processing this line, PMD is hitting a NullPointerException error. Additional detail: If I change "valueOf" to anything else, or change EsmDcVoltageSensor to anything else, no exception is generated.

Code compiles without issue.

String name = EsmDcVoltageSensor.valueOf((byte) (idx - startIdx)).getName();

Causes NPE.

String name = Something.valueOf((byte) (idx - startIdx)).getName();

No NPE.

String name = EsmDcVoltageSensor.Something((byte) (idx - startIdx)).getName();

No NPE.

Stack trace:

java.lang.NullPointerException
    at net.sourceforge.pmd.lang.ast.AbstractNode.jjtGetChild(AbstractNode.java:91)
    at net.sourceforge.pmd.lang.java.symboltable.MethodNameDeclaration.equals(MethodNameDeclaration.java:88)
    at java.util.HashMap.putVal(HashMap.java:634)
    at java.util.HashMap.put(HashMap.java:611)
    at java.util.HashSet.add(HashSet.java:219)
    at net.sourceforge.pmd.lang.java.symboltable.ClassScope.findVariableHere(ClassScope.java:209)
    at net.sourceforge.pmd.lang.java.symboltable.AbstractJavaScope.contains(AbstractJavaScope.java:33)
    at net.sourceforge.pmd.lang.java.symboltable.Search.searchUpward(Search.java:50)
    at net.sourceforge.pmd.lang.java.symboltable.Search.execute(Search.java:35)
    at net.sourceforge.pmd.lang.java.symboltable.OccurrenceFinder.visit(OccurrenceFinder.java:56)
    at net.sourceforge.pmd.lang.java.ast.ASTPrimaryExpression.jjtAccept(ASTPrimaryExpression.java:22)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:55)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:9)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:228)
    at net.sourceforge.pmd.lang.java.ast.ASTExpression.jjtAccept(ASTExpression.java:22)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:55)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:9)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:172)
    at net.sourceforge.pmd.lang.java.ast.ASTVariableInitializer.jjtAccept(ASTVariableInitializer.java:22)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:55)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:9)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:164)
    at net.sourceforge.pmd.lang.java.ast.ASTVariableDeclarator.jjtAccept(ASTVariableDeclarator.java:22)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:55)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:9)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:364)
    at net.sourceforge.pmd.lang.java.ast.ASTLocalVariableDeclaration.jjtAccept(ASTLocalVariableDeclaration.java:25)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:55)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:9)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:360)
    at net.sourceforge.pmd.lang.java.ast.ASTBlockStatement.jjtAccept(ASTBlockStatement.java:22)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:55)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:9)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:356)
    at net.sourceforge.pmd.lang.java.ast.ASTBlock.jjtAccept(ASTBlock.java:22)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:55)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:9)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:348)
    at net.sourceforge.pmd.lang.java.ast.ASTStatement.jjtAccept(ASTStatement.java:22)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:55)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:9)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:396)
    at net.sourceforge.pmd.lang.java.ast.ASTForStatement.jjtAccept(ASTForStatement.java:22)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:55)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:9)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:348)
    at net.sourceforge.pmd.lang.java.ast.ASTStatement.jjtAccept(ASTStatement.java:22)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:55)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:9)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:360)
    at net.sourceforge.pmd.lang.java.ast.ASTBlockStatement.jjtAccept(ASTBlockStatement.java:22)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:55)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:9)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:356)
    at net.sourceforge.pmd.lang.java.ast.ASTBlock.jjtAccept(ASTBlock.java:22)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:55)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:9)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:180)
    at net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration.jjtAccept(ASTMethodDeclaration.java:25)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:55)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:9)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:45)
    at net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceBodyDeclaration.jjtAccept(ASTClassOrInterfaceBodyDeclaration.java:41)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:55)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:9)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:49)
    at net.sourceforge.pmd.lang.java.ast.ASTEnumBody.jjtAccept(ASTEnumBody.java:22)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:55)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:9)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:140)
    at net.sourceforge.pmd.lang.java.ast.ASTEnumDeclaration.jjtAccept(ASTEnumDeclaration.java:18)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:55)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:9)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:156)
    at net.sourceforge.pmd.lang.java.ast.ASTTypeDeclaration.jjtAccept(ASTTypeDeclaration.java:36)
    at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:55)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:9)
    at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:136)
    at net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit.jjtAccept(ASTCompilationUnit.java:42)
    at net.sourceforge.pmd.lang.java.symboltable.SymbolFacade.initializeWith(SymbolFacade.java:16)
    at net.sourceforge.pmd.lang.java.AbstractJavaHandler$4.start(AbstractJavaHandler.java:79)
    at net.sourceforge.pmd.SourceCodeProcessor.symbolFacade(SourceCodeProcessor.java:100)
    at net.sourceforge.pmd.SourceCodeProcessor.processSource(SourceCodeProcessor.java:139)
    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:79)
    at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:25)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Discussion

  • Andreas Dangel

    Andreas Dangel - 2016-11-04
    • summary: PMD Error while processing - NullPointerException --> [java] PMD Error while processing - NullPointerException
    • status: open --> in-progress
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-5.4.3
     
  • Andreas Dangel

    Andreas Dangel - 2016-11-04
    • status: in-progress --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks