[cdi-dev] Fwd: [jsr345-experts] Final methods in a bean class?

Pete Muir pmuir at bleepbleep.org.uk
Tue Apr 2 10:57:29 EDT 2013


FYI

https://issues.jboss.org/browse/CDI-362

Begin forwarded message:

> From: Marina Vatkina <marina.vatkina at oracle.com>
> Subject: Re: [jsr345-experts] Re: Final methods in a bean class?
> Date: 29 March 2013 20:53:01 GMT
> To: Pete Muir <pmuir at bleepbleep.org.uk>
> Cc: jsr345-experts at ejb-spec.java.net, Jeremy Bauer <jrbauer at us.ibm.com>
> Reply-To: marina.vatkina at oracle.com
> 
> On 3/29/13 1:39 PM, Pete Muir wrote:
>> Note this is only a problem for session beans with a no-interface view.
> 
> Correct. This is what we are looking at.
>> 
>> We could clean this up in the CDI spec probably, by adjusting the proxyability requirements to be identical to EJB for no-interface session views.
>> 
>> Worth doing?
> 
> Yes. Please.
> 
> -marina
> 
>> 
>> On 29 Mar 2013, at 19:57, Marina Vatkina <marina.vatkina at oracle.com> wrote:
>> 
>>> On 3/29/13 12:45 PM, Pete Muir wrote:
>>>> On 29 Mar 2013, at 18:42, Jeremy Bauer <jrbauer at us.ibm.com> wrote:
>>>> 
>>>>> I may have overlooked something, but does CDI allow non-private non-public methods to be final?
>>>> No. Not *if* a proxy is required.
>>> If the EJB container created the proxy, it won't include the non-public methods. Even if the CDI spec allows more, a compliant EJB container won't intercept on those...
>>> 
>>> -marina
>>>>>  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
>>>>> }
>>>>> 
>>>>> 
>>>>> -Jeremy
>>>>> 
>>>>> 
>>>>> 
>>>>> From:        Marina Vatkina <marina.vatkina at oracle.com>
>>>>> To:        jsr345-experts at ejb-spec.java.net,
>>>>> Cc:        Pete Muir <pmuir at bleepbleep.org.uk>, Jeremy Bauer/Rochester/IBM at IBMUS
>>>>> Date:        03/28/2013 02:06 PM
>>>>> Subject:        [jsr345-experts] Re: Final methods in a bean class?
>>>>> 
>>>>> 
>>>>> 
>>>>> So we are just catching up with the CDI spec ;)
>>>>> 
>>>>> Thanks Pete.
>>>>> 
>>>>> -marina
>>>>> 
>>>>> On 3/28/13 11:21 AM, Pete Muir wrote:
>>>>>> Static methods were never considered as a block to proxability.
>>>>>> 
>>>>>> On 28 Mar 2013, at 18:20, Marina Vatkina <marina.vatkina at oracle.com> wrote:
>>>>>> 
>>>>>>> How about static methods?
>>>>>>> 
>>>>>>> thanks,
>>>>>>> -marina
>>>>>>> 
>>>>>>> On 3/28/13 11:12 AM, Pete Muir wrote:
>>>>>>>> We updated the requirements in CDI to specifically exclude private methods from proxability requirements. Note we moved this to it's own section - 3.15
>>>>>>>> 
>>>>>>>> Pete
>>>>>>>> 
>>>>>>>> On 28 Mar 2013, at 17:16, Marina Vatkina <marina.vatkina at oracle.com> wrote:
>>>>>>>> 
>>>>>>>>> Well, Pete is on this list (and I'm cc-ing him here explicitly), but I don't think private final (or static final) methods should be restricted...
>>>>>>>>> 
>>>>>>>>> -marina
>>>>>>>>> 
>>>>>>>>> On 3/28/13 9:30 AM, Jeremy Bauer wrote:
>>>>>>>>>> Hi Marina,
>>>>>>>>>> 
>>>>>>>>>> Won't allowing final methods will cause an inconsistency with the CDI spec?  CDI 1.0 section 5.4.1 says:
>>>>>>>>>> 
>>>>>>>>>> Certain legal bean types cannot be proxied by the container:
>>>>>>>>>> [...]
>>>>>>>>>>                  • classes which are declared final or have final methods,
>>>>>>>>>> 
>>>>>>>>>> And I believe this is true in CDI 1.1, but I don't have that spec handy.
>>>>>>>>>> 
>>>>>>>>>> -Jeremy
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> From:        Marina Vatkina <marina.vatkina at oracle.com>
>>>>>>>>>> To:        jsr345-experts at ejb-spec.java.net,
>>>>>>>>>> Date:        03/27/2013 06:21 PM
>>>>>>>>>> Subject:        [jsr345-experts] Re: Final methods in a bean class?
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> After a longer discussion with Mark offline and not to allow users to
>>>>>>>>>> shoot themselves into a foot, the new proposal is to change both
>>>>>>>>>> statements as follow:
>>>>>>>>>> 
>>>>>>>>>> (a) "All non-static public methods of the bean class and of any
>>>>>>>>>> superclasses except the java.lang.Object, are exposed as business methods."
>>>>>>>>>> 
>>>>>>>>>> (b) "Business methods exposed through the no-interface view must not be
>>>>>>>>>> declared final."
>>>>>>>>>> 
>>>>>>>>>> Let me know if anybody disagrees.
>>>>>>>>>> 
>>>>>>>>>> thanks,
>>>>>>>>>> -marina
>>>>>>>>>> 
>>>>>>>>>> On 3/27/13 11:36 AM, Marina Vatkina wrote:
>>>>>>>>>>> Experts,
>>>>>>>>>>> 
>>>>>>>>>>> The EJB spec currently requires that if a bean exposes a no-interface
>>>>>>>>>>> view (see 4.9.8 Session Bean’s No-Interface View):
>>>>>>>>>>> 
>>>>>>>>>>> (a) "All public methods of the bean class and of any superclasses
>>>>>>>>>>> except the java.lang.Object, are exposed as business methods through
>>>>>>>>>>> the no-interface view."
>>>>>>>>>>> (b) "All methods of the bean class and any superclasses must not be
>>>>>>>>>>> declared final."
>>>>>>>>>>> 
>>>>>>>>>>> For all other views the rules for a *business method* is
>>>>>>>>>>> "The method must not be declared as final or static."
>>>>>>>>>>> 
>>>>>>>>>>> Does any of you see a problem with removing the rule (b) and changing
>>>>>>>>>>> the rule (a) to:
>>>>>>>>>>> 
>>>>>>>>>>> "All non-final non-static public methods of the bean class and of any
>>>>>>>>>>> superclasses except the java.lang.Object, are exposed as business
>>>>>>>>>>> methods through the no-interface view."
>>>>>>>>>>> 
>>>>>>>>>>> thanks,
>>>>>>>>>>> -marina
>>>>>>>>>>> 
>>>>>>>>>>> 
> 




More information about the cdi-dev mailing list