src/java.base/share/classes/valhalla/shady/MinimalValueTypes_1_0.java

Print this page

        

@@ -51,19 +51,22 @@
     public static final String DERIVE_VALUE_TYPE_DESC = "Ljvm/internal/value/DeriveValueType;";
     public static final String DERIVE_VT_CLASSNAME_POSTFIX = "$Value";
     public static final int    DERIVE_VT_CLASS_ACCESS = ACC_PUBLIC|ACC_SUPER|ACC_FINAL|ACC_VALUE|ACC_SYNTHETIC;
 
     public static final boolean DUMP_CLASS_FILES;
+    public static final boolean MANGLE_CLASS_INFO;
     private static final JavaLangAccess JLA;
 
     static {
         // Use same property as in j.l.invoke.MethodHandleStatics
         Properties props = GetPropertyAction.privilegedGetProperties();
         DUMP_CLASS_FILES = Boolean.parseBoolean(
             props.getProperty("java.lang.invoke.MethodHandle.DUMP_CLASS_FILES"));
 
         JLA = SharedSecrets.getJavaLangAccess();
+        MANGLE_CLASS_INFO = Boolean.parseBoolean(
+            props.getProperty("valhalla.mangleClassInfo"));
     }
 
     public static String getValueTypeClassName(ValueTypeDesc valueTypeDesc) {
         return getValueTypeClassName(valueTypeDesc.getName());
     }

@@ -130,13 +133,13 @@
 
     public static byte[] createValueType(ValueTypeDesc valueTypeDesc) {
 
         String valueTypeClassName = getValueTypeClassName(valueTypeDesc);
 
-        BasicClassBuilder builder = new BasicClassBuilder(valueTypeClassName, 53, 1)
+        BasicClassBuilder builder = new BasicClassBuilder(mangleValueClassName(valueTypeClassName), 53, 1)
             .withFlags(DERIVE_VT_CLASS_ACCESS)
-            .withSuperclass(VALUE_CLASS_DESC);
+            .withSuperclass(mangleValueClassName(VALUE_CLASS_DESC));
 
         ValueTypeDesc.Field[] fields = valueTypeDesc.getFields();
         for (ValueTypeDesc.Field field : fields) {
             builder.withField(field.name, field.type, F -> F.withFlags(field.modifiers));
         }

@@ -188,6 +191,12 @@
     private final native Class<?> getDerivedValueType(Class<?> ofClass);
 
     public static Class<?> getValueClass() {
         return (Class<?>)(Object)__Value.class; //hack around static type-system checks
     }
+
+    public static String mangleValueClassName(String name) {
+        return MANGLE_CLASS_INFO ?
+                ";Q" + name + ";" :
+                name;
+    }
 }