[Soot-list] CuncurrentModificationException

Bashar Al Rawi brawi at umich.edu
Wed Aug 20 13:24:51 EDT 2008


Thanks. I tried it. But, I am always getting this:
Soot started on Wed Aug 20 13:23:14 EDT 2008
Exception in thread "main" java.lang.RuntimeException: couldn't find class:
javax.crypto.Cipher (is your soot-class-path set properly?)
    at soot.SootResolver.bringToHierarchy(SootResolver.java:139)
    at soot.SootResolver.bringToSignatures(SootResolver.java:172)
    at soot.SootResolver.bringToBodies(SootResolver.java:214)
    at soot.SootResolver.processResolveWorklist(SootResolver.java:100)
    at soot.SootResolver.resolveClass(SootResolver.java:89)
    at soot.Scene.tryLoadClass(Scene.java:305)
    at soot.Scene.loadBasicClasses(Scene.java:855)
    at soot.Scene.loadNecessaryClasses(Scene.java:881)
    at soot.Main.run(Main.java:170)
    at soot.Main.main(Main.java:146)
    at tracer.instrument.Main.main(Main.java:21)

I tried a bunch of things and I am pretty sure javax.crypto.Cipher is in the
class-path.

On Wed, Aug 20, 2008 at 12:09 PM, Eric Bodden <eric.bodden at mail.mcgill.ca>wrote:

