< prev index next >

src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java

Print this page

        

@@ -28,12 +28,10 @@
 import java.io.ByteArrayOutputStream;
 import java.io.DataOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.lang.reflect.Array;
-import java.lang.reflect.Method;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedList;

@@ -1410,23 +1408,32 @@
         }
     }
 
     /**
      * Generate code to invoke the Class.forName with the name of the given
-     * class to get its Class object at runtime.  The code is written to
-     * the supplied stream.  Note that the code generated by this method
-     * may caused the checked ClassNotFoundException to be thrown.
+     * class to get its Class object at runtime.  And also generate code
+     * to invoke Class.asValueBox if the class is regular value type.
+     *
+     * The code is written to the supplied stream.  Note that the code generated
+     * by this method may caused the checked ClassNotFoundException to be thrown.
      */
     private void codeClassForName(Class<?> cl, DataOutputStream out)
         throws IOException
     {
         code_ldc(cp.getString(cl.getName()), out);
 
         out.writeByte(opc_invokestatic);
         out.writeShort(cp.getMethodRef(
             "java/lang/Class",
             "forName", "(Ljava/lang/String;)Ljava/lang/Class;"));
+
+        if (cl.isValue() && cl == cl.asValueType()) {
+            out.writeByte(opc_invokevirtual);
+            out.writeShort(cp.getMethodRef(
+                "java/lang/Class",
+                "asValueType", "()Ljava/lang/Class;"));
+        }
     }
 
 
     /*
      * ==================== General Utility Methods ====================

@@ -1486,11 +1493,12 @@
              *
              *     return "[" + getTypeDescriptor(type.getComponentType());
              */
             return type.getName().replace('.', '/');
         } else {
-            return "L" + dotToSlash(type.getName()) + ";";
+            char prefix = type.isValue() && type == type.asValueType() ? 'Q' : 'L';
+            return prefix + dotToSlash(type.getName()) + ";";
         }
     }
 
     /**
      * Returns a human-readable string representing the signature of a
< prev index next >