United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6442437 : Allow reference to .class from generelized type identifier

Details
Type:
Enhancement
Submit Date:
2006-06-22
Status:
Closed
Updated Date:
2010-04-02
Project Name:
JDK
Resolved Date:
2006-06-23
Component:
tools
OS:
linux
Sub-Component:
javac
CPU:
x86
Priority:
P4
Resolution:
Duplicate
Affected Versions:
6
Fixed Versions:

Related Reports
Duplicate:

Sub Tasks

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>.

                                    

Comments



Hardware and Software, Engineered to Work Together