< prev index next >

src/java.base/share/classes/sun/invoke/util/Wrapper.java

Print this page
rev 52786 : 8210031: implementation for JVM Constants API

@@ -45,19 +45,21 @@
     public static final int COUNT = 10;
 
     private final Class<?> wrapperType;
     private final Class<?> primitiveType;
     private final char     basicTypeChar;
+    private final String   basicTypeString;
     private final Object   emptyArray;
     private final int      format;
     private final String   wrapperSimpleName;
     private final String   primitiveSimpleName;
 
     private Wrapper(Class<?> wtype, String wtypeName, Class<?> ptype, String ptypeName, char tchar, Object emptyArray, int format) {
         this.wrapperType = wtype;
         this.primitiveType = ptype;
         this.basicTypeChar = tchar;
+        this.basicTypeString = new String(new char[] {this.basicTypeChar});
         this.emptyArray = emptyArray;
         this.format = format;
         this.wrapperSimpleName = wtypeName;
         this.primitiveSimpleName = ptypeName;
     }

@@ -457,10 +459,15 @@
     /** What is the bytecode signature character for this wrapper's
      *  primitive type?
      */
     public char basicTypeChar() { return basicTypeChar; }
 
+    /** What is the bytecode signature string for this wrapper's
+     *  primitive type?
+     */
+    public String basicTypeString() { return basicTypeString; }
+
     /** What is the simple name of the wrapper type?
      */
     public String wrapperSimpleName() { return wrapperSimpleName; }
 
     /** What is the simple name of the primitive type?

@@ -579,13 +586,12 @@
      * Produces an {@code Integer} for {@code OBJECT}, although the exact type
      * of the operand is not known.
      * Returns null for {@code VOID}.
      */
     public Object wrap(int x) {
-        if (basicTypeChar == 'L')  return (Integer)x;
         switch (basicTypeChar) {
-            case 'L': throw newIllegalArgumentException("cannot wrap to object type");
+            case 'L': return (Integer)x;
             case 'V': return null;
             case 'I': return Integer.valueOf(x);
             case 'J': return Long.valueOf(x);
             case 'F': return Float.valueOf(x);
             case 'D': return Double.valueOf(x);
< prev index next >