Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] AspectJ 5 compiler newbei question!




Hi,

Ok ... you are hitting a bug here which is preventing things from working
how you expect them to.  Bug 93356 discusses a problem with varargs and
pointcuts that use '..' which is what you have here.
=> https://bugs.eclipse.org/bugs/show_bug.cgi?id=93356

There is a fix but I haven't integrated it into the codebase yet.

The best way to check whether your pointcuts are matching when working
on the command line is to use the '-showWeaveInfo' option.  That will
produce messages indicating where pointcuts are matching and so where
advice is being applied.

In your case you could just compile:

ajc HelloWorld.java HelloAspect.aj -1.5 -showWeaveInfo

(The 1.5 is required because you are using the 1.5 varargs feature in
your source code).

However, it is also fine to do separate compilation as you have
specified.

Basically the (..) in your pointcut is *not* matching the (String...)
in your method declaration.

I know its unpleasant but if you change your 'sayHello' method to
take a string array and change the pointcut to (String[]) then the
matching works ok and the advice is applied.

Changing to arrays and recompiling, I get:

C:\aspectj1.5.0\>ajc -1.5 *.java *.aj -showWeaveInfo
Type 'HelloWorld' (HelloWorld.java:4) advised by before advice from
'HelloAspect' (HelloAspect.aj:2)
Type 'HelloWorld' (HelloWorld.java:5) advised by before advice from
'HelloAspect' (HelloAspect.aj:2)
Type 'HelloWorld' (HelloWorld.java:6) advised by before advice from
'HelloAspect' (HelloAspect.aj:2)

Andy.
---
Andy Clement
AspectJ Dev




                                                                           
             modber Salamon                                                
             <modber2005@yahoo                                             
             .com>                                                      To 
             Sent by:                  aspectj-users@xxxxxxxxxxx           
             aspectj-users-bou                                          cc 
             nces@xxxxxxxxxxx                                              
                                                                   Subject 
                                       [aspectj-users] AspectJ 5 compiler  
             01/07/2005 15:42          newbei question!                    
                                                                           
                                                                           
             Please respond to                                             
             aspectj-users@ecl                                             
                 ipse.org                                                  
                                                                           
                                                                           




Hello list,
 I am new to aspectj and maybe my question is outdated
but I tried to get info from the net and from the
mailing list from the time aspectj 5 compiler issued..
but no way! the question is simple:

HOW CAN I COMPILE A AN ASPECTJ 5 PROGRAM?

I found that after the announcement of the compiler
Russ has asked a like question.. the reply was:

# javac HelloWorld.java /// java5 compiler
# ajc -inpath . HelloAspect.aj  /// not sure -1.5

well, it compiles, but without weaving, i.e.,
MyClass.java was not changed.. and I have checked that
with cavaj. By the way, only aspectj5 features are not
woven.

can anybody help?
thanx
modber
public class HelloWorld {
    public static void main(String[] args) {

        sayHello("Modi");
        sayHello("Medo", "Aodi", "Aedo");
        sayHello();
    }

    public static void sayHello(String... name) {
             String[] names = name;

             System.out.println("There is " + names.length + "
names.");
             for(int i = 0; i < names.length; i++)
                   System.out.println("Hello, " + names[i] +
"!");
    }

}

public aspect HelloAspect {
  before() : call( * HelloWorld.sayHello(..)) {
    System.out.println("Be ready for the greetings!");
  }
}




____________________________________________________
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
http://football.fantasysports.yahoo.com
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users




Back to the top