Enum AgentBuilder.LambdaInstrumentationStrategy.MetaFactoryRedirection

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<AgentBuilder.LambdaInstrumentationStrategy.MetaFactoryRedirection>, AsmVisitorWrapper.ForDeclaredMethods.MethodVisitorWrapper
    Enclosing class:
    AgentBuilder.LambdaInstrumentationStrategy

    protected static enum AgentBuilder.LambdaInstrumentationStrategy.MetaFactoryRedirection
    extends java.lang.Enum<AgentBuilder.LambdaInstrumentationStrategy.MetaFactoryRedirection>
    implements AsmVisitorWrapper.ForDeclaredMethods.MethodVisitorWrapper
    Implements the regular lambda meta factory. The implementation represents the following code:
     public static CallSite metafactory(MethodHandles.Lookup caller,
         String invokedName,
         MethodType invokedType,
         MethodType samMethodType,
         MethodHandle implMethod,
         MethodType instantiatedMethodType) throws Exception {
       Unsafe unsafe = Unsafe.getUnsafe();
       Class<?> lambdaClass = unsafe.defineAnonymousClass(caller.lookupClass(),
           (byte[]) ClassLoader.getSystemClassLoader().loadClass("net.bytebuddy.agent.builder.LambdaFactory").getDeclaredMethod("make",
               Object.class,
               String.class,
               Object.class,
               Object.class,
               Object.class,
               Object.class,
               boolean.class,
               List.class,
               List.class).invoke(null,
                   caller,
                   invokedName,
                   invokedType,
                   samMethodType,
                   implMethod,
                   instantiatedMethodType,
                   false,
                   Collections.emptyList(),
                   Collections.emptyList()),
           null);
       unsafe.ensureClassInitialized(lambdaClass);
       return invokedType.parameterCount() == 0
         ? new ConstantCallSite(MethodHandles.constant(invokedType.returnType(), lambdaClass.getDeclaredConstructors()[0].newInstance()))
         : new ConstantCallSite(MethodHandles.Lookup.IMPL_LOOKUP.findStatic(lambdaClass, "get$Lambda", invokedType));
     
    • Constructor Detail

      • MetaFactoryRedirection

        private MetaFactoryRedirection()
    • Method Detail

      • values

        public static AgentBuilder.LambdaInstrumentationStrategy.MetaFactoryRedirection[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (AgentBuilder.LambdaInstrumentationStrategy.MetaFactoryRedirection c : AgentBuilder.LambdaInstrumentationStrategy.MetaFactoryRedirection.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static AgentBuilder.LambdaInstrumentationStrategy.MetaFactoryRedirection valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • wrap

        public org.objectweb.asm.MethodVisitor wrap​(TypeDescription instrumentedType,
                                                    MethodDescription instrumentedMethod,
                                                    org.objectweb.asm.MethodVisitor methodVisitor,
                                                    Implementation.Context implementationContext,
                                                    TypePool typePool,
                                                    int writerFlags,
                                                    int readerFlags)
        Wraps a method visitor.
        Specified by:
        wrap in interface AsmVisitorWrapper.ForDeclaredMethods.MethodVisitorWrapper
        Parameters:
        instrumentedType - The instrumented type.
        instrumentedMethod - The method that is currently being defined.
        methodVisitor - The original field visitor that defines the given method.
        implementationContext - The implementation context to use.
        typePool - The type pool to use.
        writerFlags - The ASM ClassWriter reader flags to consider.
        readerFlags - The ASM ClassReader reader flags to consider.
        Returns:
        The wrapped method visitor.