Re: Platform wide guideline for build-in annotation literals?

Bill Shannon

The CDI expert group didn't raise this at the platform level, and they didn't even do this consistently for their annotations, so I'm not clear on what their intent is with these annotation instances.  How would applications use them?  If there's a reason applications need to be able to create annotation instances, wouldn't it be better if it worked the same whether or not the annotation has members?  Maybe this really belongs in the JDK...

Arjan Tijms wrote on 9/19/17 9:00 AM:

Sorry, that's not what I meant ;)

What I meant was that each annotation should of course stay within their respective spec. I.e. @Transactional should of course stay in JTA.

But the annotation literal support should be somewhat mandated by the umbrella spec, so that all specs provide those for their annotations (where applicable) and all specs do it in the same way.

For instance, CDI now has:

RequestScoped requestScopedLiteral = RequestScoped.Literal.INSTANCE;

So JSF should get:

ViewScoped viewScopedLiteral = ViewScoped.Literal.INSTANCE;

And not say:

ViewScoped viewScopedLiteral = ViewScoped.getAnnotation();


ViewScoped viewScopedLiteral = ViewScoped.of(ViewScoped.class);

or ...

ViewScoped should of course stay within JSF and nothing should ever move to the umbrella spec. The umbrella spec should only establish a rule saying that annotation literals are to be done via [annotation class].Literal.INSTANCE;

Hope it's more clear now ;)

Kind regards,
Arjan Tijms


Join to automatically receive all group messages.