< prev index next >

jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java

Print this page

        

@@ -23,11 +23,10 @@
  * questions.
  */
 
 package java.lang.invoke;
 
-import jdk.experimental.value.ValueType;
 import jdk.internal.misc.SharedSecrets;
 import jdk.internal.module.IllegalAccessLogger;
 import jdk.internal.org.objectweb.asm.ClassReader;
 import jdk.internal.reflect.CallerSensitive;
 import jdk.internal.reflect.Reflection;

@@ -36,10 +35,11 @@
 import sun.invoke.util.VerifyAccess;
 import sun.invoke.util.Wrapper;
 import sun.reflect.misc.ReflectUtil;
 import sun.security.util.SecurityConstants;
 import valhalla.shady.MinimalValueTypes_1_0;
+import valhalla.shady.ValueTypeHolder;
 
 import java.lang.invoke.LambdaForm.BasicType;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Member;

@@ -54,11 +54,10 @@
 import java.util.Arrays;
 import java.util.BitSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Objects;
-import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 import static java.lang.invoke.MethodHandleImpl.Intrinsic;

@@ -1425,11 +1424,11 @@
          * @throws NullPointerException if any argument is null
          * @see #findVarHandle(Class, String, Class)
          */
         public MethodHandle findGetter(Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException {
             if (MinimalValueTypes_1_0.isValueType(refc)) {
-                return ValueType.forClass(MinimalValueTypes_1_0.getValueCapableClass(refc)).findGetter(this, name, type);
+                return MinimalValueTypes_1_0.findValueType(refc).findGetter(this, name, type);
             } else {
                 MemberName field = resolveOrFail(REF_getField, refc, name, type);
                 return getDirectField(REF_getField, refc, field);
             }
         }

@@ -2537,11 +2536,11 @@
      * @see java.lang.reflect.Array#newInstance(Class, int)
      * @since 9
      */
     public static
     MethodHandle arrayConstructor(Class<?> arrayClass) throws IllegalArgumentException {
-        ValueType<?> compValue = valueComponent(arrayClass);
+        ValueTypeHolder<?> compValue = valueComponent(arrayClass);
         if (compValue != null) {
             return compValue.newArray();
         } else {
             MethodHandle ani = MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_Array_newInstance).
                     bindTo(arrayClass.getComponentType());

@@ -2559,11 +2558,11 @@
      * @throws IllegalArgumentException if arrayClass is not an array type
      * @since 9
      */
     public static
     MethodHandle arrayLength(Class<?> arrayClass) throws IllegalArgumentException {
-        ValueType<?> compValue = valueComponent(arrayClass);
+        ValueTypeHolder<?> compValue = valueComponent(arrayClass);
         return (compValue != null) ?
                 compValue.arrayLength() :
                 MethodHandleImpl.makeArrayElementAccessor(arrayClass, MethodHandleImpl.ArrayAccess.LENGTH);
     }
 

@@ -2577,11 +2576,11 @@
      * @throws NullPointerException if the argument is null
      * @throws  IllegalArgumentException if arrayClass is not an array type
      */
     public static
     MethodHandle arrayElementGetter(Class<?> arrayClass) throws IllegalArgumentException {
-        ValueType<?> compValue = valueComponent(arrayClass);
+        ValueTypeHolder<?> compValue = valueComponent(arrayClass);
         return (compValue != null) ?
                 compValue.arrayGetter() :
                 MethodHandleImpl.makeArrayElementAccessor(arrayClass, MethodHandleImpl.ArrayAccess.GET);
     }
 

@@ -2595,25 +2594,25 @@
      * @throws NullPointerException if the argument is null
      * @throws IllegalArgumentException if arrayClass is not an array type
      */
     public static
     MethodHandle arrayElementSetter(Class<?> arrayClass) throws IllegalArgumentException {
-        ValueType<?> compValue = valueComponent(arrayClass);
+        ValueTypeHolder<?> compValue = valueComponent(arrayClass);
         return (compValue != null) ?
                 compValue.arraySetter() :
                 MethodHandleImpl.makeArrayElementAccessor(arrayClass, MethodHandleImpl.ArrayAccess.SET);
     }
 
     @SuppressWarnings("unchecked")
-    private static <Z> ValueType<Z> valueComponent(Class<Z> arrayClass) {
+    private static <Z> ValueTypeHolder<Z> valueComponent(Class<Z> arrayClass) {
         if (!arrayClass.isArray()) {
             throw newIllegalArgumentException("not an array class: " + arrayClass.getName());
         }
 
         Class<?> comp = arrayClass.getComponentType();
         if (MinimalValueTypes_1_0.isValueType(comp)) {
-            return (ValueType<Z>)ValueType.forClass(MinimalValueTypes_1_0.getValueCapableClass(comp));
+            return (ValueTypeHolder<Z>) MinimalValueTypes_1_0.findValueType(comp);
         } else {
             return null;
         }
     }
 

@@ -3381,11 +3380,11 @@
     public static MethodHandle zero(Class<?> type) {
         Objects.requireNonNull(type);
         if (type.isPrimitive()) {
             return zero(Wrapper.forPrimitiveType(type), type);
         } else if (MinimalValueTypes_1_0.isValueType(type)) {
-            return ValueType.forClass(MinimalValueTypes_1_0.getValueCapableClass(type)).defaultValueConstant();
+            return MinimalValueTypes_1_0.findValueType(type).defaultValueConstant();
         } else {
             return zero(Wrapper.OBJECT, type);
         }
     }
 

@@ -3419,11 +3418,11 @@
         if (!MinimalValueTypes_1_0.isValueType(ptype)) {
             MethodType mtype = MethodType.methodType(ptype, ptype);
             LambdaForm lform = LambdaForm.identityForm(BasicType.basicType(ptype));
             return MethodHandleImpl.makeIntrinsic(mtype, lform, Intrinsic.IDENTITY);
         } else {
-            return ValueType.forClass(MinimalValueTypes_1_0.getValueCapableClass(ptype)).identity();
+            return MinimalValueTypes_1_0.findValueType(ptype).identity();
         }
     }
 
     private static MethodHandle zero(Wrapper btw, Class<?> rtype) {
         int pos = btw.ordinal();

@@ -3496,11 +3495,11 @@
                 result = insertArgumentPrimitive(result, pos, ptype, value);
             } else if (MinimalValueTypes_1_0.isValueType(ptype)) {
                 Class<?> vcc = MinimalValueTypes_1_0.getValueCapableClass(ptype);
                 Objects.requireNonNull(value); // throw NPE if needed
                 value = vcc.cast(value);       // throw CCE if needed
-                MethodHandle unbox = ValueType.forClass(vcc).unbox();
+                MethodHandle unbox = MinimalValueTypes_1_0.findValueType(ptype).unbox();
                 result = result.bindArgumentQ(pos, value, unbox);
             } else {
                 value = ptype.cast(value);  // throw CCE if needed
                 result = result.bindArgumentL(pos, value);
             }
< prev index next >