[Soot-list] Adding a class to scene/hierarchy

Derek White whitedw at gmail.com
Wed Mar 30 23:45:31 EDT 2011


Hello all,

I have a program that needs to find subclasses of a class that has
been encountered while walking the body of a method, even if the
subclasses are not loaded into the Soot scene when Soot is loaded
initially.  My approach is to use the class loader and class/jar files
to find any classes that belong to the same package as the class (in
my case it is guaranteed that any subclasses will be in that same
package).  Once I have discovered that set of classes, I want to add
them to the scene and hierarchy in order to call something like
Hierarchy's getSubclassesOf method to find which of those classes in
the package are the subclasses I am looking for.

If I just try Scene.v().addBasicClass(className) or
Scene.v().addBasicClass(className, SootClass.HIERARCHY), className is
not listed as a subclass by the active hierarchy's
getSubclassesOf(base) even though it should be

If I try something like:

            Scene.v().tryLoadClass(className, SootClass.HIERARCHY) or
Scene.v().tryLoadClass(className, SootClass.BODIES)

I get:

java.lang.RuntimeException: This operation requires resolving level
SIGNATURES but tests.B is at resolving level HIERARCHY
If you are extending Soot, try to add the following call before
calling soot.Main.main(..):
Scene.v().addBasicClass(tests.B,SIGNATURES);


Any help would be appreciated.  Thanks in advance.

-Derek


More information about the Soot-list mailing list