org.jikesrvm.classloader
Class MemberReference

java.lang.Object
  extended by org.jikesrvm.classloader.MemberReference
Direct Known Subclasses:
FieldReference, MethodReference

public abstract class MemberReference
extends Object

A class to represent the reference in a class file to some member (field or method). A member reference is uniquely defined by

Resolving a MemberReference to a RVMMember can be an expensive operation. Therefore we canonicalize MemberReference instances and cache the result of resolution.


Field Summary
protected  Atom descriptor
          The descriptor
private static ImmutableEntryHashSetRVM<MemberReference> dictionary
          Used to canonicalize memberReferences
protected  int id
          Unique id for the member reference (ignored in .equals comparison)
private static int LOG_ROW_SIZE
          2^LOG_ROW_SIZE is the number of elements per row
private static MemberReference[][] members
          Dictionary of all MemberReference instances.
protected  Atom name
          The member name
private static int nextId
          Used to assign ids.
private static int ROW_MASK
          Mask to ascertain row from id number
protected  TypeReference type
          The type reference
 
Constructor Summary
protected MemberReference(TypeReference tRef, Atom mn, Atom d, int id)
           
 
Method Summary
 FieldReference asFieldReference()
           
 MethodReference asMethodReference()
           
 boolean equals(Object other)
           
static MemberReference findOrCreate(TypeReference tRef, Atom mn, Atom md)
          Find or create the canonical MemberReference instance for the given tuple.
 Atom getDescriptor()
           
 int getId()
           
static MemberReference getMemberRef(int id)
           
 Atom getName()
           
static int getNextId()
           
 TypeReference getType()
           
 int hashCode()
           
 boolean isFieldReference()
          Is this member reference to a field?
 boolean isMethodReference()
          Is this member reference to a method?
 boolean needsDynamicLink(RVMMethod that)
          Is dynamic linking code required to access "this" member when referenced from "that" method?
static MemberReference parse(StringTokenizer parser)
          Given a StringTokenizer currently pointing to the start of a MemberReference (created by doing a toString() on a MemberReference), parse it and find/create the appropriate MemberReference.
static MemberReference parse(StringTokenizer parser, boolean boot)
           
 RVMMember peekResolvedMember()
           
 RVMMember resolveMember()
          Force resolution and return the resolved member.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

dictionary

private static final ImmutableEntryHashSetRVM<MemberReference> dictionary
Used to canonicalize memberReferences


LOG_ROW_SIZE

private static final int LOG_ROW_SIZE
2^LOG_ROW_SIZE is the number of elements per row

See Also:
Constant Field Values

ROW_MASK

private static final int ROW_MASK
Mask to ascertain row from id number

See Also:
Constant Field Values

members

private static MemberReference[][] members
Dictionary of all MemberReference instances.


nextId

private static int nextId
Used to assign ids. Id 0 is not used to support usage of member reference id's in JNI.


id

protected final int id
Unique id for the member reference (ignored in .equals comparison)


type

protected final TypeReference type
The type reference


name

protected final Atom name
The member name


descriptor

protected final Atom descriptor
The descriptor

Constructor Detail

MemberReference

protected MemberReference(TypeReference tRef,
                          Atom mn,
                          Atom d,
                          int id)
Parameters:
tRef - the type reference
mn - the field or method name
d - the field or method descriptor
id - the new ID of the member were a new member required (ignored in .equals test)
Method Detail

findOrCreate

public static MemberReference findOrCreate(TypeReference tRef,
                                           Atom mn,
                                           Atom md)
Find or create the canonical MemberReference instance for the given tuple.

Parameters:
tRef - the type reference
mn - the name of the member
md - the descriptor of the member

parse

public static MemberReference parse(StringTokenizer parser)
Given a StringTokenizer currently pointing to the start of a MemberReference (created by doing a toString() on a MemberReference), parse it and find/create the appropriate MemberReference. Consumes all of the tokens corresponding to the member reference.


parse

public static MemberReference parse(StringTokenizer parser,
                                    boolean boot)

getNextId

public static int getNextId()

getMemberRef

public static MemberReference getMemberRef(int id)

getType

public final TypeReference getType()
Returns:
the type reference component of this member reference

getName

public final Atom getName()
Returns:
the member name component of this member reference

getDescriptor

public final Atom getDescriptor()
Returns:
the descriptor component of this member reference

getId

public final int getId()
Returns:
the dynamic linking id to use for this member.

isFieldReference

public final boolean isFieldReference()
Is this member reference to a field?


isMethodReference

public final boolean isMethodReference()
Is this member reference to a method?


asFieldReference

public final FieldReference asFieldReference()
Returns:
this cast to a FieldReference

asMethodReference

public final MethodReference asMethodReference()
Returns:
this cast to a MethodReference

peekResolvedMember

public final RVMMember peekResolvedMember()
Returns:
the RVMMember this reference resolves to if it is already known or null if it cannot be resolved without risking class loading.

resolveMember

public final RVMMember resolveMember()
Force resolution and return the resolved member. Will cause classloading if necessary


needsDynamicLink

public final boolean needsDynamicLink(RVMMethod that)
Is dynamic linking code required to access "this" member when referenced from "that" method?


hashCode

public final int hashCode()
Overrides:
hashCode in class Object

equals

public final boolean equals(Object other)
Overrides:
equals in class Object

toString

public final String toString()
Overrides:
toString in class Object