public class InvokeDynamic extends Object implements Implementation
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 interface |
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.WithImplicitArgumentType
An invoke dynamic implementation where the last argument is an implicitly typed method argument.
|
static class |
InvokeDynamic.WithImplicitFieldType
A step in the invoke dynamic domain specific language that allows to explicitly specify a field type for a reference value.
|
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. |
Implementation.Compound, Implementation.Context, Implementation.Simple, Implementation.SpecialMethodInvocation, Implementation.Target
Modifier and Type | Field and Description |
---|---|
protected Assigner |
assigner
The assigner to be used.
|
protected MethodDescription.InDefinedShape |
bootstrapMethod
The bootstrap method.
|
protected List<?> |
handleArguments
The arguments that are provided to 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 bootstrapMethod,
List<?> handleArguments,
InvokeDynamic.InvocationProvider invocationProvider,
InvokeDynamic.TerminationHandler terminationHandler,
Assigner assigner,
Assigner.Typing typing)
Creates a new invoke dynamic implementation.
|
Modifier and Type | Method and Description |
---|---|
Implementation |
andThen(Implementation implementation)
Applies this invoke dynamic implementation and removes the return value of the bootstrapped method from
the operand stack before applying the provided 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<?> rawArguments)
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... rawArgument)
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 bootstrapMethod,
List<?> rawArguments)
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 bootstrapMethod,
Object... rawArgument)
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<?> rawArguments)
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... rawArgument)
Implements the instrumented method with a dynamic method invocation which is linked at runtime using the
specified bootstrap method.
|
boolean |
equals(Object other) |
protected InvokeDynamic.InvocationProvider |
getInvocationProvider()
Returns the invocation provider to be used for equals and hash code calculations.
|
int |
hashCode() |
InstrumentedType |
prepare(InstrumentedType instrumentedType)
During the preparation phase of an implementation, implementations are eligible to adding fields or methods
to the currently instrumented type.
|
String |
toString() |
InvokeDynamic |
withArgument(int... index)
Passes parameters of the instrumented method to the bootstrapped method.
|
InvokeDynamic.WithImplicitArgumentType |
withArgument(int index)
Passes a parameter of the instrumented method to the bootstrapped method.
|
InvokeDynamic |
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(String... fieldName)
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(JavaInstance... javaInstance)
Hands the provided Java instance to the dynamically bound method.
|
InvokeDynamic |
withInstanceField(String fieldName,
Class<?> fieldType)
Passes the value of the specified instance field to the bootstrapped method.
|
InvokeDynamic |
withInstanceField(String fieldName,
TypeDescription fieldType)
Passes the value of the specified instance field to the bootstrapped 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.WithImplicitFieldType |
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 bootstrapMethod
protected final List<?> handleArguments
protected final InvokeDynamic.InvocationProvider invocationProvider
protected final InvokeDynamic.TerminationHandler terminationHandler
protected final Assigner assigner
protected final Assigner.Typing typing
protected InvokeDynamic(MethodDescription.InDefinedShape bootstrapMethod, List<?> handleArguments, InvokeDynamic.InvocationProvider invocationProvider, InvokeDynamic.TerminationHandler terminationHandler, Assigner assigner, Assigner.Typing typing)
bootstrapMethod
- The bootstrap method.handleArguments
- 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... rawArgument)
method
- The bootstrap method that is used to link the instrumented method.rawArgument
- The arguments that are handed to the bootstrap method. Any argument must be saved in the
constant pool, i.e. primitive types (represented as their wrapper types) with a size of
at least 32 bit, String
types, Class
types as well
as MethodType
and MethodHandle
instances. In order to avoid class loading,
it is also possible to supply unloaded types as TypeDescription
,
JavaInstance.MethodHandle
or
JavaInstance.MethodType
instances.
instrumented method are passed to the bootstrapped method unless explicit parameters are specified.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<?> rawArguments)
method
- The bootstrap method that is used to link the instrumented method.rawArguments
- The arguments that are handed to the bootstrap method. Any argument must be saved in the
constant pool, i.e. primitive types (represented as their wrapper types) with a size of
at least 32 bit, String
types, Class
types as well
as MethodType
and MethodHandle
instances. In order to avoid class loading,
it is also possible to supply unloaded types as TypeDescription
,
JavaInstance.MethodHandle
or
JavaInstance.MethodType
instances.
instrumented method are passed to the bootstrapped method unless explicit parameters are specified.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... rawArgument)
constructor
- The bootstrap constructor that is used to link the instrumented method.rawArgument
- The arguments that are handed to the bootstrap method. Any argument must be saved in the
constant pool, i.e. primitive types (represented as their wrapper types) with a size of
at least 32 bit, String
types, Class
types as well
as MethodType
and MethodHandle
instances. In order to avoid class loading,
it is also possible to supply unloaded types as TypeDescription
,
JavaInstance.MethodHandle
or
JavaInstance.MethodType
instances.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<?> rawArguments)
constructor
- The bootstrap constructor that is used to link the instrumented method.rawArguments
- The arguments that are handed to the bootstrap method. Any argument must be saved in the
constant pool, i.e. primitive types (represented as their wrapper types) with a size of
at least 32 bit, String
types, Class
types as well
as MethodType
and MethodHandle
instances. In order to avoid class loading,
it is also possible to supply unloaded types as TypeDescription
,
JavaInstance.MethodHandle
or
JavaInstance.MethodType
instances.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 bootstrapMethod, Object... rawArgument)
bootstrapMethod
- The bootstrap method or constructor that is used to link the instrumented method.rawArgument
- The arguments that are handed to the bootstrap method. Any argument must be saved in the
constant pool, i.e. primitive types (represented as their wrapper types) with a size of
at least 32 bit, String
types, Class
types as well
as MethodType
and MethodHandle
instances. In order to avoid class loading,
it is also possible to supply unloaded types as TypeDescription
,
JavaInstance.MethodHandle
or
JavaInstance.MethodType
instances.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 bootstrapMethod, List<?> rawArguments)
bootstrapMethod
- The bootstrap method or constructor that is used to link the instrumented method.rawArguments
- The arguments that are handed to the bootstrap method. Any argument must be saved in the
constant pool, i.e. primitive types (represented as their wrapper types) with a size of
at least 32 bit, String
types, Class
types as well
as MethodType
and MethodHandle
instances. In order to avoid class loading,
it is also possible to supply unloaded types as TypeDescription
,
JavaInstance.MethodHandle
or
JavaInstance.MethodType
instances.this
reference, if available, and all arguments of the
instrumented method are passed to the bootstrapped method unless explicit parameters are specified.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.WithImplicitFieldType 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(JavaInstance... javaInstance)
javaInstance
- The Java instance 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.WithImplicitArgumentType 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 withInstanceField(String fieldName, Class<?> fieldType)
fieldName
- The name of the field.fieldType
- The type of the field.public InvokeDynamic withInstanceField(String fieldName, TypeDescription fieldType)
fieldName
- The name of the field.fieldType
- The type of the field.public InvokeDynamic withField(String... fieldName)
fieldName
- The names of the fields to be passed to the bootstrapped method.public InvokeDynamic 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)
implementation
- The implementation to apply after executing the dynamic method invocation.public InstrumentedType prepare(InstrumentedType instrumentedType)
Implementation
ByteCodeAppender
that is emitted
on the call to
Implementation.appender(Implementation.Target)
call. On this method call, loaded type initializers can also be added to the instrumented type.prepare
in interface Implementation
instrumentedType
- The instrumented type that is the basis of the ongoing instrumentation.public ByteCodeAppender appender(Implementation.Target implementationTarget)
Implementation
appender
in interface Implementation
implementationTarget
- The target of the current implementation.Implementation.prepare(InstrumentedType)
.protected InvokeDynamic.InvocationProvider getInvocationProvider()
Copyright © 2014–2015. All rights reserved.