Execution solves the problem!!
Many thanks.
But, still, shouldn't this be considered a bug? I mean, if I use the
"traditional" aspect notation, everything goes as planned. And the fact that
adding the prints, solves the problem is also weird...
Should I resport a bug?
Thanks.
On Mon, Aug 31, 2009 at 1:01 PM, <[email protected]>wrote:

>  Sorry João,
>
> I have not read your entire post correctly.
>
> Did you try with an “execution” pointcut ( not a call) ?
>
>
>
> Cordialement / Best regards
>
>
>
> *Jean-Louis Pasturel*
>
>   ------------------------------
>
> *De :* [email protected] [mailto:
> [email protected]] *De la part de* João Gonçalves
> *Envoyé :* lundi 31 août 2009 12:58
>
> *À :* [email protected]
> *Objet :* Re: [aspectj-users] [BUG?] java.lang.VerifyError with
> @AspectJannotation (but with a certain call to print, it works!?)
>
>
>
> Unfortunately, that's not the problem. With or without the blank the same
> happens.
>
> Regards.
>
>
>
> On Mon, Aug 31, 2009 at 9:03 AM, <[email protected]>
> wrote:
>
> Perhaps a blank misses in the annoted pointcut :
>
>  @Pointcut("call(public void figures.FigureElement+.move(int, int))"
>
>   +"*<blank>*&& target(fe) && args(dx, dy)")
>
>
>
> Cordialement / Best regards
>
>
>
> *Jean-Louis Pasturel*
>
>
>   ------------------------------
>
> *De :* [email protected] [mailto:
> [email protected]] *De la part de* João Gonçalves
> *Envoyé :* lundi 31 août 2009 09:45
> *À :* [email protected]
> *Objet :* [aspectj-users] [BUG?] java.lang.VerifyError with
> @AspectJannotation (but with a certain call to print, it works!?)
>
>
>
> Hi,
>
> I'm using Eclipse 3.4.1, AspectJ 1.6.5 and AJDT 2.0.0.
>
> I've created a very simple test scenario that utilizes @AspectJ. When
> running a main method in a class or when running a Junit test, I get the
> following error:
>
>
>
> Exception in thread "main" java.lang.VerifyError: (class: figures/Line,
> method: move_aroundBody3$advice signature:
> (Lfigures/Line;Lfigures/Point;IILorg/aspectj/lang/JoinPoint;Lanswers/Answer2h;Lorg/aspectj/lang/ProceedingJoinPoint;Lfigures/FigureElement;II)V)
> Incompatible argument to function
>  at MainTest.main(MainTest.java:24)
>
> Here's the aspect that is causing the error
>
> ===============================================================
>
> Answer2h.java
>
> ===============================================================
>
> package answers;
>
> import org.aspectj.lang.ProceedingJoinPoint;
> import org.aspectj.lang.annotation.*;
> import figures.*;
> import java.awt.Rectangle;
>
> @Aspect
> public class Answer2h {
>  @Pointcut("call(public void figures.FigureElement+.move(int, int))"
>   +"&& target(fe) && args(dx, dy)")
>  void movingFigureElement(FigureElement fe, int dx, int dy) {}
>
>  @Around("movingFigureElement(fe, dx, dy)")
>  public void checkIfBoundsMovedSame(ProceedingJoinPoint thisJoinPoint,
>   FigureElement fe, int dx, int dy) throws Throwable {
>   Rectangle rectangleBefore = new Rectangle(fe.getBounds());
>   thisJoinPoint.proceed(new Object[]{fe, dx, dy});
>   rectangleBefore.translate(dx, dy);
>   if(!rectangleBefore.equals(fe.getBounds()))
>   throw new IllegalStateException("move() invariant violation");
>  }
> }
> ===============================================================
>
> However, strangely, when I had the following 3 lines to my aspect (I was
> just doing debug), everything works normally:
>
> ===============================================================
>
> Answer2h.java (with 3 more lines)
>
> ===============================================================
>
> package answers;
>
> import org.aspectj.lang.ProceedingJoinPoint;
> import org.aspectj.lang.annotation.*;
> import figures.*;
> import java.awt.Rectangle;
>
> @Aspect
> public class Answer2h {
>  @Pointcut("call(public void figures.FigureElement+.move(int, int))"
>   +"&& target(fe) && args(dx, dy)")
>  void movingFigureElement(FigureElement fe, int dx, int dy) {}
>
>  @Around("movingFigureElement(fe, dx, dy)")
>  public void checkIfBoundsMovedSame(ProceedingJoinPoint thisJoinPoint,
>   FigureElement fe, int dx, int dy) throws Throwable {
>   Rectangle rectangleBefore = new Rectangle(fe.getBounds());
>
> *  for(Object o: thisJoinPoint.getArgs()) {
>   System.out.print(o+" ");
>   }
>
> *  thisJoinPoint.proceed(new Object[]{fe, dx, dy});
>   rectangleBefore.translate(dx, dy);
>   if(!rectangleBefore.equals(fe.getBounds()))
>   throw new IllegalStateException("move() invariant violation");
>  }
> }
> ===============================================================
>
> ????
>
> If I use any other print (and comment the privous print), the code
> continues giving the same error...
>
> Examples (that don't work):
>
> // System.out.println("ENTERED");
> // System.out.println("Kind: "+thisJoinPoint.getKind());
> // System.out.println("Signature: "+thisJoinPoint.getSignature());
> // System.out.println("This: "+thisJoinPoint.getThis());
> // System.out.println("Target: "+thisJoinPoint.getTarget());
>
> Another interesting thing (that makes me believe it's some kind of bug).
> The *Answer2h.java *is equivalent to this one:
>
> ===============================================================
>
> Answer2h.aj
>
> ===============================================================
>
>  package answers;
>
> import figures.*;
> import java.awt.Rectangle;
>
> public aspect Answer2h {
>  pointcut movingFigureElement(FigureElement figureElement, int dx, int dy):
>   call(public void figures.FigureElement+.move(int, int)) &&
>   target(figureElement) &&
>   args(dx, dy);
>
>  void around(FigureElement figureElement, int dx, int dy):
>   movingFigureElement(figureElement, dx, dy) {
>   Rectangle rectangleBefore =
>   new Rectangle(figureElement.getBounds());
>   proceed(figureElement, dx, dy);
>   rectangleBefore.translate(dx, dy);
>   if(!rectangleBefore.equals(figureElement.getBounds()))
>   throw new IllegalStateException("move() invariant violation"); }
> }
> ===============================================================
>
> But this latter works!!
>
> Can anyone tell me how to fix this?
>
> Thanks.
>
> Here's the MainTest.java code (not sure if it helps):
>
> ===============================================================
>
> MainTest.java
>
> ===============================================================
>
> import figures.Box;
> import figures.FigureElement;
> import figures.Group;
> import figures.Line;
> import figures.Point;
> import figures.SlothfulPoint;
>
>
> public class MainTest {
>
>  /**
>   * @param args
>   */
>  public static void main(String[] args) {
>   Box bb;
>   Point p1;
>   Point p2;
>   Line l1;
>   SlothfulPoint sloth1;
>   Group g;
>
>   p1 = new Point(10, 100);
>   p2 = new Point(20, 200);
>   l1 = new Line(p1, p2); // line of the error
>   bb = new Box(5, 5, 10, 10);
>   sloth1 = new SlothfulPoint(0, 0);
>   g = new Group(p1);
>
>   FigureElement fe = new SlothfulPoint(10, 10);
>   try {
>   fe.move(10, 10);
>   System.out.println("should have thrown IllegalStateException");
>   } catch (IllegalStateException e) { e.printStackTrace(); }
>
>   p1.move(30, 45);
>   p2.move(10, 33);
>  }
>
> }
>
> ===============================================================
>
> P.S.:
>
> When I use the MainTest.java to lauch the example, inside Answer2h.java I
> have to use this call to proceed:
>
> thisJoinPoint.proceed(new Object[]{fe, dx, dy});
>
> But, when I use the JUnit, the test oly runs if I use :
>
> thisJoinPoint.proceed(new Object[]{fe, fe, dx, dy});
>
> Why? Shouldn't the call be the same? And shouldn't the latter be the
> correct one ({target + 3 parameters})?
>
> Regards.
>
> *********************************
> This message and any attachments (the "message") are confidential and
> intended solely for the addressees.
> Any unauthorised use or dissemination is prohibited.
> Messages are susceptible to alteration.
> France Telecom Group shall not be liable for the message if altered,
> changed or falsified.
> If you are not the intended addressee of this message, please cancel it
> immediately and inform the sender.
> ********************************
>
>
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
>  *********************************
> This message and any attachments (the "message") are confidential and
> intended solely for the addressees.
> Any unauthorised use or dissemination is prohibited.
> Messages are susceptible to alteration.
> France Telecom Group shall not be liable for the message if altered,
> changed or falsified.
> If you are not the intended addressee of this message, please cancel it
> immediately and inform the sender.
> ********************************
>
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to