org.jikesrvm.classloader
Class MethodReference

java.lang.Object
  extended by org.jikesrvm.classloader.MemberReference
      extended by org.jikesrvm.classloader.MethodReference

public final class MethodReference
extends MemberReference

A class to represent the reference in a class file to a method of that class or interface.


Field Summary
private  TypeReference[] parameterTypes
          types of parameters (not including "this", if virtual)
private  RVMMethod resolvedMember
          The RVMMethod that this method reference resolved to (null if not yet resolved).
private  TypeReference returnType
          type of return value
 
Fields inherited from class org.jikesrvm.classloader.MemberReference
descriptor, id, name, type
 
Constructor Summary
MethodReference(TypeReference tr, Atom mn, Atom d, int id)
           
 
Method Summary
 boolean definitelyDifferent(MethodReference that)
          Do this and that definitely refer to the different methods?
 boolean definitelySame(MethodReference that)
          Do this and that definitely refer to the same method?
static MethodReference findOrCreate(TypeReference tRef, Atom mn, Atom md)
          Find or create a method reference
 TypeReference[] getParameterTypes()
           
 int getParameterWords()
          Space required by method for its parameters, in words.
 RVMMethod getResolvedMember()
          Get the member this reference has been resolved to, if it has already been resolved.
 TypeReference getReturnType()
           
 boolean isMagic()
          Is the method reference to a magic method?
 boolean isMiranda()
          Return true iff this member reference refers to a method which is declared as part of an abstract class but actually is an interface method, known formally as a "miranda method".
 boolean isResolved()
          Has the method reference already been resolved into a target method?
 boolean isSpecializedInvoke()
          Is the method reference to a specialized invoke?
 boolean isSysCall()
          Is the method reference to a magic method?
 RVMMethod peekInterfaceMethod()
          Find the RVMMethod that this member reference refers to using the search order specified in JVM spec 5.4.3.4.
 RVMMethod peekResolvedMethod()
          Find the RVMMethod that this method reference refers to using the search order specified in JVM spec 5.4.3.3.
 RVMMethod resolve()
          Find the RVMMethod that this field reference refers to using the search order specified in JVM specification 5.4.3.3.
 RVMMethod resolveInterfaceMethod()
          Find the RVMMethod that this member reference refers to using the search order specified in JVM spec 5.4.3.4.
private  RVMMethod resolveInterfaceMethodInternal(RVMClass declaringClass)
          Find the RVMMethod that this member reference refers to using the search order specified in JVM spec 5.4.3.4.
private  RVMMethod resolveInternal(RVMClass declaringClass)
          Find the RVMMethod that this member reference refers to using the search order specified in JVM spec 5.4.3.3.
 RVMMethod resolveInvokeSpecial()
          Resolve the method reference for an invoke special into a target method, if that is possible without causing classloading.
private  RVMMethod searchInterfaceMethods(RVMClass c)
           
(package private)  void setResolvedMember(RVMMethod it)
          For use by RVMMethod constructor
 
Methods inherited from class org.jikesrvm.classloader.MemberReference
asFieldReference, asMethodReference, equals, getDescriptor, getId, getMemberRef, getName, getNextId, getType, hashCode, isFieldReference, isMethodReference, needsDynamicLink, parse, parse, peekResolvedMember, resolveMember, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

returnType

private final TypeReference returnType
type of return value


parameterTypes

private final TypeReference[] parameterTypes
types of parameters (not including "this", if virtual)


resolvedMember

private RVMMethod resolvedMember
The RVMMethod that this method reference resolved to (null if not yet resolved).

Constructor Detail

MethodReference

MethodReference(TypeReference tr,
                Atom mn,
                Atom d,
                int id)
Parameters:
tr - a type reference to the defining class in which this method appears. (e.g., "Ljava/lang/String;")
mn - the name of this method (e.g., "equals")
d - the method descriptor (e.g., "(Ljava/lang/Object;)Z")
id - the new ID of the member were a new member required
Method Detail

