< prev index next >

src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java

Print this page
*** 28,10 ***
--- 28,11 ---
  import java.io.Serializable;
  import java.util.Arrays;
  import java.lang.reflect.Array;
  import java.util.Objects;
  
+ import jdk.internal.access.JavaLangInvokeAccess.ReflectableLambdaInfo;
  import jdk.internal.vm.annotation.AOTSafeClassInitializer;
  
  /**
   * <p>Methods to facilitate the creation of simple "function objects" that
   * implement one or more interfaces by delegation to a provided {@link MethodHandle},

*** 341,20 ***
                                         MethodType factoryType,
                                         MethodType interfaceMethodType,
                                         MethodHandle implementation,
                                         MethodType dynamicMethodType)
              throws LambdaConversionException {
!         AbstractValidatingLambdaMetafactory mf;
!         mf = new InnerClassLambdaMetafactory(Objects.requireNonNull(caller),
!                                              Objects.requireNonNull(factoryType),
!                                              Objects.requireNonNull(interfaceMethodName),
!                                              Objects.requireNonNull(interfaceMethodType),
!                                              Objects.requireNonNull(implementation),
!                                              Objects.requireNonNull(dynamicMethodType),
!                                              false,
!                                              EMPTY_CLASS_ARRAY,
!                                              EMPTY_MT_ARRAY);
          mf.validateMetafactoryArgs();
          return mf.buildCallSite();
      }
  
      /**
--- 342,32 ---
                                         MethodType factoryType,
                                         MethodType interfaceMethodType,
                                         MethodHandle implementation,
                                         MethodType dynamicMethodType)
              throws LambdaConversionException {
!         return metafactoryInternal(caller, interfaceMethodName, factoryType, interfaceMethodType,
!                 implementation, dynamicMethodType, null);
!     }
! 
!     static CallSite metafactoryInternal(MethodHandles.Lookup caller,
!                                                String interfaceMethodName,
!                                                MethodType factoryType,
!                                                MethodType interfaceMethodType,
!                                                MethodHandle implementation,
!                                                MethodType dynamicMethodType,
+                                                ReflectableLambdaInfo reflectableLambdaInfo)
+             throws LambdaConversionException {
+         AbstractValidatingLambdaMetafactory mf = new InnerClassLambdaMetafactory(Objects.requireNonNull(caller),
+                 Objects.requireNonNull(factoryType),
+                 Objects.requireNonNull(interfaceMethodName),
+                 Objects.requireNonNull(interfaceMethodType),
+                 Objects.requireNonNull(implementation),
+                 Objects.requireNonNull(dynamicMethodType),
+                 false,
+                 EMPTY_CLASS_ARRAY,
+                 EMPTY_MT_ARRAY,
+                 reflectableLambdaInfo);
          mf.validateMetafactoryArgs();
          return mf.buildCallSite();
      }
  
      /**

*** 487,10 ***
--- 500,19 ---
      public static CallSite altMetafactory(MethodHandles.Lookup caller,
                                            String interfaceMethodName,
                                            MethodType factoryType,
                                            Object... args)
              throws LambdaConversionException {
+         return altMetafactoryInternal(caller, interfaceMethodName, factoryType, null, args);
+     }
+ 
+     static CallSite altMetafactoryInternal(MethodHandles.Lookup caller,
+                                           String interfaceMethodName,
+                                           MethodType factoryType,
+                                           ReflectableLambdaInfo reflectableLambdaInfo,
+                                           Object... args)
+             throws LambdaConversionException {
          Objects.requireNonNull(caller);
          Objects.requireNonNull(interfaceMethodName);
          Objects.requireNonNull(factoryType);
          Objects.requireNonNull(args);
          int argIndex = 0;

*** 508,10 ***
--- 530,11 ---
              if (altInterfaceCount > 0) {
                  altInterfaces = extractArgs(args, argIndex, Class.class, altInterfaceCount);
                  argIndex += altInterfaceCount;
              }
          }
+ 
          if ((flags & FLAG_BRIDGES) != 0) {
              int altMethodCount = extractArg(args, argIndex++, Integer.class);
              if (altMethodCount < 0) {
                  throw new IllegalArgumentException("negative argument count");
              }

*** 535,18 ***
              }
          }
  
          AbstractValidatingLambdaMetafactory mf
                  = new InnerClassLambdaMetafactory(caller,
!                                                   factoryType,
!                                                   interfaceMethodName,
!                                                   interfaceMethodType,
!                                                   implementation,
!                                                   dynamicMethodType,
!                                                   isSerializable,
!                                                   altInterfaces,
!                                                   altMethods);
          mf.validateMetafactoryArgs();
          return mf.buildCallSite();
      }
  
      private static <T> T extractArg(Object[] args, int index, Class<T> type) {
--- 558,19 ---
              }
          }
  
          AbstractValidatingLambdaMetafactory mf
                  = new InnerClassLambdaMetafactory(caller,
!                 factoryType,
!                 interfaceMethodName,
!                 interfaceMethodType,
!                 implementation,
!                 dynamicMethodType,
!                 isSerializable,
!                 altInterfaces,
!                 altMethods,
+                 reflectableLambdaInfo);
          mf.validateMetafactoryArgs();
          return mf.buildCallSite();
      }
  
      private static <T> T extractArg(Object[] args, int index, Class<T> type) {
< prev index next >