diff --git a/pmd-java/src/main/resources/category/java/codestyle.xml b/pmd-java/src/main/resources/category/java/codestyle.xml
index b5ded22baf..37ed132429 100644
--- a/pmd-java/src/main/resources/category/java/codestyle.xml
+++ b/pmd-java/src/main/resources/category/java/codestyle.xml
@@ -1809,6 +1809,33 @@ public class Foo {
+
+
+ Use the diamond operator to let the type be inferred
+ 1
+
+
+
+
+
+
+
+
+
+
+
+ Use Diamond
+ 2
+ 8,11
+ field;
+ public void foo() {
+ List strings = new ArrayList();
+ List strings2 = new ArrayList<>();
+ this.field = new ArrayList();
+ }
+}
+ ]]>
+
+
+ False positive cases: anonymous classes, methods calls
+ 0
+ > typeReference;
+ public void foo() {
+ Collections.sort(files, new Comparator() {
+ @Override
+ public int compare(DataSource left, DataSource right) {
+ String leftString = left.getNiceFileName(useShortNames, inputPaths);
+ String rightString = right.getNiceFileName(useShortNames, inputPaths);
+ return leftString.compareTo(rightString);
+ }
+ });
+ final TreeSet> sortedKeySet = new TreeSet<>(
+ new Comparator>() {
+ @Override
+ public int compare(final Entry o1, final Entry o2) {
+ return Long.compare(o1.getValue().selfTimeNanos.get(), o2.getValue().selfTimeNanos.get());
+ }
+ });
+ new ThreadLocal>() {
+ @Override
+ protected Queue initialValue() {
+ return Collections.asLifoQueue(new LinkedList());
+ }
+ };
+ Iterator EMPTY_ITERATOR = new ArrayList().iterator();
+ Class> type = null;
+ typeReference = new WeakReference>(type);
+ ((ListNode) rev).reverseCache = new SoftReference>(this);
+ }
+ public Map, Object> getOverriddenPropertiesByPropertyDescriptor() {
+ return propertyValues == null ? new HashMap, Object>() : new HashMap<>(propertyValues);
+ }
+}
+ ]]>
+
+
\ No newline at end of file