public static class JavaConstant.Dynamic extends Object implements JavaConstant
JavaConstant.Dynamic, JavaConstant.MethodHandle, JavaConstant.MethodType, JavaConstant.Simple
Modifier | Constructor and Description |
---|---|
protected |
Dynamic(org.objectweb.asm.ConstantDynamic value,
TypeDescription typeDescription)
Creates a new dynamic class pool entry.
|
Modifier and Type | Method and Description |
---|---|
Object |
asConstantPoolValue()
Returns the represented instance as a constant pool value.
|
static JavaConstant.Dynamic |
bootstrap(String name,
Constructor<?> constructor,
List<?> constants)
Binds the supplied bootstrap constructor for the resolution of a dynamic constant.
|
static JavaConstant.Dynamic |
bootstrap(String name,
Constructor<?> constructor,
Object... constant)
Binds the supplied bootstrap constructor for the resolution of a dynamic constant.
|
static JavaConstant.Dynamic |
bootstrap(String name,
MethodDescription.InDefinedShape bootstrap,
List<?> constants)
Binds the supplied bootstrap method or constructor for the resolution of a dynamic constant.
|
static JavaConstant.Dynamic |
bootstrap(String name,
MethodDescription.InDefinedShape bootstrapMethod,
Object... constant)
Binds the supplied bootstrap method or constructor for the resolution of a dynamic constant.
|
static JavaConstant.Dynamic |
bootstrap(String name,
Method method,
List<?> constants)
Binds the supplied bootstrap method for the resolution of a dynamic constant.
|
static JavaConstant.Dynamic |
bootstrap(String name,
Method method,
Object... constant)
Binds the supplied bootstrap method for the resolution of a dynamic constant.
|
boolean |
equals(Object other) |
TypeDescription |
getTypeDescription()
Returns a description of the type of the represented instance or at least a stub.
|
int |
hashCode() |
static JavaConstant |
ofArrayVarHandle(Class<?> type)
Resolves a var handle constant for an array.
|
static JavaConstant |
ofArrayVarHandle(TypeDescription typeDescription)
Resolves a var handle constant for an array.
|
static JavaConstant |
ofEnumeration(Enum<?> enumeration)
Returns a
Enum value constant. |
static JavaConstant |
ofEnumeration(EnumerationDescription enumerationDescription)
Returns a
Enum value constant. |
static JavaConstant.Dynamic |
ofField(Field field)
Returns a
static , final field constant. |
static JavaConstant.Dynamic |
ofField(FieldDescription.InDefinedShape fieldDescription)
Returns a
static , final field constant. |
static JavaConstant.Dynamic |
ofInvocation(Constructor<?> constructor,
List<?> constants)
Represents a constant that is resolved by invoking a constructor.
|
static JavaConstant.Dynamic |
ofInvocation(Constructor<?> constructor,
Object... constant)
Represents a constant that is resolved by invoking a constructor.
|
static JavaConstant.Dynamic |
ofInvocation(MethodDescription.InDefinedShape methodDescription,
List<?> constants)
Represents a constant that is resolved by invoking a
static factory method or a constructor. |
static JavaConstant.Dynamic |
ofInvocation(MethodDescription.InDefinedShape methodDescription,
Object... constant)
Represents a constant that is resolved by invoking a
static factory method or a constructor. |
static JavaConstant.Dynamic |
ofInvocation(Method method,
List<?> constants)
Represents a constant that is resolved by invoking a
static factory method. |
static JavaConstant.Dynamic |
ofInvocation(Method method,
Object... constant)
Represents a constant that is resolved by invoking a
static factory method. |
static JavaConstant.Dynamic |
ofNullConstant()
Returns a constant
null value of type Object . |
static JavaConstant |
ofPrimitiveType(Class<?> type)
Returns a
Class constant for a primitive type. |
static JavaConstant |
ofPrimitiveType(TypeDescription typeDescription)
Returns a
Class constant for a primitive type. |
static JavaConstant |
ofVarHandle(Field field)
Resolves a var handle constant for a field.
|
static JavaConstant |
ofVarHandle(FieldDescription.InDefinedShape fieldDescription)
Resolves a var handle constant for a field.
|
JavaConstant |
withType(Class<?> type)
Resolves this
JavaConstant.Dynamic constant to resolve the returned instance to the supplied type. |
JavaConstant |
withType(TypeDescription typeDescription)
Resolves this
JavaConstant.Dynamic constant to resolve the returned instance to the supplied type. |
protected Dynamic(org.objectweb.asm.ConstantDynamic value, TypeDescription typeDescription)
value
- The represented bootstrap value.typeDescription
- The represented value constant.public static JavaConstant.Dynamic ofNullConstant()
null
value of type Object
.public static JavaConstant ofPrimitiveType(Class<?> type)
Class
constant for a primitive type.type
- The primitive type to represent.public static JavaConstant ofPrimitiveType(TypeDescription typeDescription)
Class
constant for a primitive type.typeDescription
- The primitive type to represent.public static JavaConstant ofEnumeration(Enum<?> enumeration)
Enum
value constant.enumeration
- The enumeration value to represent.public static JavaConstant ofEnumeration(EnumerationDescription enumerationDescription)
Enum
value constant.enumerationDescription
- The enumeration value to represent.public static JavaConstant.Dynamic ofField(Field field)
static
, final
field constant.field
- The field to represent a value of.public static JavaConstant.Dynamic ofField(FieldDescription.InDefinedShape fieldDescription)
static
, final
field constant.fieldDescription
- The field to represent a value of.public static JavaConstant.Dynamic ofInvocation(Method method, Object... constant)
static
factory method.method
- The method to invoke to create the represented constant value.constant
- The method's constant arguments.public static JavaConstant.Dynamic ofInvocation(Method method, List<?> constants)
static
factory method.method
- The method to invoke to create the represented constant value.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.public static JavaConstant.Dynamic ofInvocation(Constructor<?> constructor, Object... constant)
constructor
- The constructor to invoke to create the represented constant value.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.public static JavaConstant.Dynamic ofInvocation(Constructor<?> constructor, List<?> constants)
constructor
- The constructor to invoke to create the represented constant value.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.public static JavaConstant.Dynamic ofInvocation(MethodDescription.InDefinedShape methodDescription, Object... constant)
static
factory method or a constructor.methodDescription
- The method or constructor to invoke to create the represented constant value.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.public static JavaConstant.Dynamic ofInvocation(MethodDescription.InDefinedShape methodDescription, List<?> constants)
static
factory method or a constructor.methodDescription
- The method or constructor to invoke to create the represented constant value.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.public static JavaConstant ofVarHandle(Field field)
field
- The field to represent a var handle for.public static JavaConstant ofVarHandle(FieldDescription.InDefinedShape fieldDescription)
fieldDescription
- The field to represent a var handle for.public static JavaConstant ofArrayVarHandle(Class<?> type)
type
- The array type for which the var handle is resolved.public static JavaConstant ofArrayVarHandle(TypeDescription typeDescription)
typeDescription
- The array type for which the var handle is resolved.public static JavaConstant.Dynamic bootstrap(String name, Method method, Object... constant)
name
- The name of the bootstrap constant that is provided to the bootstrap method or constructor.method
- The bootstrap method to invoke.constant
- The arguments for the bootstrap method represented as primitive wrapper types,
String
, TypeDescription
or JavaConstant
values or their loaded forms.public static JavaConstant.Dynamic bootstrap(String name, Method method, List<?> constants)
name
- The name of the bootstrap constant that is provided to the bootstrap method or constructor.method
- The bootstrap method to invoke.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.public static JavaConstant.Dynamic bootstrap(String name, Constructor<?> constructor, Object... constant)
name
- The name of the bootstrap constant that is provided to the bootstrap method or constructor.constructor
- The bootstrap constructor to invoke.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.public static JavaConstant.Dynamic bootstrap(String name, Constructor<?> constructor, List<?> constants)
name
- The name of the bootstrap constant that is provided to the bootstrap method or constructor.constructor
- The bootstrap constructor to invoke.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.public static JavaConstant.Dynamic bootstrap(String name, MethodDescription.InDefinedShape bootstrapMethod, Object... constant)
name
- The name of the bootstrap constant that is provided to the bootstrap method or constructor.bootstrapMethod
- The bootstrap method or constructor to invoke.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.public static JavaConstant.Dynamic bootstrap(String name, MethodDescription.InDefinedShape bootstrap, List<?> constants)
name
- The name of the bootstrap constant that is provided to the bootstrap method or constructor.bootstrap
- The bootstrap method or constructor to invoke.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.public JavaConstant withType(Class<?> type)
JavaConstant.Dynamic
constant to resolve the returned instance to the supplied type. The type must be a subtype of the
bootstrap method's return type. Constructors cannot be resolved to a different type.type
- The type to resolve the bootstrapped value to.public JavaConstant withType(TypeDescription typeDescription)
JavaConstant.Dynamic
constant to resolve the returned instance to the supplied type. The type must be a subtype of the
bootstrap method's return type. Constructors cannot be resolved to a different type.typeDescription
- The type to resolve the bootstrapped value to.public Object asConstantPoolValue()
asConstantPoolValue
in interface JavaConstant
public TypeDescription getTypeDescription()
getTypeDescription
in interface JavaConstant
Copyright © 2014–2021. All rights reserved.