Board index » jbuilder » EnumSet<>

EnumSet<>


2005-08-18 03:17:49 PM
jbuilder8
[ Prev. posted to .students ]
Hi,
Not sure quite where the problem is here.
Code like this:
//---------------------------------------------------------------------------------
import java.util.*;
public class test {
enum Foo { A, B, C, D }
public test() {
EnumSet<Foo>x = EnumSet.of(Foo.A, Foo.B);
}
public static void main(String[] args) {
test test = new test();
}
}
//---------------------------------------------------------------------------------
Will build OK under javac, but not under JBuilder Foundation 2005 (see
comments)
Errors are as follows:
- type parameter test.Foo is not within its bound at line 21 (21:13)
- cannot find symbol; symbol : method of(test.Foo,test.Foo),
location: class java.util.EnumSet at line 21 (21:30)
At line: EnumSet<Foo>x = EnumSet.of(Foo.A, Foo.B);
I'm guessing this has to be JBuilder problem, maybe just a setting.
JDK: java version 1.5.0_04-b05
Settings:
Language Version V5.0 (Generics enabled)
Runtime : Java 2 SDK, 5.0 and later
Suggestions would be appreciated.
 
 

Re:EnumSet<>

Simon Morris wrote:
Quote
Will build OK under javac, but not under JBuilder Foundation 2005 (see
comments)

Errors are as follows:

- type parameter test.Foo is not within its bound at line 21 (21:13)

- cannot find symbol; symbol : method of(test.Foo,test.Foo),
location: class java.util.EnumSet at line 21 (21:30)
1. Project | Project Properties menu item
2. Build / Java page
3. Make sure you have Target VM set to "Java 2 SDK, v 5.0 and later."
JBuilder is capable of compiling most of the new 1.5 language features
in a way that's backward compatible with old VM's, but there are a few
things that can't work like that. These are two of them. The specific
reasons why these don't work are below, if you care.
For the first problem, EnumSet is defined as class EnumSet<E extends
Enum<E>>. Thus, in your code Foo must extend java.util.Enum. That
works fine if you compile for JDK 1.5, but in JDK 1.4 there is no
java.util.Enum class. What JBuilder does is compile a Foo that looks
and acts more or less like an Enum but that doesn't actually extend
java.util.Enum. This works for most of the things that you'd want to do
with an enum (ex. x.ordinal()), but it means that the type constraint on
EnumSet isn't met.
The second problem is quite similar. Again, in JDK 1.4 there is no
java.util.EnumSet class, so it can't find the of method.
--
Gillmer J. Derge [TeamB]
 

Re:EnumSet<>

On Thu, 18 Aug 2005 08:23:49 -0400, "Gillmer J. Derge [TeamB]"
< XXXX@XXXXX.COM >wrote:
Thanks!
Quote
Simon Morris wrote:
>Will build OK under javac, but not under JBuilder Foundation 2005 (see
>comments)
>
>Errors are as follows:
>
>- type parameter test.Foo is not within its bound at line 21 (21:13)
>
>- cannot find symbol; symbol : method of(test.Foo,test.Foo),
>location: class java.util.EnumSet at line 21 (21:30)

1. Project | Project Properties menu item

2. Build / Java page

3. Make sure you have Target VM set to "Java 2 SDK, v 5.0 and later."

JBuilder is capable of compiling most of the new 1.5 language features
in a way that's backward compatible with old VM's, but there are a few
things that can't work like that. These are two of them. The specific
reasons why these don't work are below, if you care.

For the first problem, EnumSet is defined as class EnumSet<E extends
Enum<E>>. Thus, in your code Foo must extend java.util.Enum. That
works fine if you compile for JDK 1.5, but in JDK 1.4 there is no
java.util.Enum class. What JBuilder does is compile a Foo that looks
and acts more or less like an Enum but that doesn't actually extend
java.util.Enum. This works for most of the things that you'd want to do
with an enum (ex. x.ordinal()), but it means that the type constraint on
EnumSet isn't met.

The second problem is quite similar. Again, in JDK 1.4 there is no
java.util.EnumSet class, so it can't find the of method.
 

{smallsort}