users@ejb-spec.java.net

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

From: Marina Vatkina <marina.vatkina_at_oracle.com>
Date: Wed, 27 Mar 2013 13:35:17 -0700

On 3/27/13 1:15 PM, Mark Struberg wrote:
> removing (b) completely will create proxying issues, isn't?
>
>
> It's just not possible to override a public final method in the subclass used for the proxies.

Right. If they are final, they can't be overridden, so they shouldn't be
part of the no-interface view...
> Thus those methods will create broken proxies.
>
> consider the bean
> public @Stateless class User {
> private String name;
>
> public String getName() { return name; };
> public final setName(String name) {this.name = name;}
> }
>
> and
>
> @EJB User u;
>
> calling u.setName("Hans"); would just set the 'name' field of the proxy and not the name of the pooled instance!

If a proxy is a subclass, it'd be a direct call, not through the proxy.
>
>
>
> The rule is a bit too strict though. It should only prohibit final methods until they are static or private. Final private and static methods are perfectly fine as theycannot get proxied anyway...

That's true.

Best,
-marina

>
>
> LieGrue,
> strub
>
> PS: thanks for all the hard work on the EJB spec ;)
>
>
>
> ----- Original Message -----
>> From: Marina Vatkina <marina.vatkina_at_oracle.com>
>> To: jsr345-experts_at_ejb-spec.java.net
>> Cc:
>> Sent: Wednesday, March 27, 2013 7:36 PM
>> Subject: [ejb-spec users] [jsr345-experts] Final methods in a bean class?
>>
>> 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
>>