Community
Participate
Working Groups
public abstract class GenericWarningTest { abstract <T extends Comparable<T>> java.util.Iterator<T> give(T obj); abstract <T> void receive(T obj, java.util.Iterator<T> it); void testMethod() { // Warning at next line: // Type safety: Unchecked invocation receive(Baad, Iterator) of the generic method receive(T, Iterator<T>) of type GenericWarningTest receive(new Baad(), give(new Baad())); receive(new Good(), give(new Good())); } } @SuppressWarnings("rawtypes") class Baad implements Comparable { @Override public int compareTo(Object o) { return 0; } } class Good implements Comparable<Good> { public int compareTo(Good o) { return 0; } } Iterator is parametrized everywhere, but the warning still states it's raw. However there's no mention of Comparable, the real bad guy here. http://mindprod.com/jgloss/compileerrormessages.html clearly states what the problem is and http://stackoverflow.com/questions/15501884/java-generics-warnings-on-java-util-collections provides a solution, but I still think it would be nice if the compiler at least mentioned the part of the type being unsafe (Comparable in these cases). By the way the origin of this came from Joda VS Mockito, the above is a minimal repro; for more see https://sourceforge.net/p/joda-time/bugs/172/ . Also if you investigate the hierarchy of Joda DateTime you can see it's not trivial to find the raw Comparable implements and associate it with the warning.