olamattsson (7) [Avatar] Offline
#1
Hello, when I try to compile the SecurityAspect from listing 2.3 with AspectJ 1.6.3 I get an error message complaining about the semicolon that ends the pointcut secureAccess:
srcajiaSecurityAspect.aj:9 [error] Syntax error on token ";", invalid allowable token in pointcut or type pattern
: execution(* MessageCommunicator.deliver(..));

srcajiaSecurityAspect.aj:11 [error] Syntax error, insert ";" to complete aspect member declaration
before : secureAccess() {

and when I remove the semicolon I get this error:
srcajiaSecurityAspect.aj:11 [error] Syntax error, insert ";" to complete aspect member declaration
before : secureAccess() {

this is how the SecurityAspect.aj file looks like with the semicolon in place:

package ajia;

import ajia.auth.Authenticator;

public aspect SecurityAspect {
private Authenticator authenticator = new Authenticator();

pointcut secureAccess()
: execution(* MessageCommunicator.deliver(..));

before : secureAccess() {
System.out.println("Checking and authenticating user");
authenticator.authenticate();
}
}

Is it the "traditional" syntax that doesn't work with AspectJ 1.6.3 or what?
ramnivas (171) [Avatar] Offline
#2
Re: Problem compiling Listing 2.3
Traditional syntax works fine with AspectJ 1.6.x. There is something else going on here. I wonder if the copied/pasted code from the book ended up introducing some strange characters (has happened to me with ".." and quotes). So you may want to hand type the whole line and see if that fixes it.

BTW, I will be putting the code for all examples in the book along with build scripts when the book goes out.

-Ramnivas