Due to the way DynamicJava-defined enums are implemented, the EnumSet API class doesn't recognize them as enums and throws an exception when trying to create a set of that type.
> enum Foo { A, B, C};
> EnumSet set
> set = EnumSet.allOf(Foo.class)
java.lang.ClassCastException: class Foo not an enum
at java.util.EnumSet.noneOf(EnumSet.java:93)
at java.util.EnumSet.allOf(EnumSet.java:110)
>
Also got this type error, which should be looked at more closely:
> EnumSet<Foo> set
Static Error: Type arguments are invalid
Still exists in revision 4978 (except the second error is "Static Error: Type has incompatible bounds").
In 5211, I'm getting
Welcome to DrJava. Working directory is /home/mgricken/temp
> enum Foo { A, B, C};
> EnumSet set
Static Error: Undefined class 'EnumSet'
> import java.util.EnumSet; // auto-import
EnumSet set
> set = EnumSet.allOf(Foo.class)
Static Error: No method in static raw EnumSet with name 'allOf' matches this invocation
Arguments: (Class<Foo>)
Expected return type: raw EnumSet
Candidate signatures: <E> EnumSet<E> allOf(Class<E>) [E <: Enum<E>]
> EnumSet<Foo> set2
> set2 = EnumSet.allOf(Foo.class)
java.lang.ClassCastException: class Foo not an enum
at java.util.EnumSet.noneOf(EnumSet.java:93)
at java.util.EnumSet.allOf(EnumSet.java:110)
> Foo.class.getSuperclass()
class java.lang.Enum
> Foo.class.isEnum()
false
>
Since Class.isEnum() returns false (which does a this.getModifiers() & ENUM) != 0, and getModifiers() is native), it will be difficult to implement this.