users@ejb-spec.java.net

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

From: Marina Vatkina <marina.vatkina_at_oracle.com>
Date: Mon, 08 Apr 2013 12:19:20 -0400

After another round of an off-line discussions with Mark, the final rule
for the (b) will be:

"Only private methods of the bean class and any superclasses except
java.lang.Object may be declared final."

(this is to avoid questions on the final methods defined on the
Object.class).

-marina

On 4/4/13 3:25 PM, Marina Vatkina wrote:
> Experts,
>
> We need to look at this issue again...
>
> The EJB spec is actually very strict on accessing "other" proxy methods:
>
> 3.4.4 Session Bean’s No-Interface View
>
> "Only public methods of the bean class and of any superclasses except
> java.lang.Object may be invoked through the no-interface view.
> Attempted invocations of methods with any other access modifiers via
> the no-interface view reference must result in the
> javax.ejb.EJBException."
>
> Obviously the container can't verify static or private methods.
>
> With this restriction in mind, I'm changing (b) to:
>
> "Only private methods of the bean class and any superclasses may be
> declared final."
>
> I'll also add both restrictions to the message listener methods with a
> no-methods interface.
>
> Let me know if you see any problems with this change.
>
> thanks,
> -marina
>
> On 3/29/13 1:53 PM, Marina Vatkina wrote:
>> 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
>>>>>>>>>>>>
>>>>>>>>>>>>
>>
>