concurrency icon indicating copy to clipboard operation
concurrency copied to clipboard

Missing annotation literal in @Asynchronous annotation

Open arjantijms opened this issue 3 years ago • 5 comments

It's general a good practice to add annotation literals to annotations that are used in CDI environments. We forgot these for the Faces 2.3 spec, and got quite a bit of feedback about those.

We added them in 4.0 as per e.g. this example:

https://github.com/eclipse-ee4j/mojarra/blob/master/impl/src/main/java/jakarta/faces/annotation/ApplicationMap.java#L52

Would be good for Concurrency to do the same.

arjantijms avatar Feb 14 '22 16:02 arjantijms

What's the thinking behind it? Would be good to know to understand whether to push to get in this release?

smillidge avatar Feb 15 '22 13:02 smillidge

Annotation literals are essential when adding annotations programmatically to beans in CDI. This is the exact reason why all CDI's own annotations (where applicable) have literals.

Omission of literals in annotations is still one of the reasons why the programmatic API in CDI feels sub-par, hence why, in principle, all annotations intended to be used in a CDI environment should have them.

arjantijms avatar Feb 17 '22 12:02 arjantijms

Adding the annotation programmatically seems like a more obscure scenario for @Asynchronous given that the asynchronous method implementation really ought to have awareness of itself being used as an asynchronous method. (It must follow specific patterns in terms of either returning a completion stage that is different from the one the caller receives or otherwise obtaining the resulting completion stage from the Asynchronous API itself which will only ever work if running as an asynchronous method). I'd be fine to add the literal for these cases, but it doesn't seem like a necessity for 3.0, and is something that could be added on in 3.1.

njr-11 avatar Feb 17 '22 14:02 njr-11

Adding the annotation programmatically seems like a more obscure scenario for @Asynchronous given that the asynchronous method implementation really ought to have awareness of itself being used as an asynchronous method.

I hear you, though it's perhaps less obscure for when you translate between the give or take 7 existing @Asynchronous annotations.

arjantijms avatar Feb 17 '22 17:02 arjantijms

p.s. annotation literals are not just for adding them programmatically, you also use them for look-ups.

arjantijms avatar Feb 17 '22 17:02 arjantijms