[Soot-list] Erroneous array dimensions in Dex output?

Alexandre Bartel alexandre.bartel at uni.lu
Mon Jan 6 05:40:46 EST 2014


Hi Julian,

The jimple code should be something like the following when creating a
String array:

$r1 = newarray (java.lang.String)[0];

When you create a new array in Jimple using newNexArrayExpr, the first
parameter should be the type of the array elements not the type of the
array.

/Alexandre
 
On Sat, 2014-01-04 at 23:37 +0100, Julian Schütte wrote:
> Hi all,
> 
> I am quite new to Soot, so I don't know if I'm running into a bug in
> Soot/dexpler or if I'm doing sth wrong.
> When creating an array of Strings in Soot, Dexpler seems to add one more
> dimension than requested. As creating a 0-dimensional array results in a
> RuntimeException in soot, this prevents me from creating a 1-dimensional
> array in dex.
> 
> Usage:
>    ArrayType arrayType = ArrayType.v(soot.RefType.v("java.lang.String"),
> 1);    // EXPECTING: One-dimensional array String[]
>    Local array = Jimple.v().newLocal("myArray", arrayType);
>    body.getLocals().add(array);
>    NewArrayExpr newArrayExpr = Jimple.v().newNewArrayExpr(arrayType,
> IntConstant.v(0));
>    AssignStmt assignStmt = Jimple.v().newAssignStmt(array, newArrayExpr);
>    generated.add(assignStmt);
>    ...
>    body.getUnits().insertBefore(generated, u);
> 
> Jimple output looks good:
>    myArray = newarray (java.lang.String[])[0];
> 
> Dex output does not look good:
>     new-array v0, v8, [[Ljava/lang/String;     // GOT: Two-dimensional
> array String[][]
>     move-object/from16 v18, v0                  // ??
>     move-object/from16 v0, v18
> 
> 
> Thanks for your help!
> Julian
> 
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list




More information about the Soot-list mailing list