[Soot-list] Bug in XMLPrinter?

Barthelemy Dagenais barthed at hotmail.com
Tue Oct 25 09:39:09 EDT 2005


Hello all,

I tried to create from my application a xml file representing a jimple class 
and I received a NullPointerException. I am not using the soot command line 
tool and I think that is where the problem is. I am using Soot 2.2.2.

Here is my code:

String[] options = { "-cp", classPath, "-f", "xml", "-keep-line-number", 
"-src-prec", "java", "-p", "jb",
					"use-original-names:true", "-output-dir", "c:\\java\\output1","test.B" 
};
System.out.println(Options.v().parse(options));
Scene.v().loadNecessaryClasses();
PackManager.v().runPacks();
Main.v().cmdLineArgs = new String[0];
PackManager.v().writeOutput();
System.out.println("Done!");

Here is the thrown exception:
java.lang.NullPointerException
	at soot.xml.XMLPrinter.printXMLTo(XMLPrinter.java:749)
	at soot.xml.XMLPrinter.printJimpleStyleTo(XMLPrinter.java:899)
	at soot.PackManager.writeClass(PackManager.java:569)
	at soot.PackManager.writeOutput(PackManager.java:325)
	at soot.PackManager.writeOutput(PackManager.java:285)
	at 
ca.uqam.info.slicer.plugin.eclipse.actions.ToJimpleAction.run(ToJimpleAction.java:56)

And here is the line 749 of the XMLPrinter.java:
for (int i = 0; i < Main.v().cmdLineArgs.length; i++) {

I think the problem is that the cmdLineArgs is null here because I am not 
calling soot from the Main class. The workaround I found for now is to 
initialize this public property before calling writeOutput():

Main.v().cmdLineArgs = new String[0];

I do not know if this bug was reported before or if it is a result of bad 
usage of soot. Sorry if that is the case.

Regards,
Barthélémy




More information about the Soot-list mailing list