You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HelloWorld.java:9: error: incompatible types: cannot infer type arguments for ArrayList<>
List<Class<?>> asdf = new ArrayList<>(Arrays.asList(classes));
^
reason: cannot infer type-variable(s) E,T
(argument mismatch; List<Class> cannot be converted to Collection<? extends Class<?>>)
where E,T are type-variables:
E extends Object declared in class ArrayList
T extends Object declared in method <T>asList(T...)
The text was updated successfully, but these errors were encountered:
datho7561
changed the title
Diamond operator type inferences fails under javac but not ECJ
Diamond operator type inference fails under javac but not ECJ
Jan 21, 2025
$ ecj -23 -warn:+all HelloWorld.java
----------
1. WARNING in /tmp/HelloWorld.java (at line 7)
Class[] classes = new Class[] { String.class, List.class };
^^^^^
Class is a raw type. References to generic type Class<T> should be parameterized
----------
Let's not spend time on compiler difference where raw types are involved. Those are legacy since about 20 years. Knowing that javac has some significant, long standing bugs in this area, we can simply blame them :)
The following minimal example produces a compiler error under javac but not ECJ:
Here's the error that javac gives:
The text was updated successfully, but these errors were encountered: