users@ejb-spec.java.net

[ejb-spec users] Re: [jsr345-experts] Re: Final methods in a bean class?

From: Mark Struberg <struberg_at_yahoo.de>
Date: Fri, 29 Mar 2013 20:10:55 +0000 (GMT)

Sorry Jeremy, I don't get your sample (might be me).

Lets focus on the question first:


> I may have overlooked something, but does
CDI allow

> non-private non-public methods to be final?

Nope. Every final method (except the ones from Object.class) must be either private or static. At least for all beans we need to proxy - which means all NormalScoped beans. @Dependent scoped bean don't have those restriction for example.


Back to your example:

Using @EJB vs @Inject should not make any difference, isn't? It's an EJB after all, thus I'd say you'll get the interceptor from the EJB container.


Where it might get difficult though is with the following case:

@Stateful @SessionScoped
public class UserInfo {
  ...
}








>________________________________
> From: Jeremy Bauer <jrbauer_at_us.ibm.com>
>To: marina.vatkina_at_oracle.com
>Cc: jsr345-experts_at_ejb-spec.java.net; Pete Muir <pmuir_at_bleepbleep.org.uk>
>Sent: Friday, March 29, 2013 7:42 PM
>Subject: [ejb-spec users] [jsr345-experts] Re: Final methods in a bean class?
>
>
>I may have overlooked something, but does
CDI allow non-private non-public methods to be final?  With the new
rules, couldn't we have this situation?
>
>@Stateless public class MyBean {
>    final void m() { };
>}
>
>public class Other {
>   @EJB MyBean field; // PASS
>   @Inject MyBean field; //
FAIL - unproxyable
>}
>