PMD 5.0.4 fails with NPE on parsing java enum with inner class instance creation
A source code analyzer
Brought to you by:
adangel,
juansotuyo
I've migrated our project from PMD 4.2.5 to PMD 5.0.4.
PMD 5.0.4 fails with NPE on parsing enumeration class with inner class instance creation. It seems that it couldn't find inner type in import section and set it to null then calls method on null object. This bug regards to enumeration classes only.
Test class you may find in attachment.
Do you know with which rule this happens? So far PMD can parse the file and I didn't recognize an exception when I run all rules against it.
Sorry, I've misled you I've got an exception after parsing with message "Error while processing TestInnerInEnum.java". Exception was raised from SourceCodeProcessor.usesTypeResolution method. I've used attached rule set under jdk7u21.
Last edit: Anton Zagorulko 2013-08-19
Also got this exception (on pmd 5.0.5). Seems like issue is not about inner class instantiation in enum but anonymous inner class instantiation in enum.
Command to reproduce using TestInnerInEnum.java, attached by Anthon:
pmd.bat -d TestInnerInEnum.java -f text -rulesets java-basic -debug >pmd.log 2>&1
As a result - NPE and stacktrase in pmd.log (attached).
So - will this issue be resolved in 5.1.0? I didn't see any commit or patch (which is fine...just want to make sure it wasn't closed accidentally)
Yes, it will be resolved in 5.1.0, the latest. I'm not sure about creating another 5.0.x maintenance release, but it will be definitely in 5.1.0.
The commit is here: https://github.com/pmd/pmd/commit/b329e32fcc740ce792f6185c071051010129e064
By the way: There was already a duplicate bug reported: https://sourceforge.net/p/pmd/bugs/1138/