Package net.bytebuddy.agent.builder
Enum AgentBuilder.LambdaInstrumentationStrategy.AlternativeMetaFactoryRedirection
- java.lang.Object
-
- java.lang.Enum<AgentBuilder.LambdaInstrumentationStrategy.AlternativeMetaFactoryRedirection>
-
- net.bytebuddy.agent.builder.AgentBuilder.LambdaInstrumentationStrategy.AlternativeMetaFactoryRedirection
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<AgentBuilder.LambdaInstrumentationStrategy.AlternativeMetaFactoryRedirection>
,AsmVisitorWrapper.ForDeclaredMethods.MethodVisitorWrapper
- Enclosing class:
- AgentBuilder.LambdaInstrumentationStrategy
protected static enum AgentBuilder.LambdaInstrumentationStrategy.AlternativeMetaFactoryRedirection extends java.lang.Enum<AgentBuilder.LambdaInstrumentationStrategy.AlternativeMetaFactoryRedirection> implements AsmVisitorWrapper.ForDeclaredMethods.MethodVisitorWrapper
Implements the alternative lambda meta factory. The implementation represents the following code:public static CallSite altMetafactory(MethodHandles.Lookup caller, String invokedName, MethodType invokedType, Object... args) throws Exception { int flags = (Integer) args[3]; int argIndex = 4;
Class<?>[]
markerInterface; if ((flags&
FLAG_MARKERS) != 0) { int markerCount = (Integer) args[argIndex++]; markerInterface = newClass<?>
[markerCount]; System.arraycopy(args, argIndex, markerInterface, 0, markerCount); argIndex += markerCount; } else { markerInterface = newClass<?>
[0]; } MethodType[] additionalBridge; if ((flags&
FLAG_BRIDGES) != 0) { int bridgeCount = (Integer) args[argIndex++]; additionalBridge = new MethodType[bridgeCount]; System.arraycopy(args, argIndex, additionalBridge, 0, bridgeCount); // argIndex += bridgeCount; } else { additionalBridge = new MethodType[0]; } 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, args[0], args[1], args[2], (flags&
FLAG_SERIALIZABLE) != 0, Arrays.asList(markerInterface), Arrays.asList(additionalBridge)), 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)); }
-
-
Enum Constant Summary
Enum Constants Enum Constant Description INSTANCE
The singleton instance.
-
Constructor Summary
Constructors Modifier Constructor Description private
AlternativeMetaFactoryRedirection()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AgentBuilder.LambdaInstrumentationStrategy.AlternativeMetaFactoryRedirection
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static AgentBuilder.LambdaInstrumentationStrategy.AlternativeMetaFactoryRedirection[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.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.
-
-
-
Enum Constant Detail
-
INSTANCE
public static final AgentBuilder.LambdaInstrumentationStrategy.AlternativeMetaFactoryRedirection INSTANCE
The singleton instance.
-
-
Method Detail
-
values
public static AgentBuilder.LambdaInstrumentationStrategy.AlternativeMetaFactoryRedirection[] 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.AlternativeMetaFactoryRedirection c : AgentBuilder.LambdaInstrumentationStrategy.AlternativeMetaFactoryRedirection.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.AlternativeMetaFactoryRedirection 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 namejava.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 interfaceAsmVisitorWrapper.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 ASMClassWriter
reader flags to consider.readerFlags
- The ASMClassReader
reader flags to consider.- Returns:
- The wrapped method visitor.
-
-