Package org.teavm.model
Class MethodReference
- java.lang.Object
-
- org.teavm.model.MethodReference
-
- All Implemented Interfaces:
java.io.Serializable
public class MethodReference extends java.lang.Object implements java.io.SerializableSpecifies a fully qualified name of a method, including its name, class name, parameter types and return value type. This class overloads
equalsandhashCodeso 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.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MethodReference(java.lang.Class<?> cls, java.lang.String name, java.lang.Class<?>... signature)MethodReference(java.lang.String className, java.lang.String name, ValueType... signature)Creates a new reference to a method.MethodReference(java.lang.String className, MethodDescriptor descriptor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)java.lang.StringgetClassName()MethodDescriptorgetDescriptor()java.lang.StringgetName()ValueType[]getParameterTypes()ValueTypegetReturnType()ValueType[]getSignature()inthashCode()intparameterCount()ValueTypeparameterType(int index)static MethodReferenceparse(java.lang.reflect.Method method)static MethodReferenceparse(java.lang.String string)static MethodReferenceparseIfPossible(java.lang.String string)java.lang.StringsignatureToString()java.lang.StringtoString()
-
-
-
Constructor Detail
-
MethodReference
public MethodReference(java.lang.String className, MethodDescriptor descriptor)
-
MethodReference
public MethodReference(java.lang.String className, java.lang.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"))- Parameters:
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.
-
MethodReference
public MethodReference(java.lang.Class<?> cls, java.lang.String name, java.lang.Class<?>... signature)
-
-
Method Detail
-
getClassName
public java.lang.String getClassName()
-
getDescriptor
public MethodDescriptor getDescriptor()
-
parameterCount
public int parameterCount()
-
parameterType
public ValueType parameterType(int index)
-
getParameterTypes
public ValueType[] getParameterTypes()
-
getSignature
public ValueType[] getSignature()
-
getReturnType
public ValueType getReturnType()
-
getName
public java.lang.String getName()
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
parse
public static MethodReference parse(java.lang.String string)
-
parseIfPossible
public static MethodReference parseIfPossible(java.lang.String string)
-
parse
public static MethodReference parse(java.lang.reflect.Method method)
-
signatureToString
public java.lang.String signatureToString()
-
-