Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Load Time Weaving Bug ?

Does compiling aspect1 and aspect2 with -Xreweavable help?

Cheers,
nick
On Jul 1, 2004, at 6:56 AM, David J. Pearce wrote:

Hi,

I've encountered a rather strange problem using the loadtime weaving functionality which causes the following error message:

Test\aspect1.java: error class 'Test.aspect1$myweak' is already woven and has no
t been built with -Xreweavable
trouble in:
Exception in thread "main" Message: error at Test\aspect1.java class 'Test.aspec
t1$myweak' is already woven and has not been built with -Xreweavable
org.aspectj.bridge.AbortException: class 'Test.aspect1$myweak' is already woven
and has not been built with -Xreweavable
at org.aspectj.weaver.tools.WeavingAdaptor$MessageHandler.handleMessage(
WeavingAdaptor.java:266)
        at org.aspectj.weaver.World.showMessage(World.java:258)
...

The example code which I used to generate this is:

-- FILE aspect1.java --
package Test;
aspect aspect1 {
 after() returning(Object newObject)
 : call(*.new(..)) && !within(Test..*) { new myweak(); }
 private class myweak {
  public int tmp() { return 1; }}
}

-- FILE aspect2.java --
package Test;
aspect aspect2 pertarget(allUses()) {
    pointcut allUses() : (call(* *.*(..))) && !within(Test..*);
    before() : allUses() { System.out.println("ASPECT 2 : BEFORE!"); }
}

-- FILE test.java --
class test {
    int data;
    public void fn() { System.out.println("FN CALLED!"); }
    public static void main(String argv[]) {
	test t = new test();
	t.fn();
    }
}

It seems the problem arises from using a nested class within an aspect (class myweak in the example). A few points, I compiled and run the code using this:

c> javac test.java
c> ajc aspect1.java aspect2.java -outjar asp.jar
c> set ASPECTPATH=asp.jar
c> aj test

A few interesting points. Removing the perthis declarations also gets rid of the problem? Also, if the classes are statically woven like so:

c> ajc test.java aspect1.java aspect2.java

then there is no problem. So, any help/opinion regarding this and whether it is actually a bug or not would be appreciated!

Thanks,

David J. Pearce





_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users


Nicholas Lesiecki
Software Craftsman, specializing in J2EE,
Agile Methods, and aspect-oriented programming

Books:
* Mastering AspectJ: http://tinyurl.com/66vf
* Java Tools for Extreme Programming: http://tinyurl.com/66vt

Articles on AspectJ:
* http://tinyurl.com/66vu and http://tinyurl.com/66vv



Back to the top