Bug 259416 - parameter annotation binding
Summary: parameter annotation binding
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows Vista
: P3 enhancement with 6 votes (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-19 16:14 EST by Andrew Clement CLA
Modified: 2016-12-04 09:09 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Clement CLA 2008-12-19 16:14:02 EST
Currently it is possible to match on parameter annotations:

execution(* *(@SomeAnno (*),..))

but you cannot bind them directly in the syntax.  You are forced to write some nasty code to go digging for them on the method that matches.

I'm thinking about this new possibility:

before(SomeAnno anno): execution(* *(..)) && @args(anno (*)) {}

the extra parentheses in @args do the same as in the execution syntax, enabling the annotation to be treated as on the parameter rather than on the type of the parameter.

// binding the type annotation and the param annotation
before(SomeAnno anno,TypeAnno anno2): execution(* *(..)) && @args(anno (anno2)) {}
Comment 1 Alexander Kriegisch CLA 2016-08-06 06:36:57 EDT
Hi Andy.

I think this feature is something people have been waiting for since AspectJ 1.6.0, see for example:

http://stackoverflow.com/a/38802836/1082681

http://stackoverflow.com/a/16624766/1082681

http://stackoverflow.com/a/23952001/1082681

Do you have any plans to implement this soon? Please consider this as an upvote. ;-)
Comment 2 Andrew Clement CLA 2016-08-08 15:12:01 EDT
I'll take a closer look when I get a minute. I really appreciate you providing feedback - I know you jump on the stackoverflow questions for AspectJ and providing feedback through bugzilla to me on how I can help those users is great.

The Java9 upgrade is messier than I thought/hoped so that will take a bunch of cycles. On an unrelated note - but also perhaps on the TODO list - I've been thinking/experimenting with weaving lambda generated methods so that I can catch calls/executions of methods being supplied by lambdas (eg. Runnable.run(..)) rather than anonymous inner classes.
Comment 3 Andrew Clement CLA 2016-12-02 13:36:15 EST
I started some work on this it is in the paramAnnotationBinding branch in git. It is much more involved than I initially anticipated and perhaps most importantly requires a change to the serialized form of the aspect. When this happens you usually trigger a chain of bug reports where people are using an old weaver with a new compiler. When these changes occur you need to use the newest weaver if you are using the newest compiler. For that reason I might wait and resurrect this for 1.9 rather than trying to get it into 1.8.10. it is currently working with the proposed syntax (some testcases are passing).
Comment 4 Alexander Kriegisch CLA 2016-12-04 09:09:26 EST
For me personally that would not be a problem, I always try using the latest compiler and weaver anyway. I do understand that it would not make life easier for less experienced users, though, especially when using AspectJ Maven plugin and being unaware of the possibility (and necessity, in this case) to override the plugin's dependencies.

Whenever this will become part of an actual AspectJ release, I would be willing to test a snapshot if you can provide binaries. (I am kind of reluctant to build AspectJ myself because I do not like or understand Ant, being a Maven user.)

Thank you, Andy.