public class MethodReference extends Object
Specifies a fully qualified name of a method, including its name, class name, parameter types
and return value type. This class overloads equals and hashCode
so that any two references to one method are considered equal.
Though in Java language it is enough to have only parameter types to uniquely identify a method, JVM uses return value as well. Java generates bridge methods to make adjust the JVM's behavior.
| Constructor and Description |
|---|
MethodReference(Class<?> cls,
String name,
Class<?>... signature) |
MethodReference(String className,
MethodDescriptor descriptor) |
MethodReference(String className,
String name,
ValueType... signature)
Creates a new reference to a method.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
String |
getClassName() |
MethodDescriptor |
getDescriptor() |
String |
getName() |
ValueType[] |
getParameterTypes() |
ValueType |
getReturnType() |
ValueType[] |
getSignature() |
int |
hashCode() |
int |
parameterCount() |
ValueType |
parameterType(int index) |
static MethodReference |
parse(String string) |
String |
signatureToString() |
String |
toString() |
public MethodReference(String className, MethodDescriptor descriptor)
public MethodReference(String className, String name, ValueType... signature)
Creates a new reference to a method.
For example, here is how you should call this constructor to create a reference to
the Integer.valueOf(int) method:
new MethodReference("java.lang.Integer", "valueOf",
ValueType.INT, ValueType.object("java.lang.Integer"))
className - the name of the class that owns the method.name - the name of the method.signature - descriptor of a method, as described in VM spec. The last element is
a type of a returning value, and all the remaining elements are types of arguments.public String getClassName()
public MethodDescriptor getDescriptor()
public int parameterCount()
public ValueType parameterType(int index)
public ValueType[] getParameterTypes()
public ValueType[] getSignature()
public ValueType getReturnType()
public String getName()
public static MethodReference parse(String string)
public String signatureToString()
Copyright © 2015. All rights reserved.