[Soot-list] Re: get java source statements from soot

Eric Bodden eric.bodden at mail.mcgill.ca
Mon Aug 18 08:57:52 EDT 2008


You must be doing something wrong, I am just not sure what. The
following class works perfectly fine for me:

/* Soot - a J*va Optimization Framework

 * Copyright (C) 2008 Eric Bodden

 *

 * This library is free software; you can redistribute it and/or

 * modify it under the terms of the GNU Lesser General Public

 * License as published by the Free Software Foundation; either

 * version 2.1 of the License, or (at your option) any later version.

 *

 * This library is distributed in the hope that it will be useful,

 * but WITHOUT ANY WARRANTY; without even the implied warranty of

 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

 * Lesser General Public License for more details.

 *

 * You should have received a copy of the GNU Lesser General Public

 * License along with this library; if not, write to the

 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,

 * Boston, MA 02111-1307, USA.

 */

import java.util.Map;



import soot.Body;

import soot.BodyTransformer;

import soot.G;

import soot.PackManager;

import soot.Transform;



public class MyMain {



	public static void main(String[] args) {

		PackManager.v().getPack("jtp").add(

				new Transform("jtp.myTransform", new BodyTransformer() {



					protected void internalTransform(Body body, String phase, Map options) {

						G.v().out.println("Hello World");

					}

					

				}));

		

		soot.Main.main(args);

	}



}


This prints the following to the shell if invoked with the argument
class "soot.Main" (or any other class):

Soot started on Mon Aug 18 07:56:09 GMT-05:00 2008
Transforming soot.Main...
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Writing to sootOutput/soot/Main.class

Eric

2008/8/17 Gerald Sit <Gerald.Sit at student.cityu.edu.hk>:
> I've tried G.v().out.println(..) but it seems it works like System.out.println(...) without any difference. This will write to the console view in the Soot Eclipse plugin but not the command line for me. The java io libraries like FileWriter no longer works also. What I use before is using soot as libraries to call its APIs and output the results as files without using soot.Main in the command line then it could output the results directly. Now I tried soot.Main in the command line with the TestSoot program having the main method calling soot.Main.main(args) then the output disappeared and no files are outputted. Any clues on that? Thanks again.
>
> Gerald
>
>> I am not quite sure why your output is erased. Usually in Soot the
>> default way to write something to the shell is by using...
>
>> G.v().out.println(..)
>
>> This will write it to the shell by default or to the console view in
>> the Soot Eclipse plugin etc.
>
>> Eric
>



-- 
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada


More information about the Soot-list mailing list