Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AspectJ » HelloWorld with a twist
HelloWorld with a twist [message #585303] Sun, 19 December 2004 23:25
Eclipse UserFriend
Originally posted by: sekar.gopinathan.fhlbny.com

Hi,

I used the eclipse AJDT tutorial to create a HelloWorld application and it
worked great. I added one more advice in addition to the after() advice
and it goes something like
public aspect World {
pointcut greeting() : execution(* HelloWorld.sayHello(..));
before() : greeting() {
System.out.println("After Hello");
}
after() : greeting() {
System.out.println("After Hello");
}
}
and my HelloWorld is the same as the one in the tutorial except for the
output "Hello from HelloWorld" in sayHello() method.

Now I wanted to make the aspect a library that HelloWorld project can use.
So I created a HelloAspect project and moved the World.aj aspect into
that project. Both projects are Aspect projects. Now in the
HelloAspect project, I set the output variable in AspectJ properties to
hello.jar(as per the article by Adrian in one of the posts in
Aspectprogrammer.org.a very good one that) Also, in the HelloWorld
project, I set the AspectJ aspect path to hello.jar in the HelloAspect
project. I noticed that I could see the markers in my java editor
(although the tool tip showed the jar file ie., hello.jar). So now I
compiled and run the program once again I got the output as expected i.e.,
"Before Hello"
"Hello from HelloWorld"
"After Hello"

Once I got this I decided to remove the after() advice in the World.aj
and saved it and run the program once again to ensure that my changes to
the aspect reflect on my code. I got an error, like
After Hello
Hello from HelloWorld...
java.lang.NoSuchMethodError:
myPackage.World.ajc$after$myPackage_World$2$f69f5afa()V
at myPackage.HelloWorld.sayHello(HelloWorld.java:28)
at myPackage.HelloWorld.main(HelloWorld.java:22)
Exception in thread "main"
so I put that advice back in and removed the before() advice and did the
same again. Now I got the following error.
java.lang.NoSuchMethodError:
myPackage.World.ajc$after$myPackage_World$2$f69f5afa()V
at myPackage.HelloWorld.sayHello(HelloWorld.java:28)
at myPackage.HelloWorld.main(HelloWorld.java:22)
My initial guess was that the HelloWorld projet is not in the "inpath" of
HelloAspect project. So I put the HellWorld/bin directory in the "inpath"
of HelloAspect project. Right after I hit ok I got a problem in my task
list and it read something like
"class 'myPackage.HelloWorld' is already woven and has not been built with
-Xreweavable". That's how far I could go with this.
Does anyone know how to keep aspects as a library in one project and be
able to weave the changes in aspect to the code in another project? I
think I may be missing something here.
Any "advice" appreciated. My apologies if I am doing something really
stupid and annoying you all...:)

Signing off
lost():withing(aspects)...:)
Previous Topic:Visualizer
Next Topic:HelloWorld with a twist
Goto Forum:
  


Current Time: Thu Apr 25 04:13:15 GMT 2024

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

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

Back to the top