[Soot-list] Problem to start with Soot

Marc-André Laverdière-Papineau marc-andre.laverdiere-papineau at polymtl.ca
Thu Jul 17 08:09:28 EDT 2014


Hi Suzanne,

I don't see you setting the soot class path. That would the first thing to try :-)
-- 
Marc-André Laverdière-Papineau
Doctorant - PhD Candidate
Sent from my Android device with K-9 Mail. Please excuse my brevity.

On July 15, 2014 3:42:58 PM GMT+05:30, Susanne Koch <Susanne_Koch91 at web.de> wrote:
>Hello everybody,
>
> 
>
>I try to make a easy transformation from a class-file (Hello World) to
>a Jimple-file. It is implemented after the creat class-tutorial.
>
>My problem is, when I want to run it with soot (command line), I get
>this RuntumeException:
>
>Attempt to create RefType containing a / -->
>../../../workspace/SootUse1
>
>  at soot.RefType.<init>(RefType.java:53)
>
>  at soot.RefType.<init>(RefType.java:68)
>
>  at soot.SootClass.<init>(SootClass.java:87)
>
>  at soot.SootClass.<init>(SootClass.java:101)
>
>  at soot.SootResolver.makeClassFer/SootResolver.java:108)
>
>and so on...
>
> 
>
>I don't understand, what the problem is. Can somebody help me please?
>
> 
>
>Your sincerely
>
>S. Koch
>
> 
>
>This is my code:
>
> 
>
>import java.io.FileOutputStream;
>import java.io.IOException;
>import java.io.OutputStream;
>import java.io.OutputStreamWriter;
>import java.io.PrintWriter;
>import java.util.Arrays;
>import soot.*;
>import soot.jimple.*;
>import soot.options.Options;
>import soot.util.Chain;
>
>public class Ausf {
>
>    public void main(String[] args) throws IOException {
>
>        Scene.v().loadClassAndSupport("java.lang.Object");
>        Scene.v().loadClassAndSupport("java.lang.System");
>
>        SootClass sClass;
>        SootMethod method;
>
>        sClass = new SootClass("HelloWorld", Modifier.PUBLIC);
>      sClass.setSuperclass(Scene.v().getSootClass("java.lang.Object"));
>        Scene.v().addClass(sClass);
>
>method = new SootMethod("main", Arrays.asList(new Type[] { ArrayType.v(
>                RefType.v("java.lang.String"), 1) }), VoidType.v(),
>                Modifier.PUBLIC | Modifier.STATIC);
>        sClass.addMethod(method);
>
>        {
>
>            JimpleBody body = Jimple.v().newBody(method);
>            method.setActiveBody(body);
>            Chain<Unit> units = body.getUnits();
>            Local arg, tmpRef;
>
>            arg = Jimple.v().newLocal("l0",
>                    ArrayType.v(RefType.v("java.lang.String"), 1));
>            body.getLocals().add(arg);
>
>            tmpRef = Jimple.v().newLocal("tmpRef",
>                    RefType.v("java.io.PrintStream"));
>            body.getLocals().add(tmpRef);
>
>            units.add(Jimple.v().newIdentityStmt(
>                    arg,
>                    Jimple.v().newParameterRef(
>                   ArrayType.v(RefType.v("java.lang.String"), 1), 0)));
>            {
>SootMethod toCall = Scene.v().getMethod("<java.io.PrintStream: void
>println(java.lang.String)>");
>                units.add(Jimple.v().newInvokeStmt(
>               Jimple.v().newVirtualInvokeExpr(tmpRef,toCall.makeRef(),
>                                StringConstant.v("Hello world!"))));
>                units.add(Jimple.v().newReturnVoidStmt());
>            }
>
>String fileName = SourceLocator.v().getFileNameFor(sClass,
>Options.output_format_jimple);
>               OutputStream streamOut = new FileOutputStream(fileName);
>                    PrintWriter writerOut = new PrintWriter(
>                    new OutputStreamWriter(streamOut));
>                    Printer.v().printTo(sClass, writerOut);
>                    writerOut.flush();
>                    streamOut.close();
>
>        }
>    }
>}
>
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Soot-list mailing list
>Soot-list at CS.McGill.CA
>https://mailman.CS.McGill.CA/mailman/listinfo/soot-list



More information about the Soot-list mailing list