Class CallSiteReference

java.lang.Object
com.ibm.wala.classLoader.ProgramCounter
com.ibm.wala.classLoader.CallSiteReference
All Implemented Interfaces:
ContextItem, BytecodeConstants
Direct Known Subclasses:
DynamicCallSiteReference

public abstract class CallSiteReference extends ProgramCounter implements BytecodeConstants, ContextItem
Simple object that represents a static call site (ie., an invoke instruction in the bytecode)

Note that the identity of a call site reference depends on two things: the program counter, and the containing IR. Thus, it suffices to define equals() and hashCode() from ProgramCounter, since this class does not maintain a pointer to the containing IR (or CGNode) anyway. If using a hashtable of CallSiteReference from different IRs, you probably want to use a wrapper which also holds a pointer to the governing CGNode.

  • Constructor Details

    • CallSiteReference

      protected CallSiteReference(int programCounter, MethodReference declaredTarget)
      Parameters:
      programCounter - Index into bytecode describing this instruction
      declaredTarget - The method target as declared at the call site
  • Method Details

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class ProgramCounter
    • equals

      public boolean equals(Object obj)
      Description copied from class: ProgramCounter
      A Program Counter value is enough to uniquely identify a call site reference within a method.

      Note: must use these objects with extreme care; this only works if you never mix ProgramLocations from different methods in the same collection.

      Overrides:
      equals in class ProgramCounter
    • make

      public static CallSiteReference make(int programCounter, MethodReference declaredTarget, IInvokeInstruction.IDispatch invocationCode)
      This factory method plays a little game to avoid storing the invocation code in the object; this saves a byte (probably actually a whole word) in each created object.

      TODO: Consider canonicalization?

    • getDeclaredTarget

      public MethodReference getDeclaredTarget()
      Return the Method that this call site calls. This represents the method declared in the invoke instruction only.
    • getInvocationCode

      public abstract IInvokeInstruction.IDispatch getInvocationCode()
      Return one of INVOKESPECIAL, INVOKESTATIC, INVOKEVIRTUAL, or INVOKEINTERFACE
    • toString

      public String toString()
      Overrides:
      toString in class ProgramCounter
    • getInvocationString

      protected String getInvocationString(IInvokeInstruction.IDispatch invocationCode)
    • getInvocationString

      public String getInvocationString()
    • isInterface

      public final boolean isInterface()
      Is this an invokeinterface call site?
    • isVirtual

      public final boolean isVirtual()
      Is this an invokevirtual call site?
    • isSpecial

      public final boolean isSpecial()
      Is this an invokespecial call site?
    • isStatic

      public boolean isStatic()
      Is this an invokestatic call site?
    • isFixed

      public boolean isFixed()
    • isDispatch

      public boolean isDispatch()