import java.util.*; class X<T> { } class XX extends X { Object f(X x) { if (x != null) { XX xx = (XX)new XX(); return xx; } if (1 == 1) { XX xx = (XX)x; return xx; } return null; } } class eee { COMP comp; COMP foo() { return (COMP) new eee(); } } class AllPredicate { private List> lists; public void e(AllPredicate that) { lists = (List>)that.lists; } public static List fff() { Collection c = new ArrayList(); return (List) c; //not unchecked } public static Comparable ggg() { Object time = new Object(); return (Comparable) time; } public static void foo(SortedMap sourceSortedMap) { new TreeMap((Comparator) sourceSortedMap.comparator()); } } class K { } class L extends K { } class M { public static L f(T t) { return (L) t; //this should NOT generate unchecked cast } } class UncheckedCastFalsePositive { public static void method(Object something) { if (something instanceof NumberList) { NumberList numberList = (NumberList) something; } } public static class NumberList extends ArrayList { } }