PMD runs endlessly on some generated files
A source code analyzer
Brought to you by:
adangel,
juansotuyo
PMD runs endlessly on some Java files, taking 100% CPU. After several hours, the output is still empty. Two example files that reproduce it systematically are attached.
Both files have in common a huge list of 'public static final BitSet' declarations at their end (roughly 850+). Removing half of it makes PMD finish the run.
I tried it with Oracle Java 1.8.0_25, and 1.8.0_11 on Linux Mint, and OpendJDK 1.7.0_51 on Suse (all 64bits).
I tried setting $ export HEAPSIZE=4096m to make sure it was not a xmx problem, but no luck either.
I could reproduce it with PMD 5.1.2 and 5.2.3.
Did more tests:
Thanks for reporting this issue. I could apply overall performance improvements which brought the runtime from more than 3 hours (didn't want to wait longer) down to 3 minutes (the complete design ruleset). After that, I saw, that the rule FieldDeclarationsShouldBeAtStartOfClass was the slowest one. I ended up rewriting this rule from XPath to a Java rule. This brought the runtime down to less than 30 seconds for the design ruleset.
The underlaying issue is probably, that these classes are huge - they have many, many class-level elements like methods and fields.
This fix will be included with the next release.
Your build time should already improve drastically by excluding this single rule via a custom ruleset, e.g.
Hi Andreas,
I can confirm both the bug fix and the performance improvement. This is quite impressive:
Thanks for your work!