I'm seeing a major difference in behavior between Eclipse and javac for the following code:
public class TestIncompatibleTypes {
    private static <V> void libraryMethod(Class<? extends List<V>> in) {}
    public static void main(String[] args) {
        // Eclipse warns about 'Unchecked cast'
        // Maven fails with 'incompatible types'
        Class<? extends List<String>> l = (Class<? extends List<String>>) ArrayList.class;
        libraryMethod(l);
    }
}
Eclipse issues an 'unchecked cast' warning for the above code, but it successfully compiles. Javac generates an error:
$ java -version
openjdk version "1.8.0_72-internal"
OpenJDK Runtime Environment (build 1.8.0_72-internal-b15)
OpenJDK 64-Bit Server VM (build 25.72-b15, mixed mode)
$ javac -version
javac 1.8.0_72-internal
$ javac -source 8 TestIncompatibleTypes.java
TestIncompatibleTypes.java:13: error: incompatible types: Class<ArrayList> cannot be converted to Class<? extends List<String>>
        Class<? extends List<String>> l = (Class<? extends List<String>>) ArrayList.class;
                                                                                   ^
1 error
Can anyone explain why javac disallows the cast? My understanding is that they should be completely equivalent after type erasure.
Is there a workaround to get this to compile on both compilers?
 
     
     
    