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 InstructionArrayinstructionsprotected DexIClassmyClassThe 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 booleanequals(Object obj)intgetAddressFromIndex(int index)Collection<Annotation>getAnnotations()Get the annotations on this member, if anyCollection<Annotation>getAnnotations(boolean runtimeInvisible)intgetBytecodeIndex(int i)Collection<CallSiteReference>getCallSites()thereIClassHierarchygetClassHierarchy()TypeReference[]getDeclaredExceptions()IClassgetDeclaringClass()Return the object that represents the declaring class for this member.DescriptorgetDescriptor()something like: (IILjava.lang.String;SLjava.sql.Date;)Ljava.lang.Integer;Instruction[]getDexInstructions()intgetExceptionReg()ExceptionHandler[][]getHandlers()IndirectionDatagetIndirectionData()InstructiongetInstructionFromIndex(int instructionIndex)intgetInstructionIndex(int bytecodeindex)IInstruction[]getInstructions()intgetLineNumber(int bcIndex)StringgetLocalVariableName(int bcIndex, int localNumber)intgetMaxLocals()XXX not fully about the + 2.intgetMaxStackHeight()AtomgetName()intgetNumberOfParameterRegisters()intgetNumberOfParameters()Method getNumberOfParameters.Collection<Annotation>[]getParameterAnnotations()IMethod.SourcePositiongetParameterSourcePosition(int paramNum)TypeReferencegetParameterType(int index)By convention, for a non-static method, getParameterType(0) is the this pointerMethodReferencegetReference()intgetReturnReg()TypeReferencegetReturnType()SelectorgetSelector()something like: foo(Ljava/langString;)Ljava/lang/Class;StringgetSignature()something like: com.foo.bar.createLargeOrder(IILjava.lang.String;SLjava.sql.Date;)Ljava.lang.Integer;IMethod.SourcePositiongetSourcePosition(int instructionIndex)static intgetTotalInsts()protected voidhandleINVOKE_VIRTUAL(int instLoc, String cname, String mname, String pname, int[] args, org.jf.dexlib.Code.Opcode opcode)booleanhasExceptionHandler()inthashCode()booleanhasLocalVariableTable()protected InstructionArrayinstructions()booleanisAbstract()Is this method abstract?booleanisBridge()Is this method a bridge method? See JLS 3rd Edition 15.12.4.5booleanisClinit()Is this method a class initializer?booleanisFinal()Is this method final?booleanisInit()Is this method an object initializer?booleanisNative()Is this method native?booleanisPrivate()Is this method private?booleanisProtected()Is this method protected?booleanisPublic()Is this method public?booleanisStatic()Is this member static?booleanisSynchronized()Is this method synchronized?booleanisSynthetic()Did someone synthesize this method? (As opposed to reading it from a class file)booleanisVolatile()protected voidparseBytecode()org.jf.dexlib.ClassDataItem.EncodedMethodtoEncodedMethod()StringtoString()
-
-
-
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:
getDeclaredExceptionsin interfaceIMethod- Returns:
- an array of the exception types declared by the throws clause for this method, or null if there are none
- Throws:
InvalidClassFileExceptionUnsupportedOperationException
-
getLocalVariableName
public String getLocalVariableName(int bcIndex, int localNumber)
- Specified by:
getLocalVariableNamein 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:IMethodsomething like: (IILjava.lang.String;SLjava.sql.Date;)Ljava.lang.Integer;- Specified by:
getDescriptorin interfaceIMethod
-
getNumberOfParameters
public int getNumberOfParameters()
Description copied from interface:IMethodMethod getNumberOfParameters. This result includes the "this" pointer if applicable- Specified by:
getNumberOfParametersin interfaceIMethod
-
getNumberOfParameterRegisters
public int getNumberOfParameterRegisters()
-
getParameterType
public TypeReference getParameterType(int index)
Description copied from interface:IMethodBy convention, for a non-static method, getParameterType(0) is the this pointer- Specified by:
getParameterTypein interfaceIMethod
-
getReference
public MethodReference getReference()
- Specified by:
getReferencein interfaceIMethod- Returns:
- canonical MethodReference corresponding to this method
-
getReturnType
public TypeReference getReturnType()
- Specified by:
getReturnTypein interfaceIMethod- Returns:
- the name of the return type for this method
-
getSelector
public Selector getSelector()
Description copied from interface:IMethodsomething like: foo(Ljava/langString;)Ljava/lang/Class;- Specified by:
getSelectorin interfaceIMethod
-
getSignature
public String getSignature()
Description copied from interface:IMethodsomething like: com.foo.bar.createLargeOrder(IILjava.lang.String;SLjava.sql.Date;)Ljava.lang.Integer;- Specified by:
getSignaturein interfaceIMethod
-
hasExceptionHandler
public boolean hasExceptionHandler()
- Specified by:
hasExceptionHandlerin interfaceIMethod- Returns:
- true iff this method has at least one exception handler
-
hasLocalVariableTable
public boolean hasLocalVariableTable()
- Specified by:
hasLocalVariableTablein interfaceIMethod- Returns:
- true iff the local variable table information for this method is available
-
isAbstract
public boolean isAbstract()
Description copied from interface:IMethodIs this method abstract?- Specified by:
isAbstractin interfaceIMethod
-
isClinit
public boolean isClinit()
Description copied from interface:IMethodIs this method a class initializer?
-
isFinal
public boolean isFinal()
Description copied from interface:IMethodIs this method final?
-
isInit
public boolean isInit()
Description copied from interface:IMethodIs this method an object initializer?
-
isNative
public boolean isNative()
Description copied from interface:IMethodIs this method native?
-
isBridge
public boolean isBridge()
Description copied from interface:IMethodIs this method a bridge method? See JLS 3rd Edition 15.12.4.5
-
isPrivate
public boolean isPrivate()
Description copied from interface:IMethodIs this method private?
-
isProtected
public boolean isProtected()
Description copied from interface:IMethodIs this method protected?- Specified by:
isProtectedin interfaceIMethod
-
isPublic
public boolean isPublic()
Description copied from interface:IMethodIs this method public?
-
isSynchronized
public boolean isSynchronized()
Description copied from interface:IMethodIs this method synchronized?- Specified by:
isSynchronizedin interfaceIMethod
-
isSynthetic
public boolean isSynthetic()
Description copied from interface:IMethodDid someone synthesize this method? (As opposed to reading it from a class file)- Specified by:
isSyntheticin interfaceIMethod
-
isStatic
public boolean isStatic()
Description copied from interface:IMemberIs this member static?
-
isVolatile
public boolean isVolatile()
-
getDeclaringClass
public IClass getDeclaringClass()
Description copied from interface:IMemberReturn the object that represents the declaring class for this member.- Specified by:
getDeclaringClassin interfaceIMember- Returns:
- the object that represents the declaring class for this member.
-
getClassHierarchy
public IClassHierarchy getClassHierarchy()
- Specified by:
getClassHierarchyin interfaceIClassHierarchyDweller
-
getName
public Atom getName()
-
getLineNumber
public int getLineNumber(int bcIndex)
- Specified by:
getLineNumberin 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:
equalsin classObject- See Also:
Object.equals(Object)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classObject- See Also:
Object.hashCode()
-
getBytecodeIndex
public int getBytecodeIndex(int i) throws InvalidClassFileException- Specified by:
getBytecodeIndexin interfaceIBytecodeMethod- Returns:
- the bytecode index corresponding to instruction i in the getInstructions() array
- Throws:
InvalidClassFileException
-
getHandlers
public ExceptionHandler[][] getHandlers() throws InvalidClassFileException
- Specified by:
getHandlersin interfaceIBytecodeMethod- Returns:
- the Shrike representation of the exception handlers
- Throws:
InvalidClassFileException
-
getInstructions
public IInstruction[] getInstructions()
- Specified by:
getInstructionsin 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:
getIndirectionDatain interfaceIBytecodeMethod- Returns:
- information about any indirect uses of local variables
-
getCallSites
public Collection<CallSiteReference> getCallSites() throws InvalidClassFileException
Description copied from interface:IBytecodeMethodthere- Specified by:
getCallSitesin interfaceIBytecodeMethod- Returns:
- the call sites declared in the bytecode for this method
- Throws:
InvalidClassFileExceptionUnsupportedOperationException
-
getSourcePosition
public IMethod.SourcePosition getSourcePosition(int instructionIndex) throws InvalidClassFileException
- Specified by:
getSourcePositionin interfaceIMethod- Throws:
InvalidClassFileException
-
getParameterSourcePosition
public IMethod.SourcePosition getParameterSourcePosition(int paramNum) throws InvalidClassFileException
- Specified by:
getParameterSourcePositionin interfaceIMethod- Throws:
InvalidClassFileException
-
getAnnotations
public Collection<Annotation> getAnnotations()
Description copied from interface:IMemberGet the annotations on this member, if any- Specified by:
getAnnotationsin interfaceIMember
-
getAnnotations
public Collection<Annotation> getAnnotations(boolean runtimeInvisible)
- Specified by:
getAnnotationsin interfaceIBytecodeMethod
-
getParameterAnnotations
public Collection<Annotation>[] getParameterAnnotations()
- Specified by:
getParameterAnnotationsin interfaceIBytecodeMethod
-
-