Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] AJDT and inpath

Alfonso Olias Sanz <aolias@xxxxxxxx> wrote on 20/09/2004 16:01:58:
> I did what you and detailed information about the waving appears but 
> nothing about the external jar file.
> 
> The aspect just pointcuts the execution of a method of a clas in the jar 

> file
> 
> ########################################################
> public aspect AspectHelloWorld {
> 
>      pointcut helloWorldJarFile(): execution (public void 
> HelloWorld.printHelloWorld());
> 
> 
>      void around():helloWorldJarFile(){
>          System.out.println("Hello world from the aspect"); 
>      } 
> 
> }
> #########################################################
> 
> But if I instantiate in a main method the class HelloWorld and calls 
> printHelloWorld, the waving does not catches the execution, but if I 
> change the pointcut definition and put "call" instead of execution, the 
> weaving works.
> 
> The jarfile is added in the "AspectJ InPath" project property

It sounds like you are doing the right things, I can't see why it doesn't 
work for you. Here is what I did:

Created a project with HelloWorld.java in the default package, containing:

public class HelloWorld {
        public void printHelloWorld() {
                System.out.println("Hello World");
        }
 
        public static void main(String[] args) {
                new HelloWorld().printHelloWorld();
        }
}

I then exported this to a JAR file, and created a new AspectJ project 
containing your aspect as above, and turned on weaving messages. I get a 
warning about "no match for this type name: HelloWorld", so I go to the 
project's "AspectJ InPath" property page and add the JAR I exported 
earlier. Rebuilding the AspectJ project then gives me the following line 
in the problem view:

Type 'HelloWorld' (HelloWorld.java:4) advised by around advice from 
'AspectHelloWorld' (AspectHelloWorld.aj:7)

My environment is AJDT 1.1.12, Eclipse 3.0.0, on Windows XP.

Are you doing anything differently to this? Or is your environment 
different? Maybe you've hit a bug.

Regards,

Matt.

-- 
Matt Chapman, mchapman@xxxxxxxxxx
AJDT Development, http://www.eclipse.org/ajdt



Back to the top