JDK-6548438 : (enum) java.lang.Enum should have a values(Class) method.
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 6
  • Priority: P5
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2007-04-20
  • Updated: 2018-08-14
  • Resolved: 2018-08-14
Related Reports
Relates :  
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
java.lang.Enum should have a static method values(Class<T>).
The signature of the method would be that:

public static <T extends Enum<T>> T[] values(Class<T> enumType);

JUSTIFICATION :
Every enum class has a static method valueOf(String) which the compiler generates in subclasses. The java.lang.Enum has the static method valueOf(Class<T>, String) which is a "companion" of the valueOf(String). The method valueOf(Class<T>, String) is very helpful in enum-based data structures.

However, the values() method doesn't have a "companion" in java.lang.Enum. This makes a defficiency when working in enum-based data structures which the method values(Class<T>) could easily supply.

Comments
There is the method on java.lang.Class<T> T[] Class.getEnumConstants() Is that sufficient?
18-02-2015