[Soot-list] Loading a class using soot

Ondrej Lhotak olhotak at sable.mcgill.ca
Tue Feb 8 12:46:10 EST 2005


The problem is that because you are not using soot.Main, Soot doesn't
get a chance to load basic classes that it needs for its analyses,
such as subclasses of java.lang.Runnable. You can get around this by
calling Scene.v().loadBasicClasses() yourself. I tried adding this call
immediately after the line "sc.setApplicationClass()" in your code,
and that appears to fix the problem.

Ondrej

On Tue, Feb 08, 2005 at 06:12:19PM +0100, Maxime Van de Reyd wrote:
> Hi, everybody
> 
> I try to Load a java class and to explore the structure created by soot.
> But when I try to get the method body using getActiveBody() I get an
> error when the method contains exception code (it seems to be so, but
> I'm not sure that's the problem)
> 
> To illustrate my problem I attached the class I use to make my tests.
> This class can load and explore itself without problem but when i
> uncomment the code (lines 45->53) i get an Exception [1]
> 
> I use the precompiled jars from soot version 2.2.1 found on [2] and java
> version "1.4.2_01"
> 
> I'd also like to be able to load jimple files. Can it be done from a
> Scene ? I tried with soot.jimple.Parser without success.
> 
> Your help will be greatly appreciated,
> 
> Maxime Van de Reyd
> 
> 
> 
> [1] 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:1005)
>          at
> soot.toolkits.exceptions.ThrowableSet$Manager.v(ThrowableSet.java:274)
>          at
> soot.toolkits.exceptions.PedanticThrowAnalysis.mightThrow(PedanticThrowAnalysis.java:68)
>          at
> soot.toolkits.graph.ExceptionalUnitGraph.buildExceptionDests(ExceptionalUnitGraph.java:342)
>          at
> soot.toolkits.graph.ExceptionalUnitGraph.initialize(ExceptionalUnitGraph.java:262)
>          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 LoadClassFile.showCode(LoadClassFile.java:31)
>          at LoadClassFile.main(LoadClassFile.java:26)
> 
> [2] http://www.sable.mcgill.ca/soot/soot_download.html
> 


> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://www.sable.mcgill.ca/mailman/listinfo/soot-list



More information about the Soot-list mailing list