Using the soot framework (v.2.5.0) I'm trying to load a certain class:
SootClass clazz = Scene.v().loadClassAndSupport("example.MyClass");
Before calling Scene#loadClassAndSupport
the class example.MyClass
is NOT within the scene - which is correct.
The class also doesn't exist on the soot classpath and there the statement above throws a RuntimeException
telling that the class could not be found. And that's also correct behaviour.
But after that exception has been thrown the class example.MyClass
is within soot's scene!
Another call to Scene#loadClassAndSupport
therefore returns a SootClass
instance where isPhantom
is set to false but it doesn't have any methods or fields.
- Is this behaviour intended by the soot framework or is it a bug?
- If it is intended, how can I prevent Soot from adding a "dummy" SootClass to the scene?
- Is there another way to test whether a certain class is within Soot's classpath without adding it to Soot's scene?
Update:
An ugly but working workaround is:
try {
SootClass sootClass = Scene.v().loadClassAndSupport( className );
sootClass.setApplicationClass();
// class found and loaded...
} catch(RuntimeException e) {
SootClass sootClass = Scene.v().loadClassAndSupport( className );
Scene.v().removeClass( sootClass );
// class not on soot's classpath or not loadable...
}