JDK-5020490 : (reflect) Class.isEnum should return false for specialized enum constants
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_8
  • CPU: generic
  • Submitted: 2004-03-25
  • Updated: 2019-07-03
  • Resolved: 2004-04-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 b46Fixed
Related Reports
Relates :  
Relates :  
Relates :  
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
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-beta2 FIXED IN: tiger-beta2 INTEGRATED IN: tiger-b46 tiger-beta2
14-06-2004

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
29-03-2004

EVALUATION Yes; should be fixed. ###@###.### 2004-03-26
26-03-2004