public static class JavaInstance.MethodHandle extends Object implements JavaInstance
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 |
JavaInstance.MethodHandle.Dispatcher
A dispatcher for analyzing a
java.lang.invoke.MethodHandle instance. |
static class |
JavaInstance.MethodHandle.HandleType
A representation of a method handle's type.
|
JavaInstance.MethodHandle, JavaInstance.MethodType
Modifier | Constructor and Description |
---|---|
protected |
MethodHandle(JavaInstance.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) |
JavaInstance.MethodHandle.HandleType |
getHandleType()
Returns the handle type represented by this instance.
|
TypeDescription |
getInstanceType()
Returns a description of the type of the represented instance or at least a stub.
|
String |
getName()
Returns the name represented by this instance.
|
TypeDescription |
getOwnerType()
Returns the owner type of this instance.
|
List<TypeDescription> |
getParameterTypes()
Returns the parameter types represented by this instance.
|
TypeDescription |
getReturnType()
Returns the return type represented by this instance.
|
int |
hashCode() |
static JavaInstance.MethodHandle |
of(Constructor<?> constructor)
Creates a method handle representation of the given constructor.
|
static JavaInstance.MethodHandle |
of(Method method)
Creates a method handle representation of the given method.
|
static JavaInstance.MethodHandle |
of(MethodDescription methodDescription)
Creates a method handle representation of the given method.
|
static JavaInstance.MethodHandle |
of(Object methodHandle)
Creates a method handles representation of a loaded method handle which is analyzed using a public
MethodHandles.Lookup object. |
static JavaInstance.MethodHandle |
of(Object methodHandle,
AccessControlContext accessControlContext)
Creates a method handles representation of a loaded method handle which is analyzed using a public
MethodHandles.Lookup object. |
static JavaInstance.MethodHandle |
of(Object methodHandle,
Object lookup)
Creates a method handles representation of a loaded method handle which is analyzed using the given lookup context.
|
static JavaInstance.MethodHandle |
of(Object methodHandle,
Object lookup,
AccessControlContext accessControlContext)
Creates a method handles representation of a loaded method handle which is analyzed using the given lookup context.
|
static JavaInstance.MethodHandle |
ofGetter(Field field)
Returns a method handle for a setter of the given field.
|
static JavaInstance.MethodHandle |
ofGetter(FieldDescription fieldDescription)
Returns a method handle for a setter of the given field.
|
static JavaInstance.MethodHandle |
ofSetter(Field field)
Returns a method handle for a getter of the given field.
|
static JavaInstance.MethodHandle |
ofSetter(FieldDescription fieldDescription)
Returns a method handle for a getter of the given field.
|
static JavaInstance.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 JavaInstance.MethodHandle |
ofSpecial(MethodDescription 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(JavaInstance.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 JavaInstance.MethodHandle of(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 JavaInstance.MethodHandle of(Object methodHandle, Object lookup)
methodHandle
- The loaded method handle to represent.lookup
- The lookup object to use for analyzing the method handle.public static JavaInstance.MethodHandle of(Object methodHandle, AccessControlContext accessControlContext)
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.accessControlContext
- The access control context to be used for making private methods accessible when using Java 7.public static JavaInstance.MethodHandle of(Object methodHandle, Object lookup, AccessControlContext accessControlContext)
methodHandle
- The loaded method handle to represent.lookup
- The lookup object to use for analyzing the method handle.accessControlContext
- The access control context to be used for making private methods accessible when using Java 7.public static JavaInstance.MethodHandle of(Method method)
method
- The method ro represent.public static JavaInstance.MethodHandle of(Constructor<?> constructor)
constructor
- The constructor ro represent.public static JavaInstance.MethodHandle of(MethodDescription methodDescription)
methodDescription
- The method ro represent.public static JavaInstance.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 JavaInstance.MethodHandle ofSpecial(MethodDescription 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 JavaInstance.MethodHandle ofGetter(Field field)
field
- The field to represent.public static JavaInstance.MethodHandle ofGetter(FieldDescription fieldDescription)
fieldDescription
- The field to represent.public static JavaInstance.MethodHandle ofSetter(Field field)
field
- The field to represent.public static JavaInstance.MethodHandle ofSetter(FieldDescription fieldDescription)
fieldDescription
- The field to represent.public Object asConstantPoolValue()
JavaInstance
asConstantPoolValue
in interface JavaInstance
public StackManipulation asStackManipulation()
JavaInstance
asStackManipulation
in interface JavaInstance
public TypeDescription getInstanceType()
JavaInstance
getInstanceType
in interface JavaInstance
public JavaInstance.MethodHandle.HandleType getHandleType()
public TypeDescription getOwnerType()
public String getName()
public TypeDescription getReturnType()
public List<TypeDescription> getParameterTypes()
Copyright © 2014–2015. All rights reserved.