JDK-4401321 : Add type-safe enums to Java
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Affected Version: 1.1.4,1.1.5,1.3.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,windows_95,windows_nt
  • CPU: generic,x86
  • Submitted: 2001-01-03
  • Updated: 2017-05-16
  • Resolved: 2003-08-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.
5.0 tigerFixed
Related Reports
Duplicate :  
Enumeration types similar to the c++ "enum" are not available in Java. I
searched the bug reports and could not find a match, this may be from a
dilution of other issues related to the terms Enumeration, Enumerated. Along
with the issues and workarounds outlined in


there is no way to use a type checked enumeration in the java "switch" statement with any of the cumbersome
workarounds. I find I use a lot of enumerations with my coding style, it seems
this would also be useful for others programming in Java. I could go on here
but the point I am trying to make is simple.
(Review ID: 115234)

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b14

WORK AROUND Name: boT120536 Date: 01/02/2001 1) Declare a class with a single int or String member variable and a single private constructor. 2) Implement equals(). 3) Add several public static final members that are instances of the class. 4) Use these members where you would use enums. Isn't that easy compared to enums? NOT!!! ======================================================================


EVALUATION Enums are just one more form of syntactic sugar that contribute no expressive power to the language. However, creaping featurism is the way of the world, and very few people really appreciate the maxim that "less is more". Many programmers think that "more is more" (ok, so it is intuitive). Those who want to throw everything including the kitchen sink into Java can vote for this RFE. gilad.bracha@eng 2001-01-04 The initial evaluation of this bug should not be construed to represent Sun's consensus opinion on the matter. While we are great fans of the "Typesafe Enum" pattern describe in Item 21 of Bloch's "Effective Java" (Addison-Wesley, 2001), we understand that this pattern's verbosity is a real disadvantage. We are actively investigating a language feature that would provide all the advantages of this pattern while eliminating the verbosity. ###@###.### 2002-01-09