[Soot-list] Soot unable to load class

Steven Arzt Steven.Arzt at cased.de
Tue Jun 23 04:21:55 EDT 2015


Hi Pegah,

 

Your Soot initialization is wrong. Before you can load any custom classes, you first need to load the basic ones using Scene.v().loadNecessaryClasses(). Additionally, force-resolving classes is not the preferred way to make sure that a class gets loaded. If you want to do it all manually (see below for a better way), you should use Scene.v().addBasicClass(…) before you call Scene.v().loadNecessaryClasses().

 

If you just need a unit graph, it might be easier to simply register a transformer and then all Soot’s main method which will perform the required initializations for you. For examples on how to use Soot in a more standard way, you can refer to the tutorials in our blog: http://sseblog.ec-spride.de/tutorials/  The tutorial refers to instrumentation, but for the basics it does not matter whether you want to change or just read out the data from your target program.

 

Best regards,

  Steven

 

Von: soot-list-bounces at CS.McGill.CA [mailto:soot-list-bounces at CS.McGill.CA] Im Auftrag von Pegah Jandaghi
Gesendet: Dienstag, 23. Juni 2015 00:38
An: Soot-list at CS.McGill.CA
Betreff: [Soot-list] Soot unable to load class

 

Hi everyone

 

I'm trying to create Unit graph for classes of a java library. I use the following code for building this graph:

 

String sep = File.separator;

String pathSep = File.pathSeparator;

String path =System.getProperty("java.home") + sep + "lib" + sep + "rt.jar" pathSep;

path += System.getProperty("java.home") + sep+"lib" + sep + "jce.jar";

path  += pathSep + classPath;

 

Options.v().set_soot_classpath(path);

Options.v().set_keep_line_number(true);

Options.v().setPhaseOption("jb", "use-original-names:true");

SootClass sClass = Scene.v().forceResolve(className, SootClass.BODIES);

sClass.setApplicationClass();

Scene.v().allowsPhantomRefs(); 

 

sClass.getMethodByName(methodName).retrieveActiveBody();

Body body = sootMethod.retrieveActiveBody();

UnitGraph graph = new EnhancedUnitGraph(body);

 

 

This code works for some classes but gives following exception on on line "SootClass sClass = Scene.v().forceResolve(className, SootClass.BODIES);"

for some other classes. 

 

 

Exception in thread "main" soot.CompilationDeathException: there were errors during parsing and/or type checking (JastAdd frontend)

at soot.JastAddInitialResolver.formAst(JastAddInitialResolver.java:63)

at soot.JavaClassSource.resolve(JavaClassSource.java:54)

at soot.SootResolver.bringToHierarchy(SootResolver.java:215)

at soot.SootResolver.processResolveWorklist(SootResolver.java:155)

at soot.SootResolver.resolveClass(SootResolver.java:124)

at soot.Scene.forceResolve(Scene.java:1279)

at automatic.main(automatic.java:69)

 

 

Does anyone knows why this gives exception for some classes?

 

Thanks for help

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20150623/e2cd2eca/attachment.html 


More information about the Soot-list mailing list