[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Matching varargs with subtypes: call(* *.*(Object+...))

the signature within the call()/execution() should match the declared signature of the method, so it ought to be fine with ... (methods are tagged in bytecode that they ended with varargs, so the info is not lost during compilation).

There are bugs with arrays and + which may even be part of the problem here:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=148508

Andy.

2009/2/18 Dave Whittaker <dave@xxxxxxxxxx>
My understanding on varargs is that they are converted to an array during compilation, since AspectJ matches against the binary class file, would:


call(* IPersistenceServices+.*(Object+[])) && args(varargs)

Possibly work?


On Feb 18, 2009, at 11:13 AM, Andy Clement wrote:

Please raise a bug and I'll look into it - what you are looking to do seems reasonable.

Andy.

2009/2/18 Meyer, Yang <Yang.Meyer@xxxxxxxxxxxx>
Hi,


I want to advise certain methods with an arbitrary number of formal parameters which have arbitrary types.


My advice calls a method foo(…) that runs in another JVM, so I cannot use proceed(…); therefore I use reflection to invoke the method originally called. I am trying to use AspectJ's varargs support to pass the arguments (all of them!) on to foo(…), like this:


void around(Object[] varargs) :

                       call(* IPersistenceServices+.*(Object+...)) && args(varargs) {

     System.out.println("Advice got woven!");

     myServer.foo(varargs);

}


Note the underlined part. This syntax (Object+…) seems to be in accordance with the grammar described in the AspectJ/ADK 1.5 Notebook:

http://www.eclipse.org/aspectj/doc/released/adk15notebook/annotations-pointcuts-and-advice.html#signaturePatterns

(MethodPattern => FormalsPattern => TypePattern '…' => SimpleTypePattern)


However, the Eclipse IDE complains about a syntax error, and my aspect isn't woven. I am using the 1.6.1 runtime with Equinox Aspects.


Of course I could only match on (Object...), i.e. without the plus, but that would mean constraining all methods that I want to advise to declare an (Object...) formal parameter, instead of e.g. (String...) or (MyType...) However this would really be subpar, so it'd be great to have something like the pointcut above.


Is the "TypeName+…" syntax and behavior simply not supported, or am I just doing it wrong?


Thanks for any clarification or suggestions,

Yang


_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users