Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AspectJ » [BUG?] java.lang.VerifyError with @AspectJ annotation (but with print, works!?)
[BUG?] java.lang.VerifyError with @AspectJ annotation (but with print, works!?) [message #483118] Mon, 31 August 2009 07:54 Go to next message
Eclipse UserFriend
Originally posted by: arlindolima.gmail.com

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;Lfig ures/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:

for(Object o: thisJoinPoint.getArgs()) {
System.out.print(o+" ");
}

============================================================ ===
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.
Re: [BUG?] java.lang.VerifyError with @AspectJ annotation (but with print, works!?) [message #483262 is a reply to message #483118] Mon, 31 August 2009 19:24 Go to previous message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 77
Registered: July 2009
Member
As I am sure you've realized, this message has been answered on the mailing
list.


On 31/08/09 12:54 AM, in article
96a93eae2ec3b725c775da5caced79a7$1@www.eclipse.org, "AL"
<arlindolima@gmail.com> wrote:

> 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:
>
> for(Object o: thisJoinPoint.getArgs()) {
> System.out.print(o+" ");
> }
>
> ============================================================ ===
> 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.
>
Re: [BUG?] java.lang.VerifyError with @AspectJ annotation (but with print, works!?) [message #600627 is a reply to message #483118] Mon, 31 August 2009 19:24 Go to previous message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 77
Registered: July 2009
Member
As I am sure you've realized, this message has been answered on the mailing
list.


On 31/08/09 12:54 AM, in article
96a93eae2ec3b725c775da5caced79a7$1@www.eclipse.org, "AL"
<arlindolima@gmail.com> wrote:

> 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:
>
> for(Object o: thisJoinPoint.getArgs()) {
> System.out.print(o+" ");
> }
>
> ============================================================ ===
> 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.
>
Previous Topic:[BUG?] java.lang.VerifyError with @AspectJ annotation (but with print, works!?)
Next Topic:AJDT Advice Marker Configuration for External Jars
Goto Forum:
  


Current Time: Tue Apr 23 06:53:48 GMT 2024

Powered by FUDForum. Page generated in 0.03549 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top