Class MethodReference

java.lang.Object
org.teavm.model.MethodReference
All Implemented Interfaces:
Serializable

public class MethodReference extends Object implements Serializable

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.

See Also:
  • Constructor Details

    • MethodReference

      public MethodReference(String className, MethodDescriptor descriptor)
    • MethodReference

      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"))
       
      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(Class<?> cls, String name, Class<?>... signature)
  • Method Details