Package net.bytebuddy.implementation
Class InvokeDynamic.AbstractDelegator
java.lang.Object
net.bytebuddy.implementation.InvokeDynamic
net.bytebuddy.implementation.InvokeDynamic.AbstractDelegator
- All Implemented Interfaces:
InstrumentedType.Prepareable,Implementation,Implementation.Composable
- Direct Known Subclasses:
InvokeDynamic.WithImplicitArguments,InvokeDynamic.WithImplicitType
- Enclosing class:
InvokeDynamic
An abstract delegator that allows to specify a configuration for any specification of an argument.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.bytebuddy.implementation.InvokeDynamic
InvokeDynamic.AbstractDelegator, InvokeDynamic.Appender, InvokeDynamic.InvocationProvider, InvokeDynamic.TerminationHandler, InvokeDynamic.WithImplicitArguments, InvokeDynamic.WithImplicitTarget, InvokeDynamic.WithImplicitTypeNested classes/interfaces inherited from interface net.bytebuddy.implementation.Implementation
Implementation.Composable, Implementation.Compound, Implementation.Context, Implementation.Simple, Implementation.SpecialMethodInvocation, Implementation.TargetNested classes/interfaces inherited from interface net.bytebuddy.dynamic.scaffold.InstrumentedType.Prepareable
InstrumentedType.Prepareable.NoOp -
Field Summary
Fields inherited from class net.bytebuddy.implementation.InvokeDynamic
arguments, assigner, bootstrap, invocationProvider, terminationHandler, typing -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractDelegator(MethodDescription.InDefinedShape bootstrap, List<? extends JavaConstant> arguments, InvokeDynamic.InvocationProvider invocationProvider, InvokeDynamic.TerminationHandler terminationHandler, Assigner assigner, Assigner.Typing typing) Creates a new abstract delegator for a dynamic method invocation. -
Method Summary
Modifier and TypeMethodDescriptionandThen(Implementation implementation) Appends the supplied implementation to this implementation.appender(Implementation.Target implementationTarget) Creates a byte code appender that determines the implementation of the instrumented type's methods.protected abstract InvokeDynamicResolves the current configuration into a fully initialized invoke dynamic instance.prepare(InstrumentedType instrumentedType) Prepares a given instrumented type.withArgument(int index) Passes a parameter of the instrumented method to the bootstrapped method.withArgument(int... index) Passes parameters of the instrumented method to the bootstrapped method.withAssigner(Assigner assigner, Assigner.Typing typing) Instructs this implementation to use the provided assigner and decides if the assigner should apply dynamic typing.withBooleanValue(boolean... value) Requires the bootstrap method to bootstrap a method that takes the specifiedbooleanarguments as its next parameters.withByteValue(byte... value) Requires the bootstrap method to bootstrap a method that takes the specifiedbytearguments as its next parameters.withCharacterValue(char... value) Requires the bootstrap method to bootstrap a method that takes the specifiedchararguments as its next parameters.withDoubleValue(double... value) Requires the bootstrap method to bootstrap a method that takes the specifieddoublearguments as its next parameters.withEnumeration(EnumerationDescription... enumerationDescription) Hands the provided enumerations to the dynamically bound method.Passes the values of the specified fields to the bootstrap method.Passes the values of the specified fields to the bootstrap method.withField(String name, FieldLocator.Factory fieldLocatorFactory) Passes the values of the specified fields to the bootstrap method.withField(FieldLocator.Factory fieldLocatorFactory, String... name) Passes the values of the specified fields to the bootstrap method.withFloatValue(float... value) Requires the bootstrap method to bootstrap a method that takes the specifiedfloatarguments as its next parameters.Adds a potentialthisreference and all method arguments to the the bootstrapped method.withInstance(JavaConstant... javaConstant) Hands the provided Java instance to the dynamically bound method.withIntegerValue(int... value) Requires the bootstrap method to bootstrap a method that takes the specifiedintarguments as its next parameters.withLongValue(long... value) Requires the bootstrap method to bootstrap a method that takes the specifiedlongarguments as its next parameters.Adds all method arguments to the the bootstrapped method.withNullValue(Class<?>... type) Passesnullvalues of the given types to the bootstrapped method.withNullValue(TypeDescription... typeDescription) Passesnullvalues of the given types to the bootstrapped method.withReference(Object value) Requires the bootstrap method to bootstrap a method that takes the specified argument as its next parameter while allowing to specify the value to be of a different type than the actual instance type.withReference(Object... value) Requires the bootstrap method to bootstrap a method that takes the specified arguments as its next parameters.withShortValue(short... value) Requires the bootstrap method to bootstrap a method that takes the specifiedshortarguments as its next parameters.Passes references tothisonto the operand stack where the instance is represented as the given types.withThis(TypeDescription... typeDescription) Passes references tothisonto the operand stack where the instance is represented as the given types.withType(TypeDescription... typeDescription) Hands the provided types to the dynamically bound method.Requires the bootstrap method to bootstrap a method that takes the specified arguments as its next parameters.
-
Constructor Details
-
AbstractDelegator
protected AbstractDelegator(MethodDescription.InDefinedShape bootstrap, List<? extends JavaConstant> arguments, InvokeDynamic.InvocationProvider invocationProvider, InvokeDynamic.TerminationHandler terminationHandler, Assigner assigner, Assigner.Typing typing) Creates a new abstract delegator for a dynamic method invocation.- Parameters:
bootstrap- The bootstrap method or constructor.arguments- The arguments that are provided to the bootstrap method or constructor.invocationProvider- The target provided that identifies the method to be bootstrapped.terminationHandler- A handler that handles the method return.assigner- The assigner to be used.typing- Indicates if dynamic type castings should be attempted for incompatible assignments.
-
-
Method Details
-
materialize
Resolves the current configuration into a fully initialized invoke dynamic instance.- Returns:
- The fully resolved invoke dynamic instance.
-
withBooleanValue
Requires the bootstrap method to bootstrap a method that takes the specifiedbooleanarguments as its next parameters.- Overrides:
withBooleanValuein classInvokeDynamic- Parameters:
value- The arguments to pass to the bootstrapped method.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
-
withByteValue
Requires the bootstrap method to bootstrap a method that takes the specifiedbytearguments as its next parameters.- Overrides:
withByteValuein classInvokeDynamic- Parameters:
value- The arguments to pass to the bootstrapped method.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
-
withShortValue
Requires the bootstrap method to bootstrap a method that takes the specifiedshortarguments as its next parameters.- Overrides:
withShortValuein classInvokeDynamic- Parameters:
value- The arguments to pass to the bootstrapped method.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
-
withCharacterValue
Requires the bootstrap method to bootstrap a method that takes the specifiedchararguments as its next parameters.- Overrides:
withCharacterValuein classInvokeDynamic- Parameters:
value- The arguments to pass to the bootstrapped method.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
-
withIntegerValue
Requires the bootstrap method to bootstrap a method that takes the specifiedintarguments as its next parameters.- Overrides:
withIntegerValuein classInvokeDynamic- Parameters:
value- The arguments to pass to the bootstrapped method.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
-
withLongValue
Requires the bootstrap method to bootstrap a method that takes the specifiedlongarguments as its next parameters.- Overrides:
withLongValuein classInvokeDynamic- Parameters:
value- The arguments to pass to the bootstrapped method.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
-
withFloatValue
Requires the bootstrap method to bootstrap a method that takes the specifiedfloatarguments as its next parameters.- Overrides:
withFloatValuein classInvokeDynamic- Parameters:
value- The arguments to pass to the bootstrapped method.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
-
withDoubleValue
Requires the bootstrap method to bootstrap a method that takes the specifieddoublearguments as its next parameters.- Overrides:
withDoubleValuein classInvokeDynamic- Parameters:
value- The arguments to pass to the bootstrapped method.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
-
withValue
Requires the bootstrap method to bootstrap a method that takes the specified arguments as its next parameters. Note that any primitive parameters are passed as their wrapper types. Furthermore, values that can be stored in the instrumented class's constant pool might be of different object identity when passed to the bootstrapped method or might not be visible to the the created class what later results in a runtime error.
- Overrides:
withValuein classInvokeDynamic- Parameters:
value- The arguments to pass to the bootstrapped method.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
-
withReference
Requires the bootstrap method to bootstrap a method that takes the specified argument as its next parameter while allowing to specify the value to be of a different type than the actual instance type.
- Overrides:
withReferencein classInvokeDynamic- Parameters:
value- The arguments to pass to the bootstrapped method.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
-
withReference
Requires the bootstrap method to bootstrap a method that takes the specified arguments as its next parameters. Note that any primitive parameters are passed as their wrapper types. Any value that is passed to the bootstrapped method is guaranteed to be of the same object identity.- Overrides:
withReferencein classInvokeDynamic- Parameters:
value- The arguments to pass to the bootstrapped method.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
-
withType
Hands the provided types to the dynamically bound method. The type is stored in the generated class's constant pool and is loaded at invocation time. For this to be possible, the created class's class loader must be able to see the provided type.- Overrides:
withTypein classInvokeDynamic- Parameters:
typeDescription- The classes to provide to the bound method as an argument.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified type.
-
withInstance
Hands the provided Java instance to the dynamically bound method. The instance is stored in the generated class's constant pool and is loaded at invocation time. For this to be possible, the created class's class loader must be able to create the provided Java instance.- Overrides:
withInstancein classInvokeDynamic- Parameters:
javaConstant- The constants to provide to the bound method as an argument.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified Java instance.
-
withNullValue
Passesnullvalues of the given types to the bootstrapped method.- Overrides:
withNullValuein classInvokeDynamic- Parameters:
type- The type that thenullvalues should represent.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
-
withNullValue
Passesnullvalues of the given types to the bootstrapped method.- Overrides:
withNullValuein classInvokeDynamic- Parameters:
typeDescription- The type that thenullvalues should represent.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
-
withArgument
Passes parameters of the instrumented method to the bootstrapped method.- Overrides:
withArgumentin classInvokeDynamic- Parameters:
index- The indices of the parameters that should be passed to the bootstrapped method.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
-
withArgument
Passes a parameter of the instrumented method to the bootstrapped method.- Overrides:
withArgumentin classInvokeDynamic- Parameters:
index- The index of the parameter that should be passed to the bootstrapped method.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified argument with its implicit type.
-
withThis
Passes references tothisonto the operand stack where the instance is represented as the given types.- Overrides:
withThisin classInvokeDynamic- Parameters:
type- The types as which thethisreference of the intercepted method should be masked.- Returns:
- This implementation where
thisreferences are passed as the next arguments.
-
withThis
Passes references tothisonto the operand stack where the instance is represented as the given types.- Overrides:
withThisin classInvokeDynamic- Parameters:
typeDescription- The types as which thethisreference of the intercepted method should be masked.- Returns:
- This implementation where
thisreferences are passed as the next arguments.
-
withMethodArguments
Adds all method arguments to the the bootstrapped method.- Overrides:
withMethodArgumentsin classInvokeDynamic- Returns:
- This invoke dynamic implementation with all parameters of the instrumented method added.
-
withImplicitAndMethodArguments
Adds a potentialthisreference and all method arguments to the the bootstrapped method.- Overrides:
withImplicitAndMethodArgumentsin classInvokeDynamic- Returns:
- This invoke dynamic implementation with a potential
thisreference and all parameters of the instrumented method added.
-
withField
Passes the values of the specified fields to the bootstrap method. Any of the specified fields must already exist for the instrumented type.- Overrides:
withFieldin classInvokeDynamic- Parameters:
fieldName- The names of the fields to be passed to the bootstrapped method.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
-
withEnumeration
Hands the provided enumerations to the dynamically bound method. The enumeration values are read from the enumeration class on demand. For this to be possible, the created class's class loader must be able to see the enumeration type.- Overrides:
withEnumerationin classInvokeDynamic- Parameters:
enumerationDescription- The enumeration values to provide to the bound method as an argument.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified enumerations.
-
withField
Passes the values of the specified fields to the bootstrap method. Any of the specified fields must already exist for the instrumented type.- Overrides:
withFieldin classInvokeDynamic- Parameters:
fieldLocatorFactory- The field locator factory to use.name- The names of the fields to be passed to the bootstrapped method.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
-
withField
Passes the values of the specified fields to the bootstrap method. Any of the specified fields must already exist for the instrumented type.- Overrides:
withFieldin classInvokeDynamic- Parameters:
name- The names of the fields to be passed to the bootstrapped method.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
-
withField
public InvokeDynamic.WithImplicitType withField(String name, FieldLocator.Factory fieldLocatorFactory) Passes the values of the specified fields to the bootstrap method. Any of the specified fields must already exist for the instrumented type.- Overrides:
withFieldin classInvokeDynamic- Parameters:
name- The names of the fields to be passed to the bootstrapped method.fieldLocatorFactory- The field locator factory to use.- Returns:
- This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
-
withAssigner
Instructs this implementation to use the provided assigner and decides if the assigner should apply dynamic typing.- Overrides:
withAssignerin classInvokeDynamic- Parameters:
assigner- The assigner to use.typing-trueif the assigner should attempt dynamic typing.- Returns:
- The invoke dynamic instruction where the given assigner and dynamic-typing directive are applied.
-
andThen
Appends the supplied implementation to this implementation.- Specified by:
andThenin interfaceImplementation.Composable- Overrides:
andThenin classInvokeDynamic- Parameters:
implementation- The subsequent implementation.- Returns:
- An implementation that combines this implementation with the provided one.
-
prepare
Prepares a given instrumented type.- Specified by:
preparein interfaceInstrumentedType.Prepareable- Overrides:
preparein classInvokeDynamic- Parameters:
instrumentedType- The instrumented type in its current form.- Returns:
- The prepared instrumented type.
-
appender
Creates a byte code appender that determines the implementation of the instrumented type's methods.- Specified by:
appenderin interfaceImplementation- Overrides:
appenderin classInvokeDynamic- Parameters:
implementationTarget- The target of the current implementation.- Returns:
- A byte code appender for implementing methods delegated to this implementation. This byte code appender
is also responsible for handling methods that were added by this implementation on the call to
InstrumentedType.Prepareable.prepare(InstrumentedType).
-