import java.util.*; public class MapTest { // should not be flagged since l1 is public public Map l1 = new HashMap(); // should not be flagged since l2 is a parameter public Map m(Map l2) { l2.remove(""); // should not be flagged since it is assigned an existing map Map l3 = l2; // should not be flagged since it is assigned an existing map Map l33; l33 = l2; // should not be flagged since it is returned Map s1 = new LinkedHashMap(); // should not be flagged since it is assigned to another variable Map l4 = new HashMap(); this.l1 = l4; // should not be flagged since its contents are accessed Map l5 = new HashMap(); if(!l5.containsKey("hello")) l5.put("hello", 23); // should not be flagged since its contents are accessed Map l6 = new HashMap(); if(l6.remove("") != null) return null; return s1; } public void n(Collection> ms) { // should not be flagged since it is implicitly assigned an existing collection for (Map m : ms) m.put("world", 42); } // should be flagged private Map useless = new HashMap(); { useless.put("hello", 23); useless.remove("hello"); } // should not be flagged since it is annotated with @SuppressWarnings("unused") @SuppressWarnings("unused") private Map l7 = new HashMap(); // should not be flagged since it is annotated with a non-standard annotation suggesting reflective access @interface MyReflectionAnnotation {} @MyReflectionAnnotation private Map l8 = new HashMap(); }