users@javaee-spec.java.net

[javaee-spec users] [jsr366-experts] Re: Updated Common Annotations spec

From: Antoine Sabot-Durand <antoine_at_sabot-durand.net>
Date: Tue, 14 Jun 2016 09:09:39 +0000

Hi Linda,

The MR proposal is good for CDI expert group.
I only had one remark from the EG (not related to CDI): why not allowing
@Priority on other targets like methods? It could be useful for other use
cases

Antoine

Le jeu. 26 mai 2016 à 22:49, Linda DeMichiel <linda.demichiel_at_oracle.com> a
écrit :

> After a final review of the Common Annotations spec draft and another
> sweep through the Interceptors spec, I noticed that there remained an
> inconsistency among specs as to whether PostConstruct/PreDestroy
> methods can be final.
>
> Here's the situation:
>
> For PostConstruct and PreDestroy methods, the Common Annotations spec
> states "The method MAY be final or non-final, except in the case of
> EJBs where it MUST be non-final."
>
> The Java EE 7 javadocs for PostConstruct and PreDestroy simply state:
> "The method may be final".
>
> The Interceptors spec states that all of the following interceptor
> method types MUST NOT be final:
> AroundInvoke
> AroundTimeout
> lifecycle callback methods (i.e. PostConstruct, PreDestroy,
> AroundConstruct)
>
> The Interceptors spec also forbids classes that declare interceptor
> bindings from containing final methods. This requirement was
> transferred from the CDI specification:
> "If a component class declares or inherits a class-level interceptor
> binding, it must not be declared final, or have any non-static,
> non-private, final methods."
>
> The CDI spec states that proxyable bean types must not have non-private
> final methods.
>
> The Servlet spec explicitly allows PreDestroy methods to be final.
> For PostConstruct, it doesn't state this explicitly, but rather just
> refers to the Common Annotations spec.
>
> To resolve this, I have replaced the relevant statements (as cited
> above) in the PostConstruct/PreDestroy sections of the
> CommonAnnotations spec with the following:
>
> "In general, the method method MUST NOT be final. However, other
> specifications are permitted to relax this requirement on a
> per-component basis."
>
> Similar language needs to be applied to the Interceptors spec for
> lifecycle callback methods. I plan to add this in the Interceptors MR
> that I am preparing.
>
> The Servlet 4.0 spec will need to add an explicit statement that
> PostConstruct methods may be final instead of just the reference to
> the Common Annotations spec.
>
> The javadocs for PostConstruct/PreDestroy have been modified to state
> "the method should not be final".
>
> I've posted updated documents to
> https://java.net/projects/javaee-spec/downloads
>
> -Linda
>