<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title></title>
</head>
<body style="font-family:Arial;font-size:14px">
<p>Hi Bernhard,<br>
<br>
I am quite new to Soot so this may sound very silly.&#160;<br>
<br>
If I want to instrument this code:<br>
FileOutputStream writer=new FileOutputStream("file.txt");<br>
<br>
The jimple representation is:<br>
java.io.FileOutputStream $r6;<br>
$r6 = new java.io.FileOutputStream;<br>
specialinvoke $r6.&lt;java.io.FileOutputStream: void &lt;init&gt;(java.lang.String)&gt;("file.txt");<br>
<br>
Now to do this I write my code as:<br>
final Local fileLocal=Jimple.v().newLocal("writing",RefType.v("java.io.FileOutputStream"));<br>
body.getLocals().add(fileLocal);<br>
<br>
//What is the code for creating&#160;$r6 = new java.io.FileOutputStream;</p>
<div>units .insertBefore(Jimple.v() .newInvokeStmt(Jimple.v().newSpecialInvokeExpr(fileLocal, Scene.v() .getMethod("java.io.FileOutputStream: void &lt;init&gt;(java.lang.String)").makeRef( StringConstant.v("file.txt"))),stmt);</div>
<p>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.<br>
<br>
Thanks,<br>
Pallavi<br>
&#160;</p>
<p><br>
<br>
<br>
Quoting Bernhard Berger &lt;<a href="mailto:berber@tzi.de">berber@tzi.de</a>&gt;:</p>
<blockquote style="border-left:2px solid blue;margin-left:2px;padding-left:12px;" type="cite">
<p>Hi Pallavi,</p>
<div>&#160;</div>
<div>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.</div>
<div>&#160;</div>
<div>Regards, Bernhard</div>
<div><br>
<div>
<blockquote type="cite">
<div>Am 12.01.2017 um 11:41 schrieb Pallavi Majumder &lt;<a href="mailto:s8pamaju@stud.uni-saarland.de">s8pamaju@stud.uni-saarland.de</a>&gt;:</div>
<br class="Apple-interchange-newline">
<div>&#160;</div>
</blockquote>
</div>
</div>
</blockquote>
<div style="font-family:Arial;font-size:14px">
<p>Hi All,<br>
<br>
I want to instrument the below code using soot:<br>
<br>
PrintStream writing=new PrintStream(new FileOutputStream("file.txt"));<br>
<br>
So I thought I'll start with creating the FileOutputStream object first.<br>
<br>
Soot Code:</p>
<div>final Local fileLocal=Jimple.v().newLocal("writing",</div>
<div>RefType.v("java.io.FileOutputStream"));<br>
body.getLocals().add(fileLocal);<br>
<div>units</div>
<div>.insertBefore(Jimple.v()</div>
<div>.newInvokeStmt(Jimple.v()</div>
<div>.newSpecialInvokeExpr(fileLocal, Scene.v()</div>
<div>.getMethod("&lt;java.io.FileOutputStream: void &lt;init&gt;(java.lang.String)").makeRef(),</div>
<div>StringConstant.v("file.txt"))),stmt);<br>
<br>
When I run this it gives the exception:<br>
Worker thread execution failed: oops &lt;java.io.FileOutputStream: void &lt;init&gt;(java.lang.String)</div>
</div>
<p><br>
<br>
Does anyone know a solution to this?<br>
<br>
Thanks,<br>
Pallavi</p>
</div>
<p>_______________________________________________<br>
Soot-list mailing list<br>
<a href="mailto:Soot-list@CS.McGill.CA">Soot-list@CS.McGill.CA</a><br>
https://mailman.CS.McGill.CA/mailman/listinfo/soot-list<br>
<br>
<br>
<br></p>
</body>
</html>