Package com.ibm.wala.shrike.shrikeBT
Class MethodData
- java.lang.Object
-
- com.ibm.wala.shrike.shrikeBT.MethodData
-
public final class MethodData extends java.lang.ObjectThis class is a container for a bunch of information that we might know about a method. It's here for convenience so users can just pass one MethodData around instead of passing around an array of instructions, an array of exception handler lists, etc.It also provides a place to hang annotations. We provide a table mapping abstract "keys" to annotation objects. We also provide an invalidation protocol so that the annotation objects can be notified of code changes and react appropriately. This is useful for caching analysis results for a method.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceMethodData.ResultsAnnotation objects implement this Results interface.
-
Constructor Summary
Constructors Constructor Description MethodData(int access, java.lang.String classType, java.lang.String name, java.lang.String signature, IInstruction[] instructions, ExceptionHandler[][] handlers, int[] instructionsToBytecodes)Gather the information for a method "from scratch".MethodData(Decoder d, int access, java.lang.String classType, java.lang.String name, java.lang.String signature)Gather the information for a method after it has been decoded.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetAccess()java.lang.StringgetClassType()ExceptionHandler[][]getHandlers()booleangetHasChanged()MethodData.ResultsgetInfo(java.lang.Object key)Get the annotation for the given key.IInstruction[]getInstructions()int[]getInstructionsToBytecodes()booleangetIsStatic()booleangetIsSynchronized()java.lang.StringgetName()java.lang.StringgetSignature()static MethodDatamakeWithDefaultHandlersAndInstToBytecodes(int access, java.lang.String classType, java.lang.String name, java.lang.String signature, IInstruction[] instructions)Create information for a method, with no exception handlers and a dummy mapping of instructions to original bytecodes.voidputInfo(java.lang.Object key, MethodData.Results value)Set the annotation for the given key.voidsetHasChanged()java.lang.StringtoString()
-
-
-
Constructor Detail
-
MethodData
public MethodData(int access, java.lang.String classType, java.lang.String name, java.lang.String signature, IInstruction[] instructions, ExceptionHandler[][] handlers, int[] instructionsToBytecodes)Gather the information for a method "from scratch".- Parameters:
access- the access flagsclassType- the class in which the method is defined, in JVM type format (e.g., Ljava/lang/Object;)name- the method namesignature- the method signature, in JVM type format (e.g., (ILjava/lang/Object;)V)instructions- the instructions making up the methodhandlers- a list of exception handlers for each instructioninstructionsToBytecodes- a map stating, for each instruction, the offset of the original bytecode instruction(s) giving rise to this instruction
-
MethodData
public MethodData(Decoder d, int access, java.lang.String classType, java.lang.String name, java.lang.String signature) throws java.lang.NullPointerException
Gather the information for a method after it has been decoded.- Parameters:
d- the decoder which has decoded the methodaccess- the access flagsclassType- the class in which the method is defined, in JVM type format (e.g., Ljava/lang/Object;)name- the method namesignature- the method signature, in JVM type format (e.g., (ILjava/lang/Object;)V)- Throws:
java.lang.NullPointerException- if d is null
-
-
Method Detail
-
makeWithDefaultHandlersAndInstToBytecodes
public static MethodData makeWithDefaultHandlersAndInstToBytecodes(int access, java.lang.String classType, java.lang.String name, java.lang.String signature, IInstruction[] instructions)
Create information for a method, with no exception handlers and a dummy mapping of instructions to original bytecodes.- Parameters:
access- the access flagsclassType- the class in which the method is defined, in JVM type format (e.g., Ljava/lang/Object;)name- the method namesignature- the method signature, in JVM type format (e.g., (ILjava/lang/Object;)V)instructions- the instructions making up the method
-
setHasChanged
public void setHasChanged()
-
getSignature
public java.lang.String getSignature()
- Returns:
- the method signature, in JVM format
-
getName
public java.lang.String getName()
- Returns:
- the method name
-
getAccess
public int getAccess()
- Returns:
- the method access flags
-
getClassType
public java.lang.String getClassType()
- Returns:
- the JVM type for the class defining the method (e.g., Ljava/lang/Object;)
-
getIsStatic
public boolean getIsStatic()
- Returns:
- whether or not the method is static
-
getIsSynchronized
public boolean getIsSynchronized()
- Returns:
- whether or not the method is synchronized
-
getHandlers
public ExceptionHandler[][] getHandlers()
- Returns:
- the exception handler lists
-
getInstructions
public IInstruction[] getInstructions()
- Returns:
- the instruction array
-
getInstructionsToBytecodes
public int[] getInstructionsToBytecodes()
- Returns:
- the map from instructions to bytecode offsets
-
getInfo
public MethodData.Results getInfo(java.lang.Object key)
Get the annotation for the given key.- Returns:
- the annotation or null if there isn't one
-
putInfo
public void putInfo(java.lang.Object key, MethodData.Results value)Set the annotation for the given key.
-
getHasChanged
public boolean getHasChanged()
- Returns:
- true iff the code has been updated at least once
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-