Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Getting compilation error on a simple aspect

Thanks, I got the error

But the compiler message was really 'NOT' very clear

 

Thanks,

Unmesh

 Thomas Traber <traber@xxxxxxxx> wrote:

Hi Unmesh,

On Thu, Feb 13, 2003 at 10:01:51AM -0800, unmesh joshi wrote:
> Getting compilation error on simple aspect (using Aspectj 1.1 beta);
>
> Log.aj:24: Synta
> x error on token "throwing", "++", "--" expected
> after() throwing (Exception e): visitCall() {
> ^^^^^^^^
>
> Aspect is as follows
>
> aspect Log {
> pointcut visitCall():execution(* visit(..));
>
> static void println(String msg){
> System.out.println(msg);
> }
>
> static private void printParameters(JoinPoint jp) {
> println("Arguments: " );
> Object[] args = jp.getArgs();
> String[] names = ((CodeSignature)jp.getSignature()).getParameterNames();
> Class[] types = ((CodeSignature)jp.getSignature()).getParameterTypes();
> for (int i = 0; i < args.length; i++) {
> println(" " + i + ". " + names[i] +
> " : " + types[i].getName() +
> " = " + args[i]);
> }
>
> after() throwing (Exception e): visitCall() {
> printParameters(thisJoinPoint);
> }
>
> }
>
> }

it seems that you defined the 'after' advice within the static method
printParameters(), but it has to be on the same "level" as that method.
After moving the advice out of the method and adding the imports for
JoinPoint and CodeSignature the aspect should be compilable correctly.

Thomas
--
_ _ _ _ _ Thomas Traber traber@xxxxxxxx
/_\| \/ \/ \| \ Ergon Informatik AG http://www.ergon.ch
\ | \_/\_/| | Baechtoldstrasse 4 voice +41/1/268 89 67
/ 8044 Zuerich, Switzerland fax +41/1/261 27 50
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users



Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day

Back to the top