[Soot-list] ERROR: oops <java.io.FileOutputStream: void <init>(java.lang.String)
Pallavi Majumder
s8pamaju at stud.uni-saarland.de
Fri Jan 13 08:13:10 EST 2017
Hi Bernhard,
I still get the same Run-time Exception:
oops java.io.FileOutputStream: void <init>(java.lang.String)
Any idea why and any roundabouts.
Thanks for all your help,
Pallavi
Quoting Bernhard Berger <berber at tzi.de>:
> Hi Pallavi,
> I haven’t tested it but I think you have to write:
>
> FINAL Jimple jimple = Jimple.v();
> FINAL RefType foStreamType = RefType.v("java.io.FileOutputStream");
> FINAL SootMethod constructor =
> Scene.v().getMethod("java.io.FileOutputStream: void
> <init>(java.lang.String)");
>
> FINAL Local fileLocal = jimple.newLocal("writing", foStreamType);
> body.getLocals().add(fileLocal);
>
> FINAL Stmt assignStmt = jimple.newAssignStmt(fileLocal,
> jimple.newNewExpr(foStreamType));
> FINAL Stmt invokeStmt =
> jimple.newInvokeStmt(jimple.newSpecialInvokeExpr(fileLocal,
> constructor.makeRef(), StringConstant.v("file.txt")));
> units.insertBefore(invokeStmt, stmt);
> units.insertBefore(assignStmt, invokeStmt);
>
>
> Regards, Bernhard
>
>
>> Am 13.01.2017 um 13:16 schrieb Pallavi Majumder
>> <s8pamaju at stud.uni-saarland.de>:
>>
>>
Hi Bernhard,
I am quite new to Soot so this may sound very silly.
If I want to instrument this code:
FileOutputStream writer=new FileOutputStream("file.txt");
The jimple representation is:
java.io.FileOutputStream $r6;
$r6 = new java.io.FileOutputStream;
specialinvoke $r6.<java.io.FileOutputStream: void
<init>(java.lang.String)>("file.txt");
Now to do this I write my code as:
final Local
fileLocal=Jimple.v().newLocal("writing",RefType.v("java.io.FileOutputStream"));
body.getLocals().add(fileLocal);
//What is the code for creating $r6 = new java.io.FileOutputStream;
units .insertBefore(Jimple.v()
.newInvokeStmt(Jimple.v().newSpecialInvokeExpr(fileLocal, Scene.v()
.getMethod("java.io.FileOutputStream: void
<init>(java.lang.String)").makeRef(
StringConstant.v("file.txt"))),stmt);
I am not able to create the "new FileOutputStream", when I create
using newInstanceFieldRef it somehow throws error. Can you tell me
what exactly is the code to use here.
Thanks,
Pallavi
Quoting Bernhard Berger <berber at tzi.de>:
> Hi Pallavi,
>
> is the exception thrown by Soot or by the application you are
> instrumenting? I think you forgot to call the new operator. If you
> take a look at some Jimple code you will see that for object
> creation there will be a JNewExpr (the result will be assigned to
> you local) and afterwards you are going to call the constructor.
>
> Regards, Bernhard
>
>
>> Am 12.01.2017 um 11:41 schrieb Pallavi Majumder
>> <s8pamaju at stud.uni-saarland.de>:
>>
>>
Hi All,
I want to instrument the below code using soot:
PrintStream writing=new PrintStream(new FileOutputStream("file.txt"));
So I thought I'll start with creating the FileOutputStream object first.
Soot Code:
final Local fileLocal=Jimple.v().newLocal("writing",
RefType.v("java.io.FileOutputStream"));
body.getLocals().add(fileLocal);
units
.insertBefore(Jimple.v()
.newInvokeStmt(Jimple.v()
.newSpecialInvokeExpr(fileLocal, Scene.v()
.getMethod("<java.io.FileOutputStream: void
<init>(java.lang.String)").makeRef(),
StringConstant.v("file.txt"))),stmt);
When I run this it gives the exception:
Worker thread execution failed: oops <java.io.FileOutputStream: void
<init>(java.lang.String)
Does anyone know a solution to this?
Thanks,
Pallavi
_______________________________________________
Soot-list mailing list
Soot-list at CS.McGill.CA
https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20170113/f28bf954/attachment.html
More information about the Soot-list
mailing list