public class SootUtilities
extends java.lang.Object
Constructor and Description |
---|
SootUtilities() |
Modifier and Type | Method and Description |
---|---|
static void |
assertFinalField(soot.SootClass theClass,
soot.SootField theField,
soot.Value newValue)
Make the given field final.
|
static void |
changeTypesInMethods(soot.SootClass theClass,
soot.SootClass oldClass,
soot.SootClass newClass)
Search through all the methods in the given class and change
all references to the old class to references to the new class.
|
static void |
changeTypesOfFields(soot.SootClass theClass,
soot.SootClass oldClass,
soot.SootClass newClass)
Search through all the fields in the given class and if the
field is of class oldClass, then change it to newClass.
|
static soot.jimple.Constant |
convertArgumentToConstantValue(java.lang.Object object)
Return a constant value that represents the same numeric value
as the given object.
|
static java.lang.Object |
convertConstantValueToArgument(soot.Value value)
Return an object that represents the same numeric value as the
given value.
|
static soot.SootClass |
copyClass(soot.SootClass oldClass,
java.lang.String newClassName)
Copy a class
|
static soot.SootField |
createAndSetFieldFromLocal(soot.jimple.JimpleBody body,
soot.Local local,
soot.SootClass theClass,
soot.Type type,
java.lang.String name)
Create a new instance field with the given name
and type and add it to the
given class.
|
static soot.SootField |
createAndSetFieldFromLocal(soot.jimple.JimpleBody body,
soot.Local local,
soot.SootClass theClass,
soot.Type type,
java.lang.String name,
soot.Unit insertPoint)
Create a new instance field with the given name and type and
add it to the given class.
|
static java.util.List |
createForLoopBefore(soot.Body body,
soot.Unit insertPoint,
java.util.List initializerList,
java.util.List bodyList,
soot.jimple.Expr conditionalExpr)
Create statements that correspond to a for loop and return
them.
|
static soot.Type |
createIsomorphicType(soot.Type shapeType,
soot.Type elementType)
Create a type with the same shape as the given shape type,
containing elements of the type given by the given element
type.
|
static soot.Local |
createRuntimeException(soot.Body body,
soot.Unit unit,
java.lang.String string)
Create a new local variable in the given body, initialized
before the given unit that refers to a Runtime exception with
the given string message.
|
static soot.SootClass |
createStaticClassForInstance(soot.SootClass theClass,
soot.Body containerBody,
soot.jimple.DefinitionStmt newStmt,
soot.jimple.InvokeStmt constructorStmt,
java.lang.String className)
Create a new static class that will behave identically to the
given instance.
|
static boolean |
derivesFrom(soot.SootClass theClass,
soot.SootClass baseClass)
Return true if the given class derives from the given base class.
|
static void |
foldClass(soot.SootClass theClass)
Merge the given class with its super class.
|
static java.lang.Class |
getClassForType(soot.Type type)
Given a Type object, return the java.lang.Class object that the
type represents.
|
static soot.SootMethod |
getMatchingMethod(soot.SootClass theClass,
java.lang.String name,
java.util.List args)
Get the method in the given class that has the given name and will
accept the given argument list.
|
static soot.SootMethod |
getSootMethodForMethod(java.lang.reflect.Method method) |
static boolean |
inlineCallsOnThisInMethod(soot.SootMethod method)
Inline all the method calls whose base is 'this'
in the given method.
|
static void |
inlineCallsToMethod(soot.SootMethod inlineMethod,
soot.SootClass theClass)
Inline all calls to the given method that occur within the given class.
|
static boolean |
isAliasableValue(soot.Value value)
Return true if the given value represents something that can
be aliased in Java by something else.
|
static boolean |
isSubtypeOf(soot.Type type1,
soot.Type type2)
Return true if type2 is a subtype of type1.
|
static void |
makeFieldStatic(soot.SootClass theClass,
soot.SootField field)
Make the given field a static field.
|
static java.lang.Object |
reflectAndInvokeConstructor(soot.SootMethod sootMethod,
soot.Value[] argValues)
Reflect the given constructor method with the given arguments
on the class of the given object.
|
static java.lang.Object |
reflectAndInvokeMethod(java.lang.Object object,
soot.SootMethod sootMethod,
soot.Value[] argValues)
Reflect the given method on the class of the given object.
|
static void |
replaceInvokeExpr(soot.jimple.JimpleBody body,
soot.jimple.Stmt stmt,
soot.Value value)
Replace the invoke expression in the given statement in the
given body with the given value.
|
static soot.SootMethod |
resolveSpecialInvokationForInlining(soot.jimple.SpecialInvokeExpr expr,
soot.SootMethod callingMethod) |
static soot.SootMethod |
resolveVirtualInvokationForInlining(soot.SootClass baseClass,
soot.SootMethod targetMethod) |
static soot.SootMethod |
searchForMethodByName(soot.SootClass theClass,
java.lang.String name)
Get the method with the given name in the given class
(or one of its super classes).
|
static void |
unrollIteratorInstances(soot.SootClass theClass,
soot.SootField field,
java.util.List fieldList)
Anywhere where the iterator of the given field is referenced
in the given class, unroll the iterator as if it contained the
objects referenced by the given fields.
|
public static void assertFinalField(soot.SootClass theClass, soot.SootField theField, soot.Value newValue)
public static soot.SootClass copyClass(soot.SootClass oldClass, java.lang.String newClassName)
public static void changeTypesOfFields(soot.SootClass theClass, soot.SootClass oldClass, soot.SootClass newClass)
theClass
- The class containing fields to modify.oldClass
- The class to replace.newClass
- The new class.public static void changeTypesInMethods(soot.SootClass theClass, soot.SootClass oldClass, soot.SootClass newClass)
theClass
- The class containing methods to modify.oldClass
- The class to replace.newClass
- The new class.public static java.lang.Object convertConstantValueToArgument(soot.Value value)
value
- A constant value.public static soot.jimple.Constant convertArgumentToConstantValue(java.lang.Object object)
object
- An object that is assumed to be either a Token
or a primitive Java object.public static soot.SootField createAndSetFieldFromLocal(soot.jimple.JimpleBody body, soot.Local local, soot.SootClass theClass, soot.Type type, java.lang.String name)
public static soot.SootField createAndSetFieldFromLocal(soot.jimple.JimpleBody body, soot.Local local, soot.SootClass theClass, soot.Type type, java.lang.String name, soot.Unit insertPoint)
public static java.util.List createForLoopBefore(soot.Body body, soot.Unit insertPoint, java.util.List initializerList, java.util.List bodyList, soot.jimple.Expr conditionalExpr)
public static soot.Type createIsomorphicType(soot.Type shapeType, soot.Type elementType)
public static soot.Local createRuntimeException(soot.Body body, soot.Unit unit, java.lang.String string)
public static soot.SootClass createStaticClassForInstance(soot.SootClass theClass, soot.Body containerBody, soot.jimple.DefinitionStmt newStmt, soot.jimple.InvokeStmt constructorStmt, java.lang.String className)
theClass
- The context in which method calls on the given
instance will be replaced with method calls to the new static
class.containerBody
- The body that contains the definition
statement.newStmt
- The statement where the instance is created.
The right hand side of the definition is assumed to be an
instance of NewExpr.constructorStmt
- The statement where the initializer
for the instance is called.className
- The name of the class that will be created.public static boolean derivesFrom(soot.SootClass theClass, soot.SootClass baseClass)
public static boolean isSubtypeOf(soot.Type type1, soot.Type type2)
public static void foldClass(soot.SootClass theClass)
public static java.lang.Class getClassForType(soot.Type type) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public static soot.SootMethod getMatchingMethod(soot.SootClass theClass, java.lang.String name, java.util.List args)
public static soot.SootMethod getSootMethodForMethod(java.lang.reflect.Method method)
public static soot.SootMethod resolveSpecialInvokationForInlining(soot.jimple.SpecialInvokeExpr expr, soot.SootMethod callingMethod)
public static soot.SootMethod resolveVirtualInvokationForInlining(soot.SootClass baseClass, soot.SootMethod targetMethod)
public static void inlineCallsToMethod(soot.SootMethod inlineMethod, soot.SootClass theClass)
public static boolean inlineCallsOnThisInMethod(soot.SootMethod method)
public static boolean isAliasableValue(soot.Value value)
public static void makeFieldStatic(soot.SootClass theClass, soot.SootField field)
public static java.lang.Object reflectAndInvokeMethod(java.lang.Object object, soot.SootMethod sootMethod, soot.Value[] argValues)
public static java.lang.Object reflectAndInvokeConstructor(soot.SootMethod sootMethod, soot.Value[] argValues)
sootMethod
- The soot initializer method that corresponds to the
correct Java constructor.argValues
- The arguments, which must be constant valued.public static void replaceInvokeExpr(soot.jimple.JimpleBody body, soot.jimple.Stmt stmt, soot.Value value)
public static soot.SootMethod searchForMethodByName(soot.SootClass theClass, java.lang.String name)
public static void unrollIteratorInstances(soot.SootClass theClass, soot.SootField field, java.util.List fieldList)