@HashCodeAndEqualsPlugin.Enhance public class InvokeDynamic extends Object implements Implementation.Composable
Modifier and Type | Class and Description |
---|---|
protected static class |
InvokeDynamic.AbstractDelegator
An abstract delegator that allows to specify a configuration for any specification of an argument.
|
protected class |
InvokeDynamic.Appender
The byte code appender to be used by the
InvokeDynamic implementation. |
protected static interface |
InvokeDynamic.InvocationProvider
An invocation provider is responsible for loading the arguments of the invoked method onto the operand
stack and for creating the actual invoke dynamic instruction.
|
protected static class |
InvokeDynamic.TerminationHandler
A termination handler is responsible to handle the return value of a method that is invoked via a
InvokeDynamic . |
static class |
InvokeDynamic.WithImplicitArguments
Representation of an
InvokeDynamic implementation where the bootstrapped
method is passed a this reference, if available, and any arguments of the instrumented method. |
static class |
InvokeDynamic.WithImplicitTarget
Representation of an
InvokeDynamic implementation where the bootstrapped
method is passed a this reference, if available, and any arguments of the instrumented method and
where the invocation target is implicit. |
static class |
InvokeDynamic.WithImplicitType
An
InvokeDynamic invocation where the last argument is assigned its implicit type. |
Implementation.Composable, Implementation.Compound, Implementation.Context, Implementation.Simple, Implementation.SpecialMethodInvocation, Implementation.Target
InstrumentedType.Prepareable.NoOp
Modifier and Type | Field and Description |
---|---|
protected List<? extends JavaConstant> |
arguments
The arguments that are provided to the bootstrap method.
|
protected Assigner |
assigner
The assigner to be used.
|
protected MethodDescription.InDefinedShape |
bootstrap
The bootstrap method.
|
protected InvokeDynamic.InvocationProvider |
invocationProvider
The target provided that identifies the method to be bootstrapped.
|
protected InvokeDynamic.TerminationHandler |
terminationHandler
A handler that handles the method return.
|
protected Assigner.Typing |
typing
Indicates if dynamic type castings should be attempted for incompatible assignments.
|
Modifier | Constructor and Description |
---|---|
protected |
InvokeDynamic(MethodDescription.InDefinedShape bootstrap,
List<? extends JavaConstant> arguments,
InvokeDynamic.InvocationProvider invocationProvider,
InvokeDynamic.TerminationHandler terminationHandler,
Assigner assigner,
Assigner.Typing typing)
Creates a new invoke dynamic implementation.
|
Modifier and Type | Method and Description |
---|---|
Implementation.Composable |
andThen(Implementation.Composable implementation)
Appends the supplied composable implementation to this implementation.
|
Implementation |
andThen(Implementation implementation)
Appends the supplied implementation to this implementation.
|
ByteCodeAppender |
appender(Implementation.Target implementationTarget)
Creates a byte code appender that determines the implementation of the instrumented type's methods.
|
static InvokeDynamic.WithImplicitTarget |
bootstrap(Constructor<?> constructor,
List<?> constants)
Implements the instrumented method with a dynamic method invocation which is linked at runtime using the
specified bootstrap constructor.
|
static InvokeDynamic.WithImplicitTarget |
bootstrap(Constructor<?> constructor,
Object... constant)
Implements the instrumented method with a dynamic method invocation which is linked at runtime using the
specified bootstrap constructor.
|
static InvokeDynamic.WithImplicitTarget |
bootstrap(MethodDescription.InDefinedShape bootstrap,
List<?> constants)
Implements the instrumented method with a dynamic method invocation which is linked at runtime using the
specified bootstrap method or constructor.
|
static InvokeDynamic.WithImplicitTarget |
bootstrap(MethodDescription.InDefinedShape bootstrap,
Object... constant)
Implements the instrumented method with a dynamic method invocation which is linked at runtime using the
specified bootstrap method or constructor.
|
static InvokeDynamic.WithImplicitTarget |
bootstrap(Method method,
List<?> constants)
Implements the instrumented method with a dynamic method invocation which is linked at runtime using the
specified bootstrap method.
|
static InvokeDynamic.WithImplicitTarget |
bootstrap(Method method,
Object... constant)
Implements the instrumented method with a dynamic method invocation which is linked at runtime using the
specified bootstrap method.
|
static InvokeDynamic.WithImplicitArguments |
lambda(MethodDescription.InDefinedShape methodDescription,
TypeDefinition functionalInterface)
Creates a lambda expression using the JVM's lambda meta factory.
|
static InvokeDynamic.WithImplicitArguments |
lambda(MethodDescription.InDefinedShape methodDescription,
TypeDefinition functionalInterface,
MethodGraph.Compiler methodGraphCompiler)
Creates a lambda expression using the JVM's lambda meta factory.
|
static InvokeDynamic.WithImplicitArguments |
lambda(Method method,
Type functionalInterface)
Creates a lambda expression using the JVM's lambda meta factory.
|
static InvokeDynamic.WithImplicitArguments |
lambda(Method method,
Type functionalInterface,
MethodGraph.Compiler methodGraphCompiler)
Creates a lambda expression using the JVM's lambda meta factory.
|
InstrumentedType |
prepare(InstrumentedType instrumentedType)
Prepares a given instrumented type.
|
InvokeDynamic |
withArgument(int... index)
Passes parameters of the instrumented method to the bootstrapped method.
|
InvokeDynamic.WithImplicitType |
withArgument(int index)
Passes a parameter of the instrumented method to the bootstrapped method.
|
Implementation.Composable |
withAssigner(Assigner assigner,
Assigner.Typing typing)
Instructs this implementation to use the provided assigner and decides if the assigner should apply
dynamic typing.
|
InvokeDynamic |
withBooleanValue(boolean... value)
Requires the bootstrap method to bootstrap a method that takes the specified
boolean arguments
as its next parameters. |
InvokeDynamic |
withByteValue(byte... value)
Requires the bootstrap method to bootstrap a method that takes the specified
byte arguments
as its next parameters. |
InvokeDynamic |
withCharacterValue(char... value)
Requires the bootstrap method to bootstrap a method that takes the specified
char arguments
as its next parameters. |
InvokeDynamic |
withDoubleValue(double... value)
Requires the bootstrap method to bootstrap a method that takes the specified
double arguments
as its next parameters. |
InvokeDynamic |
withEnumeration(EnumerationDescription... enumerationDescription)
Hands the provided enumerations to the dynamically bound method.
|
InvokeDynamic |
withField(FieldLocator.Factory fieldLocatorFactory,
String... name)
Passes the values of the specified fields to the bootstrap method.
|
InvokeDynamic |
withField(String... name)
Passes the values of the specified fields to the bootstrap method.
|
InvokeDynamic.WithImplicitType |
withField(String name)
Passes the values of the specified fields to the bootstrap method.
|
InvokeDynamic.WithImplicitType |
withField(String name,
FieldLocator.Factory fieldLocatorFactory)
Passes the values of the specified fields to the bootstrap method.
|
InvokeDynamic |
withFloatValue(float... value)
Requires the bootstrap method to bootstrap a method that takes the specified
float arguments
as its next parameters. |
InvokeDynamic |
withImplicitAndMethodArguments()
Adds a potential
this reference and all method arguments to the the bootstrapped method. |
InvokeDynamic |
withInstance(ConstantValue... constant)
Hands the provided Java instance to the dynamically bound method.
|
InvokeDynamic |
withInstance(JavaConstant... constant)
Hands the provided Java instance to the dynamically bound method.
|
InvokeDynamic |
withIntegerValue(int... value)
Requires the bootstrap method to bootstrap a method that takes the specified
int arguments
as its next parameters. |
InvokeDynamic |
withLongValue(long... value)
Requires the bootstrap method to bootstrap a method that takes the specified
long arguments
as its next parameters. |
InvokeDynamic |
withMethodArguments()
Adds all method arguments to the the bootstrapped method.
|
InvokeDynamic |
withNullValue(Class<?>... type)
Passes
null values of the given types to the bootstrapped method. |
InvokeDynamic |
withNullValue(TypeDescription... typeDescription)
Passes
null values of the given types to the bootstrapped method. |
InvokeDynamic |
withReference(Object... value)
Requires the bootstrap method to bootstrap a method that takes the specified arguments as its next parameters.
|
InvokeDynamic.WithImplicitType |
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.
|
InvokeDynamic |
withShortValue(short... value)
Requires the bootstrap method to bootstrap a method that takes the specified
short arguments
as its next parameters. |
InvokeDynamic |
withThis(Class<?>... type)
Passes references to
this onto the operand stack where the instance is represented as
the given types. |
InvokeDynamic |
withThis(TypeDescription... typeDescription)
Passes references to
this onto the operand stack where the instance is represented as
the given types. |
InvokeDynamic |
withType(TypeDescription... typeDescription)
Hands the provided types to the dynamically bound method.
|
InvokeDynamic |
withValue(Object... value)
Requires the bootstrap method to bootstrap a method that takes the specified arguments as its next parameters.
|
protected final MethodDescription.InDefinedShape bootstrap
protected final List<? extends JavaConstant> arguments
protected final InvokeDynamic.InvocationProvider invocationProvider
protected final InvokeDynamic.TerminationHandler terminationHandler
protected final Assigner assigner
protected final Assigner.Typing typing
protected InvokeDynamic(MethodDescription.InDefinedShape bootstrap, List<? extends JavaConstant> arguments, InvokeDynamic.InvocationProvider invocationProvider, InvokeDynamic.TerminationHandler terminationHandler, Assigner assigner, Assigner.Typing typing)
bootstrap
- The bootstrap method.arguments
- The arguments that are provided to the bootstrap method.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.public static InvokeDynamic.WithImplicitTarget bootstrap(Method method, Object... constant)
method
- The bootstrap method that is used to link the instrumented method.constant
- The constant values passed to the bootstrap method. Values can be represented either
as TypeDescription
, as JavaConstant
, as String
or a primitive
int
, long
, float
or double
represented as wrapper type.this
reference, if available, and all arguments of the
instrumented method are passed to the bootstrapped method unless explicit parameters are specified.public static InvokeDynamic.WithImplicitTarget bootstrap(Method method, List<?> constants)
method
- The bootstrap method that is used to link the instrumented method.constants
- The constant values passed to the bootstrap method. Values can be represented either
as TypeDescription
, as JavaConstant
, as String
or a primitive
int
, long
, float
or double
represented as wrapper type.this
reference, if available, and all arguments of the
instrumented method are passed to the bootstrapped method unless explicit parameters are specified.public static InvokeDynamic.WithImplicitTarget bootstrap(Constructor<?> constructor, Object... constant)
constructor
- The bootstrap constructor that is used to link the instrumented method.constant
- The constant values passed to the bootstrap method. Values can be represented either
as TypeDescription
, as JavaConstant
, as String
or a primitive
int
, long
, float
or double
represented as wrapper type.this
reference, if available, and all arguments of the
instrumented method are passed to the bootstrapped method unless explicit parameters are specified.public static InvokeDynamic.WithImplicitTarget bootstrap(Constructor<?> constructor, List<?> constants)
constructor
- The bootstrap constructor that is used to link the instrumented method.constants
- The constant values passed to the bootstrap method. Values can be represented either
as TypeDescription
, as JavaConstant
, as String
or a primitive
int
, long
, float
or double
represented as wrapper type.this
reference, if available, and all arguments of the
instrumented method are passed to the bootstrapped method unless explicit parameters are specified.public static InvokeDynamic.WithImplicitTarget bootstrap(MethodDescription.InDefinedShape bootstrap, Object... constant)
bootstrap
- The bootstrap method or constructor that is used to link the instrumented method.constant
- The constant values passed to the bootstrap method. Values can be represented either
as TypeDescription
, as JavaConstant
, as String
or a primitive
int
, long
, float
or double
represented as wrapper type.this
reference, if available, and all arguments of the
instrumented method are passed to the bootstrapped method unless explicit parameters are specified.public static InvokeDynamic.WithImplicitTarget bootstrap(MethodDescription.InDefinedShape bootstrap, List<?> constants)
bootstrap
- The bootstrap method or constructor that is used to link the instrumented method.constants
- The constant values passed to the bootstrap method. Values can be represented either
as TypeDescription
, as JavaConstant
, as String
or a primitive
int
, long
, float
or double
represented as wrapper type.this
reference, if available, and all arguments of the
instrumented method are passed to the bootstrapped method unless explicit parameters are specified.public static InvokeDynamic.WithImplicitArguments lambda(Method method, Type functionalInterface)
Creates a lambda expression using the JVM's lambda meta factory. The method that is implementing the lambda expression is provided the explicit arguments first and the functional interface's method second.
Important: Byte Buddy does not validate that the provided arguments are correct considering the required arguments of the bound functional interface. Binding an incorrect number of arguments or arguments of incompatible types does not create illegal byte code but yields a runtime error when the call site is first used. This is done to support future extensions or alternative implementations of the Java virtual machine.
method
- The method that implements the lambda expression.functionalInterface
- The functional interface that is an instance of the lambda expression.public static InvokeDynamic.WithImplicitArguments lambda(Method method, Type functionalInterface, MethodGraph.Compiler methodGraphCompiler)
Creates a lambda expression using the JVM's lambda meta factory. The method that is implementing the lambda expression is provided the explicit arguments first and the functional interface's method second.
Important: Byte Buddy does not validate that the provided arguments are correct considering the required arguments of the bound functional interface. Binding an incorrect number of arguments or arguments of incompatible types does not create illegal byte code but yields a runtime error when the call site is first used. This is done to support future extensions or alternative implementations of the Java virtual machine.
method
- The method that implements the lambda expression.functionalInterface
- The functional interface that is an instance of the lambda expression.methodGraphCompiler
- The method graph compiler to use.public static InvokeDynamic.WithImplicitArguments lambda(MethodDescription.InDefinedShape methodDescription, TypeDefinition functionalInterface)
Creates a lambda expression using the JVM's lambda meta factory. The method that is implementing the lambda expression is provided the explicit arguments first and the functional interface's method second.
Important: Byte Buddy does not validate that the provided arguments are correct considering the required arguments of the bound functional interface. Binding an incorrect number of arguments or arguments of incompatible types does not create illegal byte code but yields a runtime error when the call site is first used. This is done to support future extensions or alternative implementations of the Java virtual machine.
methodDescription
- The method that implements the lambda expression.functionalInterface
- The functional interface that is an instance of the lambda expression.public static InvokeDynamic.WithImplicitArguments lambda(MethodDescription.InDefinedShape methodDescription, TypeDefinition functionalInterface, MethodGraph.Compiler methodGraphCompiler)
Creates a lambda expression using the JVM's lambda meta factory. The method that is implementing the lambda expression is provided the explicit arguments first and the functional interface's method second.
Important: Byte Buddy does not validate that the provided arguments are correct considering the required arguments of the bound functional interface. Binding an incorrect number of arguments or arguments of incompatible types does not create illegal byte code but yields a runtime error when the call site is first used. This is done to support future extensions or alternative implementations of the Java virtual machine.
methodDescription
- The method that implements the lambda expression.functionalInterface
- The functional interface that is an instance of the lambda expression.methodGraphCompiler
- The method graph compiler to use.public InvokeDynamic withBooleanValue(boolean... value)
boolean
arguments
as its next parameters.value
- The arguments to pass to the bootstrapped method.public InvokeDynamic withByteValue(byte... value)
byte
arguments
as its next parameters.value
- The arguments to pass to the bootstrapped method.public InvokeDynamic withShortValue(short... value)
short
arguments
as its next parameters.value
- The arguments to pass to the bootstrapped method.public InvokeDynamic withCharacterValue(char... value)
char
arguments
as its next parameters.value
- The arguments to pass to the bootstrapped method.public InvokeDynamic withIntegerValue(int... value)
int
arguments
as its next parameters.value
- The arguments to pass to the bootstrapped method.public InvokeDynamic withLongValue(long... value)
long
arguments
as its next parameters.value
- The arguments to pass to the bootstrapped method.public InvokeDynamic withFloatValue(float... value)
float
arguments
as its next parameters.value
- The arguments to pass to the bootstrapped method.public InvokeDynamic withDoubleValue(double... value)
double
arguments
as its next parameters.value
- The arguments to pass to the bootstrapped method.public InvokeDynamic withValue(Object... value)
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.
value
- The arguments to pass to the bootstrapped method.public InvokeDynamic.WithImplicitType 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.
value
- The arguments to pass to the bootstrapped method.public InvokeDynamic withReference(Object... value)
value
- The arguments to pass to the bootstrapped method.public InvokeDynamic withType(TypeDescription... typeDescription)
typeDescription
- The classes to provide to the bound method as an argument.public InvokeDynamic withEnumeration(EnumerationDescription... enumerationDescription)
enumerationDescription
- The enumeration values to provide to the bound method as an argument.public InvokeDynamic withInstance(ConstantValue... constant)
constant
- The constants to provide to the bound method as an argument.public InvokeDynamic withInstance(JavaConstant... constant)
constant
- The constants to provide to the bound method as an argument.public InvokeDynamic withNullValue(Class<?>... type)
null
values of the given types to the bootstrapped method.type
- The type that the null
values should represent.public InvokeDynamic withNullValue(TypeDescription... typeDescription)
null
values of the given types to the bootstrapped method.typeDescription
- The type that the null
values should represent.public InvokeDynamic withArgument(int... index)
index
- The indices of the parameters that should be passed to the bootstrapped method.public InvokeDynamic.WithImplicitType withArgument(int index)
index
- The index of the parameter that should be passed to the bootstrapped method.public InvokeDynamic withThis(Class<?>... type)
this
onto the operand stack where the instance is represented as
the given types.type
- The types as which the this
reference of the intercepted method should be masked.this
references are passed as the next arguments.public InvokeDynamic withThis(TypeDescription... typeDescription)
this
onto the operand stack where the instance is represented as
the given types.typeDescription
- The types as which the this
reference of the intercepted method should be masked.this
references are passed as the next arguments.public InvokeDynamic withMethodArguments()
public InvokeDynamic withImplicitAndMethodArguments()
this
reference and all method arguments to the the bootstrapped method.this
reference and all
parameters of the instrumented method added.public InvokeDynamic withField(String... name)
name
- The names of the fields to be passed to the bootstrapped method.public InvokeDynamic withField(FieldLocator.Factory fieldLocatorFactory, String... name)
fieldLocatorFactory
- The field locator factory to use.name
- The names of the fields to be passed to the bootstrapped method.public InvokeDynamic.WithImplicitType withField(String name)
name
- The names of the fields to be passed to the bootstrapped method.public InvokeDynamic.WithImplicitType withField(String name, FieldLocator.Factory fieldLocatorFactory)
fieldLocatorFactory
- The field locator factory to use.name
- The names of the fields to be passed to the bootstrapped method.public Implementation.Composable withAssigner(Assigner assigner, Assigner.Typing typing)
assigner
- The assigner to use.typing
- true
if the assigner should attempt dynamic typing.public Implementation andThen(Implementation implementation)
andThen
in interface Implementation.Composable
implementation
- The subsequent implementation.public Implementation.Composable andThen(Implementation.Composable implementation)
andThen
in interface Implementation.Composable
implementation
- The subsequent composable implementation.public InstrumentedType prepare(InstrumentedType instrumentedType)
prepare
in interface InstrumentedType.Prepareable
instrumentedType
- The instrumented type in its current form.public ByteCodeAppender appender(Implementation.Target implementationTarget)
appender
in interface Implementation
implementationTarget
- The target of the current implementation.InstrumentedType.Prepareable.prepare(InstrumentedType)
.Copyright © 2014–2025. All rights reserved.