JDK-6442437 : Allow reference to .class from generelized type identifier
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2006-06-22
  • Updated: 2010-04-02
  • Resolved: 2006-06-23
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE REQUEST :
When writing a class that supports generics, I'd like to be retrieve a handle to the Class reference for my generalized type. This should be possible by calling T.class (where T is my type identifier), but the compiler doesn't allow this.

JUSTIFICATION :
In my case, I need to call getEnumConstants() on class to get all of the declared enumeration values in an enum class. Other implementations might be interested in having the class for using reflection or logging class information.


CUSTOMER SUBMITTED WORKAROUND :
Currently, the best workaround is to create a constructor with an argument of Class<T>.