public class MethodRenamer extends SceneTransformer implements IJbcoTransform
Some methods cannot be renamed:
main
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 SootClass.isLibraryClass()
true
are 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 when
D#method()
is processed, it must not be renamed as there is class C
that 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 valueModifier and Type | Field and Description |
---|---|
static java.lang.String[] |
dependencies |
static java.lang.String |
name |
debug, out, output
Constructor and Description |
---|
MethodRenamer(Singletons.Global global)
Singleton constructor.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String[] |
getDependencies()
Gets array of
jbco transformer code names on which current transformer depends on. |
java.lang.String |
getName()
Gets the code name of
jbco transformer implementation. |
java.lang.String |
getNewName()
Creates new unique method name.
|
java.util.Map<java.lang.String,java.lang.String> |
getRenamingMap(java.lang.String className)
Gets renaming map for specific class.
|
protected void |
internalTransform(java.lang.String phaseName,
java.util.Map<java.lang.String,java.lang.String> options)
Performs the transformation on the Scene, under the given phaseName and with the given Options.
|
void |
outputSummary()
Prints summary of the produced changes.
|
static MethodRenamer |
v()
Singleton getter.
|
transform, transform, transform
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isDebugEnabled, isVerbose
public static final java.lang.String name
public static final java.lang.String[] dependencies
public MethodRenamer(Singletons.Global global)
global
- the singletons container. Must not be null
java.lang.NullPointerException
- when global
argument is null
public static MethodRenamer v()
MethodRenamer
public java.lang.String getName()
IJbcoTransform
jbco transformer
implementation.getName
in interface IJbcoTransform
jbco transformer
public java.lang.String[] getDependencies()
IJbcoTransform
jbco transformer
code names on which current transformer depends on.getDependencies
in interface IJbcoTransform
public void outputSummary()
IJbcoTransform
outputSummary
in interface IJbcoTransform
public java.util.Map<java.lang.String,java.lang.String> getRenamingMap(java.lang.String className)
className
- the name of class to get renaming map fornull
protected void internalTransform(java.lang.String phaseName, java.util.Map<java.lang.String,java.lang.String> options)
SceneTransformer
internalTransform
in class SceneTransformer
public java.lang.String getNewName()