users@websocket-spec.java.net

[jsr356-users] [jsr356-experts] Re: Annotation inheritance: was: Re: Potpourri of smaller issues

From: Mark Thomas <mark_at_homeinbox.net>
Date: Sun, 13 Jan 2013 11:09:30 +0000

On 11/01/2013 23:23, Danny Coward wrote:
> On 11/28/12 3:40 PM, Mark Thomas wrote:
>>> 1) What are the inheritance semantics of the websocket annotations ?

<snip/>

>>> > My proposal is that we stick to the guidelines that JSR 250 ( Common
>>> > Annotations for the Java Platform) sets out in
>>> > section 2.1. The layman's version is that subclasses don't inherit any
>>> > of the metadata. Annotations only affect the class (or methods of the
>>> > class) they live on. The semantics start to get very tricky if we
>>> > diverge from those guidelines.
>> That is exactly the opposite of what the Servlet spec does with
>> @HandlesTypes. This would require further filtering of the classes
>> passed to the SCI to ensure they met these stricter requirements.
>>
> Hi Mark,
>
> I meant to follow up on this before public draft but didn't.
>
> My concern with allowing annotated behavior to be inherited is that we'd
> also need to define a set of rules for the inheritance for a variety of
> circumstances, which quickly get complicated, even in relatively simple
> cases.

<snip/>

> In sum, I think its much cleaner to say: annotations have to live on the
> implementation class.

Fair enough.

> In terms of container implementation, are you saying that the infamous
> SCI scan will return any subclasses of a class marked @WebSocketEndpoint
> ?

Yes it will but...

> We do have java.lang.Class. getDeclaredAnnotations() to help out.

+1.

To look at this another way to make sure I understand this, a
@WebSocketEndpoint annotation on an abstract class would be ignored, right?

Mark