[Soot-list] Unnecessary instructions in generated bytecode
Matteo Ceccarello
matteo.ceccarello at gmail.com
Tue Aug 20 06:19:14 EDT 2013
Hi all,
I am using this code to write class files:
|FileNameGenerator.mkDirsForClass(cls, baseDir);
String fileName ="filename";
OutputStream streamOut =new JasminOutputStream(new FileOutputStream(fileName));
PrintWriter writerOut =new PrintWriter(new OutputStreamWriter(streamOut));
JasminClass jasminClass =new JasminClass(cls);
jasminClass.print(writerOut);
writerOut.flush();
streamOut.close();|
Then I decompile the bytecode I obtain with different decompilers.
However I get confused results with almost all of them. This is strange,
since I do not modify the class with Soot once I load it and decompiling
the original class file works just fine.
Looking into the generated bytecode I found out that Soot introduces a
couple of instructions that are not present in the original class: some
|store|s and |load|s.
Just to make an example, this is the original bytecode of
|java.lang.Integer.toHexString| method (printed by javap)
|public static java.lang.String toHexString(int);
Code:
0: iload_0
1: iconst_4
2: invokestatic #5 // Method toUnsignedString:(II)Ljava/lang/String;
5: areturn|
The bytecode that Soot outputs is the following:
|public static java.lang.String toHexString(int);
Code:
0: iload_0
1: iconst_4
2: invokestatic #49 // Method toUnsignedString:(II)Ljava/lang/String;
5: astore_0
6: aload_0
7: areturn|
As you can see there are two instructions more than the original.
Is this a bug? Should I report it to the github issues page?
In the meantime, since this is a problem for me, is there a way to get
the Jasmin bytecode representation in order to remove these instructions?
Cheers
Matteo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20130820/7f5649e5/attachment.html
More information about the Soot-list
mailing list