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

(reflect) Add Enum for generic access to primitive types

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 6
    • core-libs

      A DESCRIPTION OF THE REQUEST :
      Currently, the JDK does not provide a way of dynamically accessing all Classes for which isPrimitive() returns true.

      JUSTIFICATION :
      There are scenarios where it would be desirable to iterate over the Classes for which isPrimitive() returns true WITHOUT an 8-fold case distinction. Ideally, this would be realized via an enum named "Primitive" (or something like that), similar to the PrimitiveType.Kind enum of the mirror API. Also, problems arising in wrapping situations should be eased by the implementation of utility methods.



      ---------- BEGIN SOURCE ----------
      public enum Primitive {
        BOOLEAN,
        BYTE,
        CHAR,
        DOUBLE,
        FLOAT,
        INTEGER,
        LONG,
        SHORT;
        public Class getWrappedClass() {...}
        public Class getWrapperClass() {...}
        public Object getDefaultValue() {...}
      }

      The method getDefaultValue() would return wrapped values of the primitives that are used for initialization e.g. of arrays of the corresponding types (i.e. false resp. the different flavors of zero)
      ---------- END SOURCE ----------
      ###@###.### 2005-04-25 20:21:28 GMT

            darcy Joe Darcy
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: