[Soot-list] Newbie question regarding ExceptionalUnitGraph

mbatch at cs.mcgill.ca mbatch at cs.mcgill.ca
Fri Jan 11 17:21:58 EST 2008


On Fri, January 11, 2008 4:45 pm, Alvin Yan wrote:
> Hello,
>
>
> I wanted to use Soot to generate CFG with exception support. So I did
> this:
>
>
> UnitGraph graph = new ExceptionalUnitGraph(b);
> System.out.println(graph.toString());
>
>
> But I got the following error:
> <test.Test: void <init>()>
> java.lang.NullPointerException at soot.AnySubType.v(AnySubType.java:44) at
> soot.toolkits.exceptions.ThrowableSet$Manager.<init>(ThrowableSet.java:23
> 9)
> 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(PedanticThrowAn
> alysis.java:68)
> at
> soot.toolkits.graph.ExceptionalUnitGraph.getExceptionDests(ExceptionalUni
> tGraph.java:803)
> at
> soot.toolkits.graph.ExceptionalUnitGraph.toString(ExceptionalUnitGraph.ja
> va:918)
> at test.TestSoot.main(TestSoot.java:39)
>
>
> And I traced up, found out
>
>
> resolveClassErrorSet.add(AnySubType.v(Scene.v().getRefType("java.lang.Cla
> ssFormatError")));
>
> at
> soot.toolkits.exceptions.ThrowableSet$Manager.<init>(ThrowableSet.java:23
> 9)
>
>
> might be the problem. Any experiences why this is happening?
>
>
> Alvin Yan

This is undoubtedly one of Soot's famous classloading "bugs". I say bug in
quotes because it isn't a bug at all, but it is a common question on this
list.

Before you build your graph, you need to make sure you make this call:

Scene.v().loadNecessaryClasses();

Which will load all necessary classes, as the method suggests.

And, as yet another reminder to all list participants: I searched google
for the terms "Soot NullPointerException ClassFormatError" and found a
previous discussion on this exact problem (first hit), as well as the
exact solution I just gave.

As our local due-diligence zealot Chris would remind us, it is always good
practice to try and see if the answer to our problem has already been
answered before.

Cheers, and happy weekend!

Michael Batchelder



More information about the Soot-list mailing list