< prev index next >

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

Print this page
*** 24,11 ***
--- 24,13 ---
   */
  package java.lang.invoke;
  
  import sun.invoke.util.Wrapper;
  
+ import java.lang.classfile.ClassBuilder;
  import java.lang.reflect.Modifier;
+ import java.util.function.Function;
  
  import static java.lang.invoke.MethodHandleInfo.*;
  import static sun.invoke.util.Wrapper.forPrimitiveType;
  import static sun.invoke.util.Wrapper.forWrapperType;
  import static sun.invoke.util.Wrapper.isWrapperType;

*** 67,11 ***
      final Class<?> implClass;                 // Class for referencing the implementation method "class CC"
      final MethodType dynamicMethodType;       // Dynamically checked method type "(Integer)Object"
      final boolean isSerializable;             // Should the returned instance be serializable
      final Class<?>[] altInterfaces;           // Additional interfaces to be implemented
      final MethodType[] altMethods;            // Signatures of additional methods to bridge
! 
  
      /**
       * Meta-factory constructor.
       *
       * @param caller Stacked automatically by VM; represents a lookup context
--- 69,11 ---
      final Class<?> implClass;                 // Class for referencing the implementation method "class CC"
      final MethodType dynamicMethodType;       // Dynamically checked method type "(Integer)Object"
      final boolean isSerializable;             // Should the returned instance be serializable
      final Class<?>[] altInterfaces;           // Additional interfaces to be implemented
      final MethodType[] altMethods;            // Signatures of additional methods to bridge
!     final Function<ClassBuilder, Object> finisher; // Function called to finish lambda class build process, returns additional class data (can be null)
  
      /**
       * Meta-factory constructor.
       *
       * @param caller Stacked automatically by VM; represents a lookup context

*** 103,10 ***
--- 105,13 ---
       *                       types must extend {@code Serializable}.
       * @param altInterfaces Additional interfaces which the lambda object
       *                      should implement.
       * @param altMethods Method types for additional signatures to be
       *                   implemented by invoking the implementation method
+      * @param finisher Function called at the end of the lambda class build process
+      *                 that returns an additional object to append to the class data,
+      *                 may be (@code null}, may return {@code null}.
       * @throws LambdaConversionException If any of the meta-factory protocol
       *         invariants are violated
       */
      AbstractValidatingLambdaMetafactory(MethodHandles.Lookup caller,
                                          MethodType factoryType,

*** 114,11 ***
                                          MethodType interfaceMethodType,
                                          MethodHandle implementation,
                                          MethodType dynamicMethodType,
                                          boolean isSerializable,
                                          Class<?>[] altInterfaces,
!                                         MethodType[] altMethods)
              throws LambdaConversionException {
          if (!caller.hasFullPrivilegeAccess()) {
              throw new LambdaConversionException(String.format(
                      "Invalid caller: %s",
                      caller.lookupClass().getName()));
--- 119,12 ---
                                          MethodType interfaceMethodType,
                                          MethodHandle implementation,
                                          MethodType dynamicMethodType,
                                          boolean isSerializable,
                                          Class<?>[] altInterfaces,
!                                         MethodType[] altMethods,
+                                         Function<ClassBuilder, Object> finisher)
              throws LambdaConversionException {
          if (!caller.hasFullPrivilegeAccess()) {
              throw new LambdaConversionException(String.format(
                      "Invalid caller: %s",
                      caller.lookupClass().getName()));

*** 175,10 ***
--- 181,11 ---
  
          this.dynamicMethodType = dynamicMethodType;
          this.isSerializable = isSerializable;
          this.altInterfaces = altInterfaces;
          this.altMethods = altMethods;
+         this.finisher = finisher;
  
          if (interfaceMethodName.isEmpty() ||
                  interfaceMethodName.indexOf('.') >= 0 ||
                  interfaceMethodName.indexOf(';') >= 0 ||
                  interfaceMethodName.indexOf('[') >= 0 ||
< prev index next >