Since: PMD 3.5
In JDK 1.5, calling new Integer() causes memory allocation. Integer.valueOf() is more memory friendly.
This rule is defined by the following XPath expression:
//PrimaryPrefix /AllocationExpression [not (ArrayDimsAndInits) and (ClassOrInterfaceType/@Image='Integer' or ClassOrInterfaceType/@Image='java.lang.Integer')]
Example:
public class Foo { private Integer i = new Integer(0); // change to Integer i = Integer.valueOf(0); }