> wjtp is a whole-program pack. Therefore you have to use Soot's -w
> option to enable this pack.
>
> Eric
>
> 2008/8/20 Bashar Al Rawi <brawi at umich.edu>:
> > So, I have created this class:
> >
> > public class ClassTransformer extends SceneTransformer {
> >     private ClassTransformer() {
> >     }
> >
> >     public static ClassTransformer v() {
> >         return instance;
> >     }
> >
> >     protected void internalTransform(String arg0, Map arg1) {
> >         // TODO Auto-generated method stub
> >         System.out.println("SSSSSSSSSSSSS");
> >         Iterator it =
> Scene.v().getApplicationClasses().snapshotIterator();
> >
> >         while(it.hasNext()){
> >             SootClass sc = (SootClass) it.next();
> >             System.out.println(sc);
> >             instrumentSelfRef(sc);
> >             System.out.println(sc.getMethods());
> >         }
> >     }
> > }
> >
> > and in my main method, I have added the following:
> >
> > PackManager.v().getPack("wjtp").add(
> >                 new Transform("wjtp.ClassTransformer",
> > ClassTransformer.v()));
> >
> > I get the following output:
> > Transforming tracer.benchmarks.MyThread...
> > Transforming tracer.benchmarks.Toy1...
> > Writing to sootOutput\tracer\benchmarks\MyThread.class
> > Writing to sootOutput\tracer\benchmarks\Toy1.class
> >
> > So, basically it does not NOT print out the "SSSSSSSSSSSSSSSS", which
> means
> > it never executes internalTransform. But, when I add the line:
> > ClassTransformer.v().transform(); it works. Can you tell me why
> > "internalTransform" is not called when I add it to "wjtp"?
> >
> >
> > Many thanks.
> >
> >
> > On Wed, Aug 20, 2008 at 10:05 AM, Bashar Al Rawi <brawi at umich.edu>
> wrote:
> >>
> >> Thanks a lot. I will try it out and see what happens.
> >>
> >> On Wed, Aug 20, 2008 at 9:38 AM, Eric Bodden <
> eric.bodden at mail.mcgill.ca>
> >> wrote:
> >>>
> >>> Soto calls a BodyTransformer in a loop, executing it for each body
> >>> (each one that has a body, that is) of each application class. You
> >>> modify the list of methods *while* this iteration happens. This is
> >>> forbidden.
> >>>
> >>> The solution is to use a SceneTransformer instead, stick it in the
> >>> wjtp pack, and then do this iteration manually in your code. Make sure
> >>> that when you iterate over a class you actually iterate over a *copy*
> >>> of the list of the methods in that class so that you can modify the
> >>> actual list of methods concurrently.
> >>>
> >>> Eric
> >>>
> >>> 2008/8/20 Bashar Al Rawi <brawi at umich.edu>:
> >>> > public class Instrumenter extends BodyTransformer {
> >>> >
> >>> >     private boolean isObjectInstrumented = false;
> >>> >     private Set<SootClass> selfRefObjSet = new HashSet<SootClass>();
> >>> >     private static Instrumenter instance = new Instrumenter();
> >>> >
> >>> >     private Instrumenter() {
> >>> >     }
> >>> >
> >>> >     public static Instrumenter v() {
> >>> >         return instance;
> >>> >     }
> >>> >
> >>> > private SootClass getTopNonLibClass(SootClass s){
> >>> >         if(!selfRefObjSet.contains(s))
> >>> >             selfRefObjSet.add(s);
> >>> >         System.out.println("CURRENT CLASS: " + s);
> >>> >         if(s.getSuperclass().isLibraryClass())
> >>> >             return s;
> >>> >         return getTopNonLibClass(s.getSuperclass());
> >>> >     }
> >>> >
> >>> >     private void instrumentSelfRef(SootClass sc) {
> >>> >         if (implementsSelfRef(sc))
> >>> >             return;
> >>> >         SootClass c = getTopNonLibClass(sc);
> >>> >         System.out.println("Top Non-Lib Class = " + c);
> >>> >         SootField objVar = new SootField("thisRef", RefType
> >>> >                 .v("tracer.util.ObjVar"), Modifier.PUBLIC);
> >>> >         c.addField(objVar);
> >>> >         SootClass selfRefInterface = null;
> >>> >         if (!Scene.v().containsClass("tracer.util.SelfRef")) {
> >>> >             selfRefInterface = new SootClass("tracer.util.SelfRef",
> >>> >                     Modifier.PUBLIC | Modifier.INTERFACE);
> >>> >         } else {
> >>> >             selfRefInterface =
> >>> > Scene.v().getSootClass("tracer.util.SelfRef");
> >>> >         }
> >>> >         assert selfRefInterface.isInterface();
> >>> >         c.addInterface(selfRefInterface);
> >>> >         SootMethod m = new SootMethod("getSelfRef",
> >>> >                 Arrays.asList(VoidType.v()),
> >>> > RefType.v("tracer.util.ObjVar"),
> >>> >                 Modifier.PUBLIC);
> >>> >         c.addMethod(m);   //
> >>> > -------------------------------------------------------> If I remove
> >>> > this
> >>> > statement, everything works fine
> >>> >
> >>> >     }
> >>> >     private void instrumentClasses(){
> >>> >         Iterator it =
> >>> > Scene.v().getApplicationClasses().snapshotIterator();
> >>> >         while(it.hasNext()){
> >>> >
> >>> >             SootClass c = (SootClass) it.next();
> >>> >             instrumentSelfRef(c);
> >>> >             System.out.println(c.getMethods());
> >>> >         }
> >>> >     }
> >>> >     protected void internalTransform(Body body, String pn, Map map) {
> >>> >         System.out.println(Scene.v().getApplicationClasses());
> >>> >         if(!isObjectInstrumented){
> >>> >             isObjectInstrumented = true;
> >>> >             instrumentClasses();
> >>> >         }
> >>> >
> >>> >
> >>> >         instrumentStmt(body);
> >>> >
> >>> >     }
> >>> > }
> >>> >
> >>> >
> >>> > Here is the output I got:
> >>> >
> >>> > Transforming tracer.benchmarks.Toy1...
> >>> > [tracer.benchmarks.Toy1, tracer.benchmarks.MyThread]
> >>> > CURRENT CLASS: tracer.benchmarks.Toy1
> >>> > Top Non-Lib Class = tracer.benchmarks.Toy1
> >>> > [<tracer.benchmarks.Toy1: void <init>()>, <tracer.benchmarks.Toy1:
> void
> >>> > main(java.lang.String[])>, <tracer.benchmarks.Toy1:
> tracer.util.ObjVar
> >>> > getSelfRef(void)>]
> >>> > CURRENT CLASS: tracer.benchmarks.MyThread
> >>> > Top Non-Lib Class = tracer.benchmarks.MyThread
> >>> > [<tracer.benchmarks.MyThread: void <init>()>,
> >>> > <tracer.benchmarks.MyThread:
> >>> > void run()>, <tracer.benchmarks.MyThread: int getX()>,
> >>> > <tracer.benchmarks.MyThread: tracer.util.ObjVar getSelfRef(void)>]
> >>> > method: <init>
> >>> > r0 := @this: tracer.benchmarks.Toy1
> >>> > Identity: r0 := @this: tracer.benchmarks.Toy1
> >>> > specialinvoke r0.<java.lang.Object: void <init>()>()
> >>> > return
> >>> > Exception in thread "main" java.util.ConcurrentModificationException
> >>> >     at java.util.AbstractList$Itr.checkForComodification(Unknown
> >>> > Source)
> >>> >     at java.util.AbstractList$Itr.next(Unknown Source)
> >>> >     at soot.PackManager.runBodyPacks(PackManager.java:735)
> >>> >     at soot.PackManager.runBodyPacks(PackManager.java:451)
> >>> >     at soot.PackManager.runBodyPacks(PackManager.java:370)
> >>> >     at soot.PackManager.runPacks(PackManager.java:347)
> >>> >     at soot.Main.run(Main.java:203)
> >>> >     at soot.Main.main(Main.java:146)
> >>> >     at tracer.instrument.Instrumenter.main(Instrumenter.java:675)
> >>> >
> >>> >
> >>> > Thanks a lot in advance.
> >>> >
> >>> >
> >>> >
> >>> > On Tue, Aug 19, 2008 at 11:21 PM, Richard L. Halpert
> >>> > <richardlhalpert at gmail.com> wrote:
> >>> >>
> >>> >> Your explanation of the problem is rather vague.  Please send code.
> >>> >>
> >>> >> -Richard
> >>> >>
> >>> >> On Tue, Aug 19, 2008 at 5:31 PM, Bashar Al Rawi <brawi at umich.edu>
> >>> >> wrote:
> >>> >>>
> >>> >>> Hi,
> >>> >>>
> >>> >>> I am trying to add modify a class file by overwriting the
> >>> >>> internalTransform method. However, whenever I add a new method to
> the
> >>> >>> class,
> >>> >>> I get java.util.ConcurrentModificationException. I tried using
> >>> >>> snapshotIterator, but its not working. Can you please tell me wat's
> >>> >>> happening?
> >>> >>>
> >>> >>> Thanks
> >>> >>>
> >>> >>> --
> >>> >>> Bashar
> >>> >>>
> >>> >>>
> >>> >>> _______________________________________________
> >>> >>> Soot-list mailing list
> >>> >>> Soot-list at sable.mcgill.ca
> >>> >>> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
> >>> >>>
> >>> >>
> >>> >
> >>> >
> >>> >
> >>> > --
> >>> > Bashar
> >>> >
> >>> > _______________________________________________
> >>> > Soot-list mailing list
> >>> > Soot-list at sable.mcgill.ca
> >>> > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
> >>> >
> >>> >
> >>>
> >>>
> >>>
> >>> --
> >>> Eric Bodden
> >>> Sable Research Group
> >>> McGill University, Montréal, Canada
> >>
> >>
> >>
> >> --
> >> Bashar
> >
> >
> >
> > --
> > Bashar
> >
>
>
>
> --
> Eric Bodden
> Sable Research Group
> McGill University, Montréal, Canada
>



-- 
Bashar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20080820/75c476cb/attachment-0001.htm


More information about the Soot-list mailing list