Re: [abc-users] InterprocConstantPropagator throws IndexOutOfBoundsException when Advice does not apply

From: Thomas Pawlitzki <mailinglist_at_pawlitzki.name>
Date: Wed, 30 Apr 2008 15:28:10 +0200

Hello again,

I think I found the location, where the Jimple locals are created:

  // Declared in AdviceCodegen.jrag at line 353
  public void jimplify2()
  {
    JimpleBody body = Jimple.v().newBody(proceedMethod());
    proceedMethod().setActiveBody(body);
    Body b = new Body(hostType(), body, this);
    jimplify2(b); // <-------- HERE
    b.add(Jimple.v().newReturnVoidStmt());
  }

By jimplify2 the Parameters for normal formal parameters and also for
implicit parameters (as thisJoinPoint) are local created.

Please add this simple advice to an aspect and try to compile it with
"-ext abc.ja". It should provoke the IndexOutOfBoundsExcpetion:

        void around(java.io.PrintStream a) : call(* System.*(..)) && args(a)
&& if(false) {
                System.out.println("\taround - TESTING - "+thisJoinPoint);
                proceed(System.out);
                System.out.println("\taround - TESTING - "+thisJoinPoint);
        }

Regards,
Thomas

2008/4/30 Thomas Pawlitzki <mailinglist_at_pawlitzki.name>:
> Hello Pavel,
>
>
> > > The Problem is that when an advice which is modified by my compiler
> > > extension is passed to the findUsedArguments method it contains only
> > > one parameterType
> > > [java.lang.String]
> > > but 2 IdentityStmt
> > > [test := @parameter0: java.lang.String, thisJoinPoint := @parameter1:
> > > org.aspectj.lang.JoinPoint, return]
> > >
> > > So the result[boolean] has only length 1 but accessed is result[0] and
> > > result[1].
>
>
> > Could you give us some more details regarding where the method in question
> > comes from? Is it one that abc generates, or is it added by your extension?
>
> The method which provokes the Exception is
> <aspects.PrinterAspect: void proceed$0(java.lang.String)>
>
> and is generated from my advice
>
> void around(Printing p) {
> System.out.println();
> System.out.println("\t-------------------------------------------");
> System.out.println("\t*** before Printing *** "+thisJoinPoint);
> System.out.println("\tp.test="+p.test);
> System.out.println("\tClass of Joinpoint : "+p.getClass());
> System.out.println("\tSignature :
> "+thisJoinPoint.getSignature());
> System.out.println("\t-------------------------------------------");
>
> proceed(p);
>
> System.out.println("\t-------------------------------------------");
> System.out.println("\t*** after Printing *** "+thisJoinPoint);
> System.out.println("\t-------------------------------------------");
> System.out.println();
> }
>
> This advice has no pointcut as I set this pointut during compilation
> to all pointcuts of the joinpoint Printing (which is the argument).
> If there is no pointcut for Printing, i create the never matching
> pointcut mentioned above. This I have to do as the advice defines a
> formal parameter. If this parameter is not be bound via this(),
> target() or args() an error is generated during checking the AST.
>
> In addition to manipulating the pointcut expression of the advice I
> add a statement to the advice body. But i do this in the frontend
> before the jimple code is generated.
>
> Greetings,
> Thomas
>
Received on Wed Apr 30 2008 - 14:28:14 BST

This archive was generated by hypermail 2.2.0 : Wed Apr 30 2008 - 15:10:11 BST