Question

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.

  1. Is this behaviour intended by the soot framework or is it a bug?
  2. If it is intended, how can I prevent Soot from adding a "dummy" SootClass to the scene?
  3. 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...
}
Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top