Bug 86838 - [1.5] [compiler] Eclipse compiles parameterized code that javac says is "is not within its bound"
Summary: [1.5] [compiler] Eclipse compiles parameterized code that javac says is "is n...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-28 10:23 EST by Jon Nall CLA
Modified: 2005-03-31 09:43 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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