Community
Participate
Working Groups
The following code compiles and runs under eclipse-3.1M6, but fails under javac: import java.lang.annotation.RetentionPolicy; public class Test { public static void main(String[] args) { Class<? extends Enum<?>> c = RetentionPolicy.class; System.out.println(Enum.valueOf(c, "CLASS")); } } Javac reports the following error: Test.java:8: <T>valueOf(java.lang.Class<T>,java.lang.String) in java.lang.Enum cannot be applied to (java.lang.Class<capture of ? extends java.lang.Enum<?>>,java.lang.String) System.out.println(Enum.valueOf(c, "CLASS")); ^ 1 error Eclipse should produce an error (see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6209030).
Added GenericTypeTest#test631. This got addressed along with changes near capture conversion since M6.
fyi, we now produce the error: Bound mismatch: The generic method valueOf(Class<T>, String) of type Enum<E> is not applicable for the arguments (Class<capture-of ? extends Enum<?>>, String) since the type capture-of ? extends Enum<?> is not a valid substitute for the bounded parameter <T extends Enum<T>>
Great, thanks for the info.