Re: [abc-users] CastShadowMatch

From: Eric Bodden <eric.bodden_at_mail.mcgill.ca>
Date: Wed, 20 Feb 2008 12:05:48 -0500

Yes, I think this happens because you weave into places where normally
one ought not to be weaving into.

At each statement that is matched, i.e. in your scenario at *any*
statement, abc weaves in some code that...

1.) fetches the current aspect instance (using aspectOf()), and then
2.) executes the advice on that aspect instance.

Point 1.) fails in your scenario because the aspect is tried to
accessed at a point in time where it has not even been initialized
yet.

Eric

On 20/02/2008, Amjad Nusayr <anusayr_at_cs.nmsu.edu> wrote:
> Eric
> Thanks for the reply, but why not I want to see how much my code will
> blow up if I shadow every statement, any way its not working for for I
> tryed the following.
> first in my "AnyStmtShadowMatch#matchesAt" method I checked if the a
> stmt is an instance of a Stmt.
>
> if (!(stmt instanceof Stmt)) return null;
>
> and when that did not work I did the follwing my in AnyStmt.java
>
> protected Residue matchesAt(ShadowMatch sm)
> {
> if (!(sm instanceof StmtShadowMatch)) return NeverMatch.v();
> return AlwaysMatch.v();
> }
>
> if dont know if I have to do something else, but I kept getting the same error in both scenarios, the abc compiled correctly, but when I tried t run my example I got the following exception.
>
> f:\helloworld\p2>java -cp f:\abc\lib\abc-complete.jar;. Hello
>
> Exception in thread "main" java.lang.ExceptionInInitializerError
> at Hello.<clinit>(Hello.java)
> Caused by: org.aspectj.lang.NoAspectBoundException: Exception while initializing
> World: org.aspectj.lang.NoAspectBoundException: World
> at World.aspectOf(World.aj)
> at World.<clinit>(World.aj)
> ... 1 more
> Caused by: org.aspectj.lang.NoAspectBoundException: World
> at World.aspectOf(World.aj)
> at World.<init>(World.aj)
> at World.abc$postClinit(World.aj)
> ... 2 more
>
>
> do you have any idea of what should be done here?
>
> Thanks
> Amjad
>
>
> Eric Bodden wrote:
> > Hi, Amjad.
> >
> > I am not sure if it makes sense to generate a *Cast*ShadowMatch on
> > every statement. This will likely not be successful because later
> > stages in abc actually extract the cast from the CastShadowMatch and
> > if there is none, the code just fails. However, you can certainly
> > generate a new type of shadow match there, let's say an
> > "AnyStmtShadowMatch", subtype of StmtShadowMatch. That should work.
> > Note however, that this will create thousands if not millions of
> > matches for a regular sized program. Certainly when you weave into all
> > these positions, you might certainly have a complexity problem because
> > your code will blow up a lot. Also, a statement in source code is
> > usually represented by multiple Stmts in Jimple, so there is no 1 to 1
> > correspondence - something else to consider.
> >
> > Eric
> >
> > On 15/02/2008, Amjad Nusayr <anusayr_at_cs.nmsu.edu> wrote:
> >
> >> Hi
> >> I was wondering if there is a way to place a shadow on every statement
> >> in the program, I was looking at the CastShadowMatch code and observed
> >> the following
> >>
> >> /Stmt stmt = ((StmtMethodPosition) pos).getStmt();
> >> if (!(stmt instanceof AssignStmt)) return null;
> >> Value rhs = ((AssignStmt) stmt).getRightOp();
> >> if(!(rhs instanceof CastExpr)) return null;
> >> Type cast_to = ((CastExpr) rhs).getCastType();
> >> return new CastShadowMatch(pos.getContainer(), stmt, cast_to);
> >>
> >>
> >> /is it possible to do the following,
> >>
> >> /Stmt stmt = ((StmtMethodPosition) pos).getStmt();
> >> //if (!(stmt instanceof Stmt)) return null; //any statement
> >> //return new CastShadowMatch(pos.getContainer(), stmt, null);
> >>
> >> /I did a couple of tests and was not successful, has anyone got any idea?
> >>
> >> Thanks
> >>
> >> Amjad Nusayr
> >>
> >>
> >>
> >
> >
> >
>
>
>

-- 
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada
Received on Wed Feb 20 2008 - 17:05:53 GMT

This archive was generated by hypermail 2.2.0 : Thu Feb 21 2008 - 09:30:11 GMT