[Soot-list] Can't find java.lang.Error

Marc Hull (Imperial College) mfh02 at doc.ic.ac.uk
Fri Feb 10 09:48:27 EST 2006


Hi,
I've got some code which examines the concrete methods of a class and 
all superclasses, but it always throws a NullPointerException when 
retrieving the active body of Object.wait(long, int). This can be 
recreated using:

        SootClass sClass = 
Scene.v().loadClassAndSupport("java.lang.Object");
        for (Object o : sClass.getMethods()) {
            SootMethod method = (SootMethod)o;
            if (method.isConcrete()) {
                System.out.println(method.getSignature());
                Body b = method.retrieveActiveBody();   // fails here
            }
        }

It seems to be caused by not being able to resolve java.lang.Error at 
this line in soot.toolkits.exceptions.ThrowableSet.class:

        
initializationErrorSet.add(AnySubType.v(Scene.v().getRefType("java.lang.Error")));

which causes null to be passed to AnySubType.v(..), generating the 
exception at this line:

    public static AnySubType v( RefType base ) {
        if( base.getAnySubType() == null ) {
       ...snip...
    }

This doesn't occur if java.lang.Error is explicitly loaded or is loaded 
by some other class (e.g. by adding 
Scene.v().loadClassAndSupport("java.lang.Error"); to the start of the 
program). Is this a bug or am I missing some initialisation step which 
will load the class automatically?

Best wishes,
Marc

Complete exception:
Exception in thread "main" java.lang.NullPointerException
    at soot.AnySubType.v(AnySubType.java:44)
    at 
soot.toolkits.exceptions.ThrowableSet$Manager.<init>(ThrowableSet.java:263)
    at 
soot.Singletons.soot_toolkits_exceptions_ThrowableSet_Manager(Singletons.java:765)
    at 
soot.toolkits.exceptions.ThrowableSet$Manager.v(ThrowableSet.java:274)
    at 
soot.toolkits.exceptions.PedanticThrowAnalysis.mightThrow(PedanticThrowAnalysis.java:68)
    at 
soot.toolkits.graph.ExceptionalUnitGraph.getExceptionDests(ExceptionalUnitGraph.java:803)
    at 
soot.toolkits.graph.ExceptionalUnitGraph.buildHeadsAndTails(ExceptionalUnitGraph.java:766)
    at 
soot.toolkits.graph.ExceptionalUnitGraph.initialize(ExceptionalUnitGraph.java:283)
    at 
soot.toolkits.graph.ExceptionalUnitGraph.<init>(ExceptionalUnitGraph.java:148)
    at 
soot.toolkits.graph.ExceptionalUnitGraph.<init>(ExceptionalUnitGraph.java:180)
    at 
soot.toolkits.scalar.LocalSplitter.internalTransform(LocalSplitter.java:78)
    at soot.BodyTransformer.transform(BodyTransformer.java:51)
    at soot.Transform.apply(Transform.java:104)
    at soot.JimpleBodyPack.applyPhaseOptions(JimpleBodyPack.java:61)
    at soot.JimpleBodyPack.internalApply(JimpleBodyPack.java:93)
    at soot.Pack.apply(Pack.java:120)
    at soot.coffi.CoffiMethodSource.getBody(CoffiMethodSource.java:115)
    at soot.SootMethod.getBodyFromMethodSource(SootMethod.java:80)
    at soot.SootMethod.retrieveActiveBody(SootMethod.java:304)
    at uk.ac.ic.doc.cuXca.prototypes.soot.SootTest3.main(SootTest3.java:28)




More information about the Soot-list mailing list