PMD, IntegerInstantiation and a Red Herring
Yesterday I did a bit of exploring how well PMD‘s Eclipse plug-in integrates into our development tools / process. Even if you are not planning on implementing static analysis and you are a java shop, you owe it to yourself to become familiar with the rules that PMD and other such tools utilize.
Why? Because while we have in technology a great tradition of reinventing the wheel it is generally not too efficient and managers tend to frown on it too. So why do you want your group to re-learn in their context what others have learned in similar ones?
You will also learn more about the underlying technology of the product you are testing. That is certainly not a bad thing either.
Back to the original point. The code I work against is triggering a pretty sizable amount of hits to the IntegerInstantiation rule which they summarize as IntegerInstantiation: In JDK 1.5, calling new Integer() causes memory allocation. Integer.valueOf() is more memory friendly. I can’t argue with the whole ‘memory friendly’ aspect, but we’re using Java 1.4 which makes this a false positive (something you learn to live with in the world of static analysis.
But through the process I extended my knowledge of how Java works; initially from the description of the rule, and further through articles I found like this which is absolutely a Good Thing™.