Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6442437

Allow reference to .class from generelized type identifier

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6
    • tools
    • x86
    • linux

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

            Unassigned Unassigned
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: