[Soot-list] Help!! Analysis a class with throws statement

Eric Bodden eric.bodden at ec-spride.de
Fri Mar 16 04:13:42 EDT 2012


Hi.

You are not using Soot in the right way.

Instead of what you are doing now, simply insert a new body
transformer into the "jtp" pack and then call soot.Main.main(args).
This has been discussed on this list numerous times by now, so please
browse the archives for details.

The error should then just go away because Soot automatically does the
right things when being called that way.

Eric

On 15 March 2012 23:38, hxj <hxj163 at gmail.com> wrote:
> Dear developer,
>
> I have a class with a throw exception statement:
>
> package testers;
>
> public class test1  {
>
>     public void test1(int a) {
>             if (a==0) {
>               throw new IllegalArgumentException("avcde");
>             }
>     }
> }
>
>
> And I want to analysis each statement in this class. So I created a simple
> class:
>
> public class RunIt
> {
>     public static void main(String[] args) {
>         args = new String[] {"testers.test1"};
>         SootClass sClass = Scene.v().loadClassAndSupport(args[0]);
>         sClass.setApplicationClass();
>
>         Iterator methodIt = sClass.getMethods().iterator();
>         while (methodIt.hasNext()) {
>             SootMethod m = (SootMethod)methodIt.next();
>
>             Body b = m.retrieveActiveBody();
>             UnitGraph g = new ExceptionalUnitGraph(b);
>
>             Iterator unitIt = g.iterator();
>             while (unitIt.hasNext()) {
>                      Unit s = (Unit) unitIt.next();
>                      Stmt tmp = (Stmt) s;
>                      System.out.println(tmp.toString());
>             }
>         }
>     }
> }
>
> Then I got the following exception:
>
> Exception in thread "main" java.lang.IllegalStateException: RefType
> java.lang.ArithmeticException not loaded. If you tried to get the RefType of
> a library class, did you call loadNecessaryClasses()? Otherwise please check
> Soot's classpath.
>     at soot.Scene.getRefType(Scene.java:444)
>     at
> soot.toolkits.exceptions.ThrowableSet$Manager.<init>(ThrowableSet.java:193)
>     at
> soot.Singletons.soot_toolkits_exceptions_ThrowableSet_Manager(Singletons.java:765)
>     at
> soot.toolkits.exceptions.ThrowableSet$Manager.v(ThrowableSet.java:275)
>     at
> soot.toolkits.exceptions.PedanticThrowAnalysis.mightThrow(PedanticThrowAnalysis.java:67)
>     at
> soot.toolkits.graph.ExceptionalUnitGraph.buildExceptionDests(ExceptionalUnitGraph.java:342)
>     at
> soot.toolkits.graph.ExceptionalUnitGraph.initialize(ExceptionalUnitGraph.java:263)
>     at
> soot.toolkits.graph.ExceptionalUnitGraph.<init>(ExceptionalUnitGraph.java:149)
>     at
> soot.toolkits.graph.ExceptionalUnitGraph.<init>(ExceptionalUnitGraph.java:181)
>     at
> soot.toolkits.scalar.LocalSplitter.internalTransform(LocalSplitter.java:77)
>     at soot.BodyTransformer.transform(BodyTransformer.java:51)
>     at soot.Transform.apply(Transform.java:104)
>     at soot.JimpleBodyPack.applyPhaseOptions(JimpleBodyPack.java:57)
>     at soot.JimpleBodyPack.internalApply(JimpleBodyPack.java:89)
>     at soot.Pack.apply(Pack.java:124)
>     at soot.coffi.CoffiMethodSource.getBody(CoffiMethodSource.java:117)
>     at soot.SootMethod.getBodyFromMethodSource(SootMethod.java:82)
>     at soot.SootMethod.retrieveActiveBody(SootMethod.java:315)
>     at dk.brics.soot.RunIt.main(RunIt.java:22)
>
>
> I know this RunIt class could be used to print out all of statements in a
> class without throws statement. But I don't know how to change the code to
> analysis a class with throws. So I need your help!
>
> Thanks very much!
>
> Best regards,
> Eve
>
>
>
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>



-- 
Eric Bodden, Ph.D., http://bodden.de/
Head of Secure Software Engineering Group at EC SPRIDE
Principal Investigator in Secure Services at CASED
Tel: +49 6151 16-75422    Fax: +49 6151 16-72051
Room 3.2.14, Mornewegstr. 30, 64293 Darmstadt


More information about the Soot-list mailing list