src/java.base/share/classes/jdk/experimental/value/MethodHandleBuilder.java

Print this page

        

*** 35,55 **** import jdk.experimental.bytecode.TypeHelper; import jdk.experimental.bytecode.TypeTag; import jdk.experimental.bytecode.TypedCodeBuilder; import jdk.experimental.value.MethodHandleBuilder.IsolatedMethodBuilder.IsolatedMethodPoolHelper; import jdk.internal.misc.Unsafe; ! import sun.security.action.GetBooleanAction; import valhalla.shady.MinimalValueTypes_1_0; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles.Lookup; import java.lang.invoke.MethodType; ! import java.security.AccessController; ! import java.util.HashMap; ! import java.util.Iterator; ! import java.util.Map; ! import java.util.PropertyPermission; import java.util.function.Consumer; import java.util.function.Function; /** * Utility class for building method handles. --- 35,51 ---- import jdk.experimental.bytecode.TypeHelper; import jdk.experimental.bytecode.TypeTag; import jdk.experimental.bytecode.TypedCodeBuilder; import jdk.experimental.value.MethodHandleBuilder.IsolatedMethodBuilder.IsolatedMethodPoolHelper; import jdk.internal.misc.Unsafe; ! import sun.security.action.GetPropertyAction; import valhalla.shady.MinimalValueTypes_1_0; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles.Lookup; import java.lang.invoke.MethodType; ! import java.util.*; import java.util.function.Consumer; import java.util.function.Function; /** * Utility class for building method handles.
*** 57,73 **** public class MethodHandleBuilder { static final Unsafe UNSAFE = Unsafe.getUnsafe(); static final boolean ENABLE_POOL_PATCHES; static { ! final String key = "valhalla.enablePoolPatches"; ! ENABLE_POOL_PATCHES = key == null ? false : ! AccessController.doPrivileged( ! new GetBooleanAction(key), null, ! new PropertyPermission(key , "read")); } public static MethodHandle loadCode(Lookup lookup, String name, MethodType type, Consumer<? super MethodHandleCodeBuilder> builder) { return loadCode(lookup, name, type.toMethodDescriptorString(), builder); } --- 53,70 ---- public class MethodHandleBuilder { static final Unsafe UNSAFE = Unsafe.getUnsafe(); static final boolean ENABLE_POOL_PATCHES; + static final boolean MANGLE_CLASS_INFO; static { ! Properties props = GetPropertyAction.privilegedGetProperties(); ! ENABLE_POOL_PATCHES = Boolean.parseBoolean( ! props.getProperty("valhalla.enablePoolPatches")); ! MANGLE_CLASS_INFO = Boolean.parseBoolean( ! props.getProperty("valhalla.mangleClassInfo")); } public static MethodHandle loadCode(Lookup lookup, String name, MethodType type, Consumer<? super MethodHandleCodeBuilder> builder) { return loadCode(lookup, name, type.toMethodDescriptorString(), builder); }
*** 212,222 **** IsolatedMethodPoolHelper(String clazz) { this.clazz = clazz; } String from(Class<?> c) { ! String name = c == THIS_CLASS ? clazz : c.getName(); return name.replaceAll("\\.", "/"); } @Override public int putClass(Class<?> symbol) { --- 209,228 ---- IsolatedMethodPoolHelper(String clazz) { this.clazz = clazz; } String from(Class<?> c) { ! String name; ! boolean isValue = MinimalValueTypes_1_0.isValueType(c); ! if (c == THIS_CLASS) { ! //THIS_CLASS cannot be a DVT (by construction) - never mangle ! name = clazz; ! } else { ! name = (isValue && MANGLE_CLASS_INFO) ? ! ";Q" + c.getName() + ";" : //mangle DVT name ! c.getName(); ! } return name.replaceAll("\\.", "/"); } @Override public int putClass(Class<?> symbol) {