Bug 93044

Summary: [1.5][compiler] Eclipse compiler & javac disprepency?
Product: [Eclipse Project] JDT Reporter: Mark Hobson <hello>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M7   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Mark Hobson CLA 2005-04-27 19:35:21 EDT
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).
Comment 1 Philipe Mulet CLA 2005-04-28 03:58:17 EDT
Added GenericTypeTest#test631.

This got addressed along with changes near capture conversion since M6.
Comment 2 Philipe Mulet CLA 2005-04-28 04:05:00 EDT
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>>
Comment 3 Mark Hobson CLA 2005-04-28 04:26:09 EDT
Great, thanks for the info.