United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-5020490 : (reflect) Class.isEnum should return false for specialized enum constants

Details
Type:
Bug
Submit Date:
2004-03-25
Status:
Resolved
Updated Date:
2012-09-28
Project Name:
JDK
Resolved Date:
2004-04-01
Component:
core-libs
OS:
solaris_8
Sub-Component:
java.lang:reflect
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:
5.0 (b46)

Related Reports
Relates:

Sub Tasks

Description
the following program should print "false", as the classof a is an anonymous
class that was not declared as an enumeration type.

The proper implementation of isEnum should check both the ACC_ENUM bit on
the class AND that the direct supertype is java.lang.Enum.  Only when both
conditions are true should the method return true.

enum E {
    a {};
    public static void main(String[] args) {
        System.out.println(a.getClass().isEnum());
    }
}

                                    

Comments
EVALUATION

Yes; should be fixed.

###@###.### 2004-03-26
                                     
2004-03-26
SUGGESTED FIX

src/share/classes/java/lang>sccs sccsdiff -r1.174 -r1.175 Class.java       

------- Class.java -------
2449c2449,2453
<       return (getModifiers() & ENUM) != 0;
---
>       // An enum must both directly extend java.lang.Enum and have
>       // the ENUM bit set; classes for specialized enum constants
>       // don't do the former.
>       return (this.getModifiers() & ENUM) != 0 && 
>       this.getSuperclass() == java.lang.Enum.class;

###@###.### 2004-03-29
                                     
2004-03-29
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger-beta2

FIXED IN:
tiger-beta2

INTEGRATED IN:
tiger-b46
tiger-beta2


                                     
2004-06-14



Hardware and Software, Engineered to Work Together