public static class JavaConstant.MethodHandle extends Object implements JavaConstant
java.lang.invoke.MethodHandle
object. Note that constant MethodHandle
s cannot
be represented within the constant pool of a Java class and can therefore not be represented as an instance of
this representation order.Modifier and Type | Class and Description |
---|---|
protected static interface |
JavaConstant.MethodHandle.Dispatcher
A dispatcher for analyzing a
java.lang.invoke.MethodHandle instance. |
static class |
JavaConstant.MethodHandle.HandleType
A representation of a method handle's type.
|
JavaConstant.MethodHandle, JavaConstant.MethodType
Modifier | Constructor and Description |
---|---|
protected |
MethodHandle(JavaConstant.MethodHandle.HandleType handleType,
TypeDescription ownerType,
String name,
TypeDescription returnType,
List<? extends TypeDescription> parameterTypes)
Creates a method handle representation.
|
Modifier and Type | Method and Description |
---|---|
Object |
asConstantPoolValue()
Returns the represented instance as a constant pool value.
|
StackManipulation |
asStackManipulation()
Returns the instance as loadable onto the operand stack.
|
boolean |
equals(Object other) |
String |
getDescriptor()
Returns the method descriptor of this method handle representation.
|
JavaConstant.MethodHandle.HandleType |
getHandleType()
Returns the handle type represented by this instance.
|
String |
getName()
Returns the name represented by this instance.
|
TypeDescription |
getOwnerType()
Returns the owner type of this instance.
|
TypeList |
getParameterTypes()
Returns the parameter types represented by this instance.
|
TypeDescription |
getReturnType()
Returns the return type represented by this instance.
|
TypeDescription |
getType()
Returns a description of the type of the represented instance or at least a stub.
|
int |
hashCode() |
static Class<?> |
lookupType(Object callerClassLookup)
Returns the lookup type of the provided
java.lang.invoke.MethodHandles$Lookup instance. |
static JavaConstant.MethodHandle |
of(Constructor<?> constructor)
Creates a method handle representation of the given constructor.
|
static JavaConstant.MethodHandle |
of(Method method)
Creates a method handle representation of the given method.
|
static JavaConstant.MethodHandle |
of(MethodDescription.InDefinedShape methodDescription)
Creates a method handle representation of the given method.
|
static JavaConstant.MethodHandle |
ofGetter(Field field)
Returns a method handle for a setter of the given field.
|
static JavaConstant.MethodHandle |
ofGetter(FieldDescription.InDefinedShape fieldDescription)
Returns a method handle for a setter of the given field.
|
static JavaConstant.MethodHandle |
ofLoaded(Object methodHandle)
Creates a method handles representation of a loaded method handle which is analyzed using a public
MethodHandles.Lookup object. |
static JavaConstant.MethodHandle |
ofLoaded(Object methodHandle,
Object lookup)
Creates a method handles representation of a loaded method handle which is analyzed using the given lookup context.
|
static JavaConstant.MethodHandle |
ofSetter(Field field)
Returns a method handle for a getter of the given field.
|
static JavaConstant.MethodHandle |
ofSetter(FieldDescription.InDefinedShape fieldDescription)
Returns a method handle for a getter of the given field.
|
static JavaConstant.MethodHandle |
ofSpecial(Method method,
Class<?> type)
Creates a method handle representation of the given method for an explicit special method invocation of an otherwise virtual method.
|
static JavaConstant.MethodHandle |
ofSpecial(MethodDescription.InDefinedShape methodDescription,
TypeDescription typeDescription)
Creates a method handle representation of the given method for an explicit special method invocation of an otherwise virtual method.
|
String |
toString() |
protected MethodHandle(JavaConstant.MethodHandle.HandleType handleType, TypeDescription ownerType, String name, TypeDescription returnType, List<? extends TypeDescription> parameterTypes)
handleType
- The handle type that is represented by this instance.ownerType
- The owner type that is represented by this instance.name
- The name that is represented by this instance.returnType
- The return type that is represented by this instance.parameterTypes
- The parameter types that is represented by this instance.public static JavaConstant.MethodHandle ofLoaded(Object methodHandle)
MethodHandles.Lookup
object.
A method handle can only be analyzed on virtual machines that support the corresponding API (Java 7+). For virtual machines before Java 8+,
a method handle instance can only be analyzed by taking advantage of private APIs what might require a access context.methodHandle
- The loaded method handle to represent.public static JavaConstant.MethodHandle ofLoaded(Object methodHandle, Object lookup)
methodHandle
- The loaded method handle to represent.lookup
- The lookup object to use for analyzing the method handle.public static JavaConstant.MethodHandle of(Method method)
method
- The method ro represent.public static JavaConstant.MethodHandle of(Constructor<?> constructor)
constructor
- The constructor ro represent.public static JavaConstant.MethodHandle of(MethodDescription.InDefinedShape methodDescription)
methodDescription
- The method ro represent.public static JavaConstant.MethodHandle ofSpecial(Method method, Class<?> type)
method
- The method ro represent.type
- The type on which the method is to be invoked on as a special method invocation.public static JavaConstant.MethodHandle ofSpecial(MethodDescription.InDefinedShape methodDescription, TypeDescription typeDescription)
methodDescription
- The method ro represent.typeDescription
- The type on which the method is to be invoked on as a special method invocation.public static JavaConstant.MethodHandle ofGetter(Field field)
field
- The field to represent.public static JavaConstant.MethodHandle ofGetter(FieldDescription.InDefinedShape fieldDescription)
fieldDescription
- The field to represent.public static JavaConstant.MethodHandle ofSetter(Field field)
field
- The field to represent.public static JavaConstant.MethodHandle ofSetter(FieldDescription.InDefinedShape fieldDescription)
fieldDescription
- The field to represent.public Object asConstantPoolValue()
JavaConstant
asConstantPoolValue
in interface JavaConstant
public StackManipulation asStackManipulation()
JavaConstant
asStackManipulation
in interface JavaConstant
public TypeDescription getType()
JavaConstant
getType
in interface JavaConstant
public JavaConstant.MethodHandle.HandleType getHandleType()
public TypeDescription getOwnerType()
public String getName()
public TypeDescription getReturnType()
public TypeList getParameterTypes()
public String getDescriptor()
Copyright © 2014–2017. All rights reserved.