Package soot.jbco.jimpleTransformations
Class MethodRenamer
- java.lang.Object
-
- soot.Transformer
-
- soot.SceneTransformer
-
- soot.jbco.jimpleTransformations.MethodRenamer
-
- All Implemented Interfaces:
IJbcoTransform
public class MethodRenamer extends SceneTransformer implements IJbcoTransform
Creates new method names using names of fields or generates randomly. New names are unique through the whole application.Some methods cannot be renamed:
mainmethods- constructors
- static initializers
- ones that override/implement library methods
To find methods from last group the next approach is used. All superclasses and interfaces that processing class extends / implements are collected. The children of that items are taken and united together along with processing class. The same action is performed for every item of the obtained result until the full "tree" is not created. Then from this tree, the classes that do not have methods with
similar to searching signature, are removed. The left items that haveSootClass.isLibraryClass()trueare searching ones.This complex approach is used to detect indirect inheritance. Consider next example:
,--------. |A | |--------| |--------| |method()| `--------' / \ / \ ,-----------------------------. ,--------. ,--------. ,--------------------------------. |D | |B | |E | | Note: E is a library interface | |-----------------------------| |--------| |--------| `--------------------------------' |-----------------------------| |--------| |--------| |method() | |method()| |method()| |method(java.lang.String, int)| `--------' `--------' `-----------------------------' \ / ,------------------------. |C | |------------------------| |------------------------| |method() | |method(java.lang.String)| |method(long, int) | `------------------------'Thus whenD#method()is processed, it must not be renamed as there is classCthat implements library one (E#method()).After applying this transformer the next result is expected:
#method()is not renamed in any application classes as it overrides one from library#method(java.lang.String),#method(long, int)and#method(java.lang.String, int)are renamed and have the same name. Such renaming behaviour allows having renaming map for every class with old method name as a key and new method name as a value
- Since:
- 24-Jan-2006
- Author:
- Michael Batchelder, Pavel Nesterovich
-
-
Constructor Summary
Constructors Constructor Description MethodRenamer(Singletons.Global global)Singleton constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String[]getDependencies()Gets array ofjbco transformercode names on which current transformer depends on.StringgetName()Gets the code name ofjbco transformerimplementation.StringgetNewName()Creates new unique method name.Map<String,String>getRenamingMap(String className)Gets renaming map for specific class.protected voidinternalTransform(String phaseName, Map<String,String> options)Performs the transformation on the Scene, under the given phaseName and with the given Options.voidoutputSummary()Prints summary of the produced changes.static MethodRenamerv()Singleton getter.-
Methods inherited from class soot.SceneTransformer
transform, transform, transform
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface soot.jbco.IJbcoTransform
isDebugEnabled, isVerbose
-
-
-
-
Field Detail
-
name
public static final String name
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MethodRenamer
public MethodRenamer(Singletons.Global global)
Singleton constructor.- Parameters:
global- the singletons container. Must not benull- Throws:
NullPointerException- whenglobalargument isnull
-
-
Method Detail
-
v
public static MethodRenamer v()
Singleton getter.- Returns:
- returns instance of
MethodRenamer
-
getName
public String getName()
Description copied from interface:IJbcoTransformGets the code name ofjbco transformerimplementation.- Specified by:
getNamein interfaceIJbcoTransform- Returns:
- the code name of
jbco transformer
-
getDependencies
public String[] getDependencies()
Description copied from interface:IJbcoTransformGets array ofjbco transformercode names on which current transformer depends on.- Specified by:
getDependenciesin interfaceIJbcoTransform- Returns:
- array of code names
-
outputSummary
public void outputSummary()
Description copied from interface:IJbcoTransformPrints summary of the produced changes.- Specified by:
outputSummaryin interfaceIJbcoTransform
-
getRenamingMap
public Map<String,String> getRenamingMap(String className)
Gets renaming map for specific class.- Parameters:
className- the name of class to get renaming map for- Returns:
- the map where the key is old method name, the value - new method name. Never
null
-
internalTransform
protected void internalTransform(String phaseName, Map<String,String> options)
Description copied from class:SceneTransformerPerforms the transformation on the Scene, under the given phaseName and with the given Options.- Specified by:
internalTransformin classSceneTransformer
-
getNewName
public String getNewName()
Creates new unique method name.- Returns:
- newly generated junk name that DOES NOT exist yet
-
-