findOrCreate

public static MethodReference findOrCreate(TypeReference tRef,
                                           Atom mn,
                                           Atom md)
Find or create a method reference

See Also:
MemberReference.findOrCreate(TypeReference, Atom, Atom)

getReturnType

public TypeReference getReturnType()
Returns:
return type of the method

getParameterTypes

public TypeReference[] getParameterTypes()
Returns:
parameter types of the method

getParameterWords

public int getParameterWords()
Space required by method for its parameters, in words. Note: does *not* include implicit "this" parameter, if any.


definitelyDifferent

public boolean definitelyDifferent(MethodReference that)
Do this and that definitely refer to the different methods?


definitelySame

public boolean definitelySame(MethodReference that)
Do this and that definitely refer to the same method?


isResolved

public boolean isResolved()
Has the method reference already been resolved into a target method?


getResolvedMember

public RVMMethod getResolvedMember()
Get the member this reference has been resolved to, if it has already been resolved. Does NOT force resolution.


setResolvedMember

void setResolvedMember(RVMMethod it)
For use by RVMMethod constructor


resolveInvokeSpecial

public RVMMethod resolveInvokeSpecial()
Resolve the method reference for an invoke special into a target method, if that is possible without causing classloading.

Returns:
target method or null if the method cannot be resolved without classloading.

peekResolvedMethod

public RVMMethod peekResolvedMethod()
Find the RVMMethod that this method reference refers to using the search order specified in JVM spec 5.4.3.3.

Returns:
the RVMMethod that this method ref resolved to or null if it cannot be resolved.

resolve

public RVMMethod resolve()
Find the RVMMethod that this field reference refers to using the search order specified in JVM specification 5.4.3.3.

Returns:
the RVMMethod that this method reference resolved to.

isMiranda

public boolean isMiranda()
Return true iff this member reference refers to a method which is declared as part of an abstract class but actually is an interface method, known formally as a "miranda method".

This method is necessary to handle the special case where an invokevirtual is defined on an abstract class, where the method invocation points to a method inherited from an interface.

Returns:
boolean true iff this member method reference is a miranda method

isMagic

public boolean isMagic()
Is the method reference to a magic method? NB. In the case of SysCall annotated methods we don't know until they are resolved.


isSpecializedInvoke

public boolean isSpecializedInvoke()
Is the method reference to a specialized invoke? NB. we don't know until they are resolved.


isSysCall

public boolean isSysCall()
Is the method reference to a magic method? NB. In the case of SysCall annotated methods we don't know until they are resolved.


resolveInternal

private RVMMethod resolveInternal(RVMClass declaringClass)
Find the RVMMethod that this member reference refers to using the search order specified in JVM spec 5.4.3.3.

Returns:
the RVMMethod that this method ref resolved to.

peekInterfaceMethod

public RVMMethod peekInterfaceMethod()
Find the RVMMethod that this member reference refers to using the search order specified in JVM spec 5.4.3.4.

Returns:
the RVMMethod that this method ref resolved to or null if it cannot be resolved without trigering class loading

resolveInterfaceMethod

public RVMMethod resolveInterfaceMethod()
                                 throws IncompatibleClassChangeError,
                                        NoSuchMethodError
Find the RVMMethod that this member reference refers to using the search order specified in JVM spec 5.4.3.4.

Returns:
the RVMMethod that this method ref resolved to
Throws:
IncompatibleClassChangeError
NoSuchMethodError

resolveInterfaceMethodInternal

private RVMMethod resolveInterfaceMethodInternal(RVMClass declaringClass)
Find the RVMMethod that this member reference refers to using the search order specified in JVM spec 5.4.3.4.

Returns:
the RVMMethod that this method ref resolved to or null for error

searchInterfaceMethods

private RVMMethod searchInterfaceMethods(RVMClass c)