Bug 86838

Summary: [1.5] [compiler] Eclipse compiles parameterized code that javac says is "is not within its bound"
Product: [Eclipse Project] JDT Reporter: Jon Nall <nall>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M6   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Jon Nall CLA 2005-02-28 10:23:06 EST
The following code compiles in eclipse with a WARNING:
Type safety: The expression of type EnumSet needs unchecked conversion to
conform to EnumSet<Enum>

The code fails in javac 1.5.0_01 with an ERROR:
EnumTest.java:15: type parameter java.lang.Enum is not within its bound
        EnumSet<Enum> eSet = EnumSet.allOf(c);

Changing EnumSet<Enum> to EnumSet<Foo> resolves the javac error. I tried to
figure out the JLS3 interpretation of this, but got confused. 

//////////////////////////////////////////////////////
import java.util.EnumSet;

enum Foo
{
    blargh,
    baz,
    boz;
}

public class EnumTest
{
    public static void main(String[] args)
    {
        Class c = Foo.class;
        EnumSet<Enum> eSet = EnumSet.allOf(c);
    }
}
Comment 1 Philipe Mulet CLA 2005-02-28 19:45:44 EST
Added regression test: 
GenericTypeTest#test533-538.

Adjusted type variable bound check.
Fixed
Comment 2 David Audel CLA 2005-03-31 09:43:14 EST
Verified in I20050330-0500