Package soot.toDex
Class DexArrayInitDetector
- java.lang.Object
-
- soot.toDex.DexArrayInitDetector
-
public class DexArrayInitDetector extends Object
Detector class that identifies array initializations and packs them into a single instruction: a = new char[2]; a[0] = 42; a[1] = 3; In dex, this can be expressed in a more concise way: a = new char[2]; fill(a, ...)- Author:
- Steven Arzt
-
-
Constructor Summary
Constructors Constructor Description DexArrayInitDetector()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconstructArrayInitializations(Body body)Constructs packed array initializations from the individual element assignments in the given bodyvoidfixTraps(Body activeBody)Fixes the traps in the given body to account for assignments to individual array elements being replaced by a single fill instruction.Set<Unit>getIgnoreUnits()List<Value>getValuesForArrayInit(Unit arrayInit)voidsetMinimumArrayLength(int l)Sets the minimum array length to consider Only arrays with more than this number of elements will be identified, because we only need to handle those explicitly.
-
-
-
Method Detail
-
constructArrayInitializations
public void constructArrayInitializations(Body body)
Constructs packed array initializations from the individual element assignments in the given body- Parameters:
body- The body in which to look for element assignments
-
setMinimumArrayLength
public void setMinimumArrayLength(int l)
Sets the minimum array length to consider Only arrays with more than this number of elements will be identified, because we only need to handle those explicitly. For small arrays, we can have individual assignments for each element in the code, but for larger methods, this would exceed the allowed method size according to the JVM / Dalvik Spec.- Parameters:
l- the minimum length of arrays
-
fixTraps
public void fixTraps(Body activeBody)
Fixes the traps in the given body to account for assignments to individual array elements being replaced by a single fill instruction. If a trap starts or ends in the middle of the replaced instructions, we have to move the trap.- Parameters:
activeBody- The body in which to fix the traps
-
-