Re: [abc-users] Obtaining SootMethods from PerSetupAdvice

From: Eric Bodden <eric.bodden_at_mail.mcgill.ca>
Date: Wed, 14 May 2008 11:14:51 -0400

> That unfortunately doesn't work - I just get a RuntimeException saying
> the method couldn't be found, regardless of the classes in question.
> If it helps, I'm analysing the Spacewar example distributed with
> AspectJ - the final GameSynchronisation.jimple file certainly does
> have a abc$perThisBind method, but when I use this technique, it only
> finds three methods in the GameSynchronisation class - <init>,
> aspectOf and hasAspect.

Hmm, it might be the case that the method is only generated during weaving.

>
> I added the setApplicationClass() and loadClass methods at your
> previous suggestion ;) Without them I get a
> polyglot.util.InternalCompilerError exception: "Anonymous classes
> cannot have names" when I try and convert an AbcClass to a SootClass.
> Here's the snippet of code I'm using:
>
> List<SootMethod> methods = new ArrayList<SootMethod>();
> Iterator<AbcClass> classes =
> abc.main.Main.v().getAbcExtension().getGlobalAspectInfo().getWeavableClasses().iterator();
>
> while (classes.hasNext()) {
> AbcClass abccl = classes.next();
> SootClass scl = abccl.getSootClass();
>
> scl.setApplicationClass();
> Scene.v().loadClass(scl.getName(), SootClass.BODIES);
>
> Iterator<SootMethod> methodsit =
> Scene.v().getSootClass(scl.getName()).getMethods().iterator();
>
> // Previously using this:
> // Iterator<SootMethod> methodsit = scl.getMethods().iterator();
>
> while (methodsit.hasNext()) { ... etc.

Ah that's probably also because you do your analysis prior to weaving.
I think classes are fully resolved as the first step *within* the
weaver. So you are right, before weaving you might need this extra
code. Hmm, I am not sure what to do in your case. Do you have to
execute your stuff before weaving? Otherwise you could use a
ReweavingAnalysis, which is probably more convenient.

Eric

-- 
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada
Received on Wed May 14 2008 - 16:14:54 BST

This archive was generated by hypermail 2.2.0 : Wed May 14 2008 - 22:30:10 BST