Package com.ibm.wala.dalvik.classLoader
Class DexIMethod
- java.lang.Object
-
- com.ibm.wala.dalvik.classLoader.DexIMethod
-
- All Implemented Interfaces:
IBytecodeMethod
,IMember
,IMethod
,ContextItem
,IClassHierarchyDweller
- Direct Known Subclasses:
ActivityModelMethod
public class DexIMethod extends Object implements IBytecodeMethod
A wrapper around a EncodedMethod object (from dexlib) that represents a method.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.ibm.wala.ipa.callgraph.ContextItem
ContextItem.Value<T>
-
Nested classes/interfaces inherited from interface com.ibm.wala.classLoader.IMethod
IMethod.SourcePosition
-
-
Field Summary
Fields Modifier and Type Field Description protected InstructionArray
instructions
protected DexIClass
myClass
The declaring class for this method.
-
Constructor Summary
Constructors Constructor Description DexIMethod(org.jf.dexlib.ClassDataItem.EncodedMethod encodedMethod, DexIClass klass)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
int
getAddressFromIndex(int index)
Collection<Annotation>
getAnnotations()
Get the annotations on this member, if anyCollection<Annotation>
getAnnotations(boolean runtimeInvisible)
int
getBytecodeIndex(int i)
Collection<CallSiteReference>
getCallSites()
thereIClassHierarchy
getClassHierarchy()
TypeReference[]
getDeclaredExceptions()
IClass
getDeclaringClass()
Return the object that represents the declaring class for this member.Descriptor
getDescriptor()
something like: (IILjava.lang.String;SLjava.sql.Date;)Ljava.lang.Integer;Instruction[]
getDexInstructions()
int
getExceptionReg()
ExceptionHandler[][]
getHandlers()
IndirectionData
getIndirectionData()
Instruction
getInstructionFromIndex(int instructionIndex)
int
getInstructionIndex(int bytecodeindex)
IInstruction[]
getInstructions()
int
getLineNumber(int bcIndex)
String
getLocalVariableName(int bcIndex, int localNumber)
int
getMaxLocals()
XXX not fully about the + 2.int
getMaxStackHeight()
Atom
getName()
int
getNumberOfParameterRegisters()
int
getNumberOfParameters()
Method getNumberOfParameters.Collection<Annotation>[]
getParameterAnnotations()
IMethod.SourcePosition
getParameterSourcePosition(int paramNum)
TypeReference
getParameterType(int index)
By convention, for a non-static method, getParameterType(0) is the this pointerMethodReference
getReference()
int
getReturnReg()
TypeReference
getReturnType()
Selector
getSelector()
something like: foo(Ljava/langString;)Ljava/lang/Class;String
getSignature()
something like: com.foo.bar.createLargeOrder(IILjava.lang.String;SLjava.sql.Date;)Ljava.lang.Integer;IMethod.SourcePosition
getSourcePosition(int instructionIndex)
static int
getTotalInsts()
protected void
handleINVOKE_VIRTUAL(int instLoc, String cname, String mname, String pname, int[] args, org.jf.dexlib.Code.Opcode opcode)
boolean
hasExceptionHandler()
int
hashCode()
boolean
hasLocalVariableTable()
protected InstructionArray
instructions()
boolean
isAbstract()
Is this method abstract?boolean
isBridge()
Is this method a bridge method? See JLS 3rd Edition 15.12.4.5boolean
isClinit()
Is this method a class initializer?boolean
isFinal()
Is this method final?boolean
isInit()
Is this method an object initializer?boolean
isNative()
Is this method native?boolean
isPrivate()
Is this method private?boolean
isProtected()
Is this method protected?boolean
isPublic()
Is this method public?boolean
isStatic()
Is this member static?boolean
isSynchronized()
Is this method synchronized?boolean
isSynthetic()
Did someone synthesize this method? (As opposed to reading it from a class file)boolean
isVolatile()
protected void
parseBytecode()
org.jf.dexlib.ClassDataItem.EncodedMethod
toEncodedMethod()
String
toString()
-
-
-
Field Detail
-
myClass
protected final DexIClass myClass
The declaring class for this method.
-
instructions
protected InstructionArray instructions
-
-
Constructor Detail
-
DexIMethod
public DexIMethod(org.jf.dexlib.ClassDataItem.EncodedMethod encodedMethod, DexIClass klass)
-
-
Method Detail
-
getTotalInsts
public static int getTotalInsts()
-
toEncodedMethod
public org.jf.dexlib.ClassDataItem.EncodedMethod toEncodedMethod()
- Returns:
- the EncodedMethod object for which this DexIMethod is a wrapper.
-
getDeclaredExceptions
public TypeReference[] getDeclaredExceptions() throws InvalidClassFileException, UnsupportedOperationException
- Specified by:
getDeclaredExceptions
in interfaceIMethod
- Returns:
- an array of the exception types declared by the throws clause for this method, or null if there are none
- Throws:
InvalidClassFileException
UnsupportedOperationException
-
getLocalVariableName
public String getLocalVariableName(int bcIndex, int localNumber)
- Specified by:
getLocalVariableName
in interfaceIMethod
- Returns:
- the (source code) name of the local variable of a given number at the specified program counter, or null if the information is not available.
-
getMaxLocals
public int getMaxLocals()
XXX not fully about the + 2.- Returns:
- the RegisterCount + 2 to make some room for the return and exception register
- See Also:
com.ibm.wala.classLoader.IMethod#getMaxLocals()
-
getReturnReg
public int getReturnReg()
-
getExceptionReg
public int getExceptionReg()
-
getMaxStackHeight
public int getMaxStackHeight()
-
getDescriptor
public Descriptor getDescriptor()
Description copied from interface:IMethod
something like: (IILjava.lang.String;SLjava.sql.Date;)Ljava.lang.Integer;- Specified by:
getDescriptor
in interfaceIMethod
-
getNumberOfParameters
public int getNumberOfParameters()
Description copied from interface:IMethod
Method getNumberOfParameters. This result includes the "this" pointer if applicable- Specified by:
getNumberOfParameters
in interfaceIMethod
-
getNumberOfParameterRegisters
public int getNumberOfParameterRegisters()
-
getParameterType
public TypeReference getParameterType(int index)
Description copied from interface:IMethod
By convention, for a non-static method, getParameterType(0) is the this pointer- Specified by:
getParameterType
in interfaceIMethod
-
getReference
public MethodReference getReference()
- Specified by:
getReference
in interfaceIMethod
- Returns:
- canonical MethodReference corresponding to this method
-
getReturnType
public TypeReference getReturnType()
- Specified by:
getReturnType
in interfaceIMethod
- Returns:
- the name of the return type for this method
-
getSelector
public Selector getSelector()
Description copied from interface:IMethod
something like: foo(Ljava/langString;)Ljava/lang/Class;- Specified by:
getSelector
in interfaceIMethod
-
getSignature
public String getSignature()
Description copied from interface:IMethod
something like: com.foo.bar.createLargeOrder(IILjava.lang.String;SLjava.sql.Date;)Ljava.lang.Integer;- Specified by:
getSignature
in interfaceIMethod
-
hasExceptionHandler
public boolean hasExceptionHandler()
- Specified by:
hasExceptionHandler
in interfaceIMethod
- Returns:
- true iff this method has at least one exception handler
-
hasLocalVariableTable
public boolean hasLocalVariableTable()
- Specified by:
hasLocalVariableTable
in interfaceIMethod
- Returns:
- true iff the local variable table information for this method is available
-
isAbstract
public boolean isAbstract()
Description copied from interface:IMethod
Is this method abstract?- Specified by:
isAbstract
in interfaceIMethod
-
isClinit
public boolean isClinit()
Description copied from interface:IMethod
Is this method a class initializer?
-
isFinal
public boolean isFinal()
Description copied from interface:IMethod
Is this method final?
-
isInit
public boolean isInit()
Description copied from interface:IMethod
Is this method an object initializer?
-
isNative
public boolean isNative()
Description copied from interface:IMethod
Is this method native?
-
isBridge
public boolean isBridge()
Description copied from interface:IMethod
Is this method a bridge method? See JLS 3rd Edition 15.12.4.5
-
isPrivate
public boolean isPrivate()
Description copied from interface:IMethod
Is this method private?
-
isProtected
public boolean isProtected()
Description copied from interface:IMethod
Is this method protected?- Specified by:
isProtected
in interfaceIMethod
-
isPublic
public boolean isPublic()
Description copied from interface:IMethod
Is this method public?
-
isSynchronized
public boolean isSynchronized()
Description copied from interface:IMethod
Is this method synchronized?- Specified by:
isSynchronized
in interfaceIMethod
-
isSynthetic
public boolean isSynthetic()
Description copied from interface:IMethod
Did someone synthesize this method? (As opposed to reading it from a class file)- Specified by:
isSynthetic
in interfaceIMethod
-
isStatic
public boolean isStatic()
Description copied from interface:IMember
Is this member static?
-
isVolatile
public boolean isVolatile()
-
getDeclaringClass
public IClass getDeclaringClass()
Description copied from interface:IMember
Return the object that represents the declaring class for this member.- Specified by:
getDeclaringClass
in interfaceIMember
- Returns:
- the object that represents the declaring class for this member.
-
getClassHierarchy
public IClassHierarchy getClassHierarchy()
- Specified by:
getClassHierarchy
in interfaceIClassHierarchyDweller
-
getName
public Atom getName()
-
getLineNumber
public int getLineNumber(int bcIndex)
- Specified by:
getLineNumber
in interfaceIMethod
- Returns:
- the source line number corresponding to a particular bytecode index, or -1 if the information is not available.
-
equals
public boolean equals(Object obj)
- Overrides:
equals
in classObject
- See Also:
Object.equals(Object)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classObject
- See Also:
Object.hashCode()
-
getBytecodeIndex
public int getBytecodeIndex(int i) throws InvalidClassFileException
- Specified by:
getBytecodeIndex
in interfaceIBytecodeMethod
- Returns:
- the bytecode index corresponding to instruction i in the getInstructions() array
- Throws:
InvalidClassFileException
-
getHandlers
public ExceptionHandler[][] getHandlers() throws InvalidClassFileException
- Specified by:
getHandlers
in interfaceIBytecodeMethod
- Returns:
- the Shrike representation of the exception handlers
- Throws:
InvalidClassFileException
-
getInstructions
public IInstruction[] getInstructions()
- Specified by:
getInstructions
in interfaceIBytecodeMethod
- Returns:
- the Shrike instructions decoded from the bytecode
-
parseBytecode
protected void parseBytecode()
-
handleINVOKE_VIRTUAL
protected void handleINVOKE_VIRTUAL(int instLoc, String cname, String mname, String pname, int[] args, org.jf.dexlib.Code.Opcode opcode)
-
getDexInstructions
public Instruction[] getDexInstructions()
-
instructions
protected InstructionArray instructions()
-
getAddressFromIndex
public int getAddressFromIndex(int index)
-
getInstructionIndex
public int getInstructionIndex(int bytecodeindex)
-
getInstructionFromIndex
public Instruction getInstructionFromIndex(int instructionIndex)
-
getIndirectionData
public IndirectionData getIndirectionData()
- Specified by:
getIndirectionData
in interfaceIBytecodeMethod
- Returns:
- information about any indirect uses of local variables
-
getCallSites
public Collection<CallSiteReference> getCallSites() throws InvalidClassFileException
Description copied from interface:IBytecodeMethod
there- Specified by:
getCallSites
in interfaceIBytecodeMethod
- Returns:
- the call sites declared in the bytecode for this method
- Throws:
InvalidClassFileException
UnsupportedOperationException
-
getSourcePosition
public IMethod.SourcePosition getSourcePosition(int instructionIndex) throws InvalidClassFileException
- Specified by:
getSourcePosition
in interfaceIMethod
- Throws:
InvalidClassFileException
-
getParameterSourcePosition
public IMethod.SourcePosition getParameterSourcePosition(int paramNum) throws InvalidClassFileException
- Specified by:
getParameterSourcePosition
in interfaceIMethod
- Throws:
InvalidClassFileException
-
getAnnotations
public Collection<Annotation> getAnnotations()
Description copied from interface:IMember
Get the annotations on this member, if any- Specified by:
getAnnotations
in interfaceIMember
-
getAnnotations
public Collection<Annotation> getAnnotations(boolean runtimeInvisible)
- Specified by:
getAnnotations
in interfaceIBytecodeMethod
-
getParameterAnnotations
public Collection<Annotation>[] getParameterAnnotations()
- Specified by:
getParameterAnnotations
in interfaceIBytecodeMethod
-
-