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.
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...
}
This looks like a bug. Can you please file it here? We will then take a look. https://github.com/Sable/soot/issues
This is the better place to discuss such issues anyway.
Cheers, Eric