@DesireWarning("SF_SWITCH_NO_DEFAULT") public int test3(MyEnum e) { switch (e) { case A: return 1; } return 3; }
@DesireWarning("BX_UNBOXING_IMMEDIATELY_REBOXED") public Long f(boolean b, Long x, long y) { Long z = b ? x : y; return z; }
public class Bug3463046 { @DesireWarning("") private static final AtomicIntegerFieldUpdater<Bug3463046> s_atomic1 = AtomicIntegerFieldUpdater.newUpdater(Bug3463046.class, "noSuchField"); private static final AtomicIntegerFieldUpdater<Bug3463046> s_atomic2 = AtomicIntegerFieldUpdater.newUpdater(Bug3463046.class, "incorrectFieldType"); private static final AtomicIntegerFieldUpdater<Bug3463046> s_atomic3 = AtomicIntegerFieldUpdater.newUpdater(Bug3463046.class, "fieldNotVolatile"); private volatile long incorrectFieldType; private int fieldNotVolatile; }
@DesireWarning("Se") public static Bug1234 create(final Runnable action) { return new Bug1234() { @Override public void run() { action.run(); } }; } }
@DesireWarning("EI2") public void assign_conditional(Object[] args) { this.args1 = args == null ? NO_ARGS : args; };
@DesireWarning("") public synchronized int getNext2() { return counter++; }
@DesireWarning(value = "NP", confidence = Confidence.LOW) @Override @CheckForNull public Object get() { return null; }
@Override @DesireWarning("EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS") public boolean equals(Object that) { int[][] thatData; if (that instanceof Ideas_2009_12_11) thatData = ((Ideas_2009_12_11) that).data; else if (that instanceof int[][]) thatData = (int[][]) that; else return false; return Arrays.deepEquals(data, thatData); }
@DesireWarning("RCN") public static void test2(Object o) { if (o instanceof String || o instanceof StringBuffer) { if (o == null) System.out.println("Huh?"); } }
@DesireWarning("EC_UNRELATED_TYPES") public void test7() { Integer x = 5; String y = "5"; org.testng.Assert.assertEquals(x, y, "oops"); }
@Override @DesireWarning(value = "NP", confidence = Confidence.LOW) @CheckForNull public Object get(); }
@DesireWarning("UL_UNRELEASED_LOCK") void bug(Lock any) { any.lock(); // any code }
@DesireWarning("NP") void foo(Object o, boolean b) { if (o == null || b) { /* */ } else { /* */ } o.toString(); } }
@DesireWarning("DMI_BAD_MONTH") void bug2(Date date) { boolean b = date.getMonth() == 12; }
@DesireWarning("NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE") protected Object method(@CheckForNull Object... params) { return params.length; }
@DesireWarning("NP") int f3Bug(Object x) { Assert.assertTrue(x == null); return x.hashCode(); }
@DesireWarning("NP_NULL_ON_SOME_PATH") public int getHashCode0(Object x) { boolean b = x != null; if (b) System.out.println("Good"); return x.hashCode(); } @DesireNoWarning("NP_NULL_ON_SOME_PATH")
@DesireWarning("UL_UNRELEASED_LOCK") void bug2(Lock any) { any.lock(); // any code; might throw exception any.unlock(); }
@DesireWarning("NP") int f4Bug(Object x) { Assert.assertFalse(x != null); return x.hashCode(); }
@DesireWarning("GC") public static boolean foo(TreeMap<String, String> map, String key) { return map.keySet().contains(map); }