Package com.ibm.wala.classLoader
Class ShrikeBTMethod
- java.lang.Object
-
- com.ibm.wala.classLoader.ShrikeBTMethod
-
- All Implemented Interfaces:
IMember,IMethod,ContextItem,IClassHierarchyDweller,BytecodeConstants
- Direct Known Subclasses:
ShrikeCTMethod
public abstract class ShrikeBTMethod extends Object implements IMethod, BytecodeConstants
A wrapper around a Shrike object that represents a method
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classShrikeBTMethod.BytecodeInfo-
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 IClassdeclaringClassA wrapper around the declaring class.-
Fields inherited from interface com.ibm.wala.shrikeBT.BytecodeConstants
JBC_aaload, JBC_aastore, JBC_aconst_null, JBC_aload, JBC_aload_0, JBC_aload_1, JBC_aload_2, JBC_aload_3, JBC_anewarray, JBC_areturn, JBC_arraylength, JBC_astore, JBC_astore_0, JBC_astore_1, JBC_astore_2, JBC_astore_3, JBC_athrow, JBC_baload, JBC_bastore, JBC_bipush, JBC_caload, JBC_castore, JBC_checkcast, JBC_d2f, JBC_d2i, JBC_d2l, JBC_dadd, JBC_daload, JBC_dastore, JBC_dcmpg, JBC_dcmpl, JBC_dconst_0, JBC_dconst_1, JBC_ddiv, JBC_dload, JBC_dload_0, JBC_dload_1, JBC_dload_2, JBC_dload_3, JBC_dmul, JBC_dneg, JBC_drem, JBC_dreturn, JBC_dstore, JBC_dstore_0, JBC_dstore_1, JBC_dstore_2, JBC_dstore_3, JBC_dsub, JBC_dup, JBC_dup_x1, JBC_dup_x2, JBC_dup2, JBC_dup2_x1, JBC_dup2_x2, JBC_f2d, JBC_f2i, JBC_f2l, JBC_fadd, JBC_faload, JBC_fastore, JBC_fcmpg, JBC_fcmpl, JBC_fconst_0, JBC_fconst_1, JBC_fconst_2, JBC_fdiv, JBC_fload, JBC_fload_0, JBC_fload_1, JBC_fload_2, JBC_fload_3, JBC_fmul, JBC_fneg, JBC_frem, JBC_freturn, JBC_fstore, JBC_fstore_0, JBC_fstore_1, JBC_fstore_2, JBC_fstore_3, JBC_fsub, JBC_getfield, JBC_getstatic, JBC_goto, JBC_goto_w, JBC_i2d, JBC_i2f, JBC_i2l, JBC_iadd, JBC_iaload, JBC_iand, JBC_iastore, JBC_iconst_0, JBC_iconst_1, JBC_iconst_2, JBC_iconst_3, JBC_iconst_4, JBC_iconst_5, JBC_iconst_m1, JBC_idiv, JBC_if_acmpeq, JBC_if_acmpne, JBC_if_icmpeq, JBC_if_icmpge, JBC_if_icmpgt, JBC_if_icmple, JBC_if_icmplt, JBC_if_icmpne, JBC_ifeq, JBC_ifge, JBC_ifgt, JBC_ifle, JBC_iflt, JBC_ifne, JBC_ifnonnull, JBC_ifnull, JBC_iinc, JBC_iload, JBC_iload_0, JBC_iload_1, JBC_iload_2, JBC_iload_3, JBC_impdep1, JBC_impdep2, JBC_imul, JBC_ineg, JBC_instanceof, JBC_int2byte, JBC_int2char, JBC_int2short, JBC_invokeinterface, JBC_invokespecial, JBC_invokestatic, JBC_invokevirtual, JBC_ior, JBC_irem, JBC_ireturn, JBC_ishl, JBC_ishr, JBC_istore, JBC_istore_0, JBC_istore_1, JBC_istore_2, JBC_istore_3, JBC_isub, JBC_iushr, JBC_ixor, JBC_jsr, JBC_jsr_w, JBC_l2d, JBC_l2f, JBC_l2i, JBC_ladd, JBC_laload, JBC_land, JBC_lastore, JBC_lcmp, JBC_lconst_0, JBC_lconst_1, JBC_ldc, JBC_ldc_w, JBC_ldc2_w, JBC_ldiv, JBC_length, JBC_lload, JBC_lload_0, JBC_lload_1, JBC_lload_2, JBC_lload_3, JBC_lmul, JBC_lneg, JBC_lookupswitch, JBC_lor, JBC_lrem, JBC_lreturn, JBC_lshl, JBC_lshr, JBC_lstore, JBC_lstore_0, JBC_lstore_1, JBC_lstore_2, JBC_lstore_3, JBC_lsub, JBC_lushr, JBC_lxor, JBC_monitorenter, JBC_monitorexit, JBC_multianewarray, JBC_name, JBC_new, JBC_newarray, JBC_nop, JBC_pop, JBC_pop2, JBC_putfield, JBC_putstatic, JBC_ret, JBC_return, JBC_saload, JBC_sastore, JBC_sipush, JBC_swap, JBC_tableswitch, JBC_wide, JBC_xxxunusedxxx
-
-
Constructor Summary
Constructors Constructor Description ShrikeBTMethod(IClass klass)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclearCaches()Clear all optional cached data associated with this class.booleanequals(Object obj)IteratorgetArraysRead()Iterator<TypeReference>getArraysWritten()protected ShrikeBTMethod.BytecodeInfogetBCInfo()intgetBytecodeIndex(int instructionIndex)Return the program counter (bytecode index) for a particular Shrike instruction index.protected abstract byte[]getBytecodes()BytecodeStreamgetBytecodeStream()Method getBytecodeStream.Collection<CallSiteReference>getCallSites()IteratorgetCastTypes()Set<TypeReference>getCaughtExceptionTypes()TypeReference[]getDeclaredExceptions()Clients should not modify the returned array.protected abstract String[]getDeclaredExceptionTypeNames()IClassgetDeclaringClass()Return the object that represents the declaring class for this member.DescriptorgetDescriptor()something like: (IILjava.lang.String;SLjava.sql.Date;)Ljava.lang.Integer;Iterator<FieldReference>getFieldsRead()Iterator<FieldReference>getFieldsWritten()ExceptionHandler[][]getHandlers()Collection<TypeReference>getImplicitExceptionTypes()IInstruction[]getInstructions()intgetLineNumber(int bcIndex)END Custom change: precise bytecode positionsabstract StringgetLocalVariableName(int bcIndex, int localNumber)abstract intgetMaxLocals()abstract intgetMaxStackHeight()protected abstract StringgetMethodName()protected abstract StringgetMethodSignature()protected abstract intgetModifiers()AtomgetName()intgetNumberOfParameters()Method getNumberOfParameters.intgetNumShrikeInstructions()Return the number of Shrike instructions for this method.IMethod.SourcePositiongetParameterSourcePosition(int paramNum)TypeReferencegetParameterType(int i)By convention, for a non-static method, getParameterType(0) is the this pointerMethodReferencegetReference()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 bcIndex)BEGIN Custom change: precise bytecode positionsabstract booleanhasExceptionHandler()inthashCode()abstract booleanhasLocalVariableTable()booleanhasMonitorOp()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)protected abstract DecodermakeDecoder()Find the decoder object for this method, or create one if necessary.protected abstract voidprocessDebugInfo(ShrikeBTMethod.BytecodeInfo bcInfo)Walk through the bytecodes and collect trivial information.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.ibm.wala.ipa.cha.IClassHierarchyDweller
getClassHierarchy
-
Methods inherited from interface com.ibm.wala.classLoader.IMember
getAnnotations
-
Methods inherited from interface com.ibm.wala.classLoader.IMethod
getReturnType
-
-
-
-
Field Detail
-
declaringClass
protected final IClass declaringClass
A wrapper around the declaring class.
-
-
Constructor Detail
-
ShrikeBTMethod
public ShrikeBTMethod(IClass klass)
-
-
Method Detail
-
getBCInfo
protected ShrikeBTMethod.BytecodeInfo getBCInfo() throws InvalidClassFileException
- Throws:
InvalidClassFileException
-
getBytecodeIndex
public int getBytecodeIndex(int instructionIndex) throws InvalidClassFileExceptionReturn the program counter (bytecode index) for a particular Shrike instruction index.- Throws:
InvalidClassFileException
-
getNumShrikeInstructions
public int getNumShrikeInstructions() throws InvalidClassFileExceptionReturn the number of Shrike instructions for this method.- Throws:
InvalidClassFileException
-
getCallSites
public Collection<CallSiteReference> getCallSites() throws InvalidClassFileException
- Throws:
InvalidClassFileException
-
getImplicitExceptionTypes
public Collection<TypeReference> getImplicitExceptionTypes() throws InvalidClassFileException
- Returns:
- Set
, the exceptions that statements in this method may throw, - Throws:
InvalidClassFileException
-
hasMonitorOp
public boolean hasMonitorOp() throws InvalidClassFileException- Returns:
- true iff this method has a monitorenter or monitorexit
- Throws:
InvalidClassFileException
-
getFieldsWritten
public Iterator<FieldReference> getFieldsWritten() throws InvalidClassFileException
- Returns:
- Set of FieldReference
- Throws:
InvalidClassFileException
-
getFieldsRead
public Iterator<FieldReference> getFieldsRead() throws InvalidClassFileException
- Returns:
- Iterator of FieldReference
- Throws:
InvalidClassFileException
-
getArraysRead
public Iterator getArraysRead() throws InvalidClassFileException
- Returns:
- Iterator of TypeReference
- Throws:
InvalidClassFileException
-
getArraysWritten
public Iterator<TypeReference> getArraysWritten() throws InvalidClassFileException
- Returns:
- Iterator of TypeReference
- Throws:
InvalidClassFileException
-
getCastTypes
public Iterator getCastTypes() throws InvalidClassFileException
- Returns:
- Iterator of TypeReference
- Throws:
InvalidClassFileException
-
getBytecodes
protected abstract byte[] getBytecodes()
-
getBytecodeStream
public BytecodeStream getBytecodeStream()
Method getBytecodeStream.- Returns:
- the bytecode stream for this method, or null if no bytecodes.
-
getMethodName
protected abstract String getMethodName() throws InvalidClassFileException
- Throws:
InvalidClassFileException
-
getMethodSignature
protected abstract String getMethodSignature() throws InvalidClassFileException
- Throws:
InvalidClassFileException
-
getReference
public MethodReference getReference()
- Specified by:
getReferencein interfaceIMethod- Returns:
- canonical MethodReference corresponding to this method
-
isClinit
public boolean isClinit()
Description copied from interface:IMethodIs this method a class initializer?
-
isInit
public boolean isInit()
Description copied from interface:IMethodIs this method an object initializer?
-
getModifiers
protected abstract int getModifiers()
-
isNative
public boolean isNative()
Description copied from interface:IMethodIs this method native?
-
isAbstract
public boolean isAbstract()
Description copied from interface:IMethodIs this method abstract?- Specified by:
isAbstractin interfaceIMethod
-
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?
-
isFinal
public boolean isFinal()
Description copied from interface:IMethodIs this method final?
-
isBridge
public boolean isBridge()
Description copied from interface:IMethodIs this method a bridge method? See JLS 3rd Edition 15.12.4.5
-
isSynchronized
public boolean isSynchronized()
Description copied from interface:IMethodIs this method synchronized?- Specified by:
isSynchronizedin interfaceIMethod
-
isStatic
public boolean isStatic()
Description copied from interface:IMemberIs this member static?
-
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
-
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.
-
makeDecoder
protected abstract Decoder makeDecoder()
Find the decoder object for this method, or create one if necessary.- Returns:
- null if the method has no code.
-
processDebugInfo
protected abstract void processDebugInfo(ShrikeBTMethod.BytecodeInfo bcInfo) throws InvalidClassFileException
Walk through the bytecodes and collect trivial information.- Throws:
InvalidClassFileException
-
toString
public String toString()
- Overrides:
toStringin classObject- See Also:
Object.toString()
-
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()
-
getMaxLocals
public abstract int getMaxLocals()
-
getMaxStackHeight
public abstract int getMaxStackHeight()
-
getName
public Atom getName()
-
getDescriptor
public Descriptor getDescriptor()
Description copied from interface:IMethodsomething like: (IILjava.lang.String;SLjava.sql.Date;)Ljava.lang.Integer;- Specified by:
getDescriptorin interfaceIMethod
-
getInstructions
public IInstruction[] getInstructions() throws InvalidClassFileException
- Throws:
InvalidClassFileException
-
getHandlers
public ExceptionHandler[][] getHandlers() throws InvalidClassFileException
- Throws:
InvalidClassFileException
-
getParameterType
public TypeReference getParameterType(int i)
By convention, for a non-static method, getParameterType(0) is the this pointer- Specified by:
getParameterTypein interfaceIMethod
-
getNumberOfParameters
public int getNumberOfParameters()
Method getNumberOfParameters. This result includes the "this" pointer if applicable- Specified by:
getNumberOfParametersin interfaceIMethod- Returns:
- int
-
hasExceptionHandler
public abstract boolean hasExceptionHandler()
- Specified by:
hasExceptionHandlerin interfaceIMethod- Returns:
- true iff this method has at least one exception handler
-
getDeclaredExceptions
public TypeReference[] getDeclaredExceptions() throws InvalidClassFileException
Clients should not modify the returned array. TODO: clone to avoid the problem?- 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:
InvalidClassFileException- See Also:
IMethod.getDeclaredExceptions()
-
getDeclaredExceptionTypeNames
protected abstract String[] getDeclaredExceptionTypeNames() throws InvalidClassFileException
- Throws:
InvalidClassFileException
-
getSourcePosition
public IMethod.SourcePosition getSourcePosition(int bcIndex) throws InvalidClassFileException
BEGIN Custom change: precise bytecode positions- Specified by:
getSourcePositionin interfaceIMethod- Throws:
InvalidClassFileException
-
getParameterSourcePosition
public IMethod.SourcePosition getParameterSourcePosition(int paramNum) throws InvalidClassFileException
- Specified by:
getParameterSourcePositionin interfaceIMethod- Throws:
InvalidClassFileException
-
getLineNumber
public int getLineNumber(int bcIndex)
END Custom change: precise bytecode positions- Specified by:
getLineNumberin interfaceIMethod- Returns:
- the source line number corresponding to a particular bytecode index, or -1 if the information is not available.
-
getCaughtExceptionTypes
public Set<TypeReference> getCaughtExceptionTypes() throws InvalidClassFileException
- Returns:
- Set
- Throws:
InvalidClassFileException
-
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
-
getSelector
public Selector getSelector()
Description copied from interface:IMethodsomething like: foo(Ljava/langString;)Ljava/lang/Class;- Specified by:
getSelectorin interfaceIMethod
-
getLocalVariableName
public abstract 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.
-
hasLocalVariableTable
public abstract boolean hasLocalVariableTable()
- Specified by:
hasLocalVariableTablein interfaceIMethod- Returns:
- true iff the local variable table information for this method is available
-
clearCaches
public void clearCaches()
Clear all optional cached data associated with this class.
-
-