A simpler model for repeating annotations
michael keith
michael.keith at oracle.com
Mon Jan 7 08:55:36 PST 2013
Thanks for the update, Alex. I like the direction this is going in.
Since the get[Declared]Annotations(Class) methods are semantically
different from the others they do deserve something different in their
names to indicate it. However, given that the javadoc of the lagacy
get[Declared]Annotations() methods state simply "Returns *all*
annotations [directly] present on this element" (emphasis added) I am
not sure that adding "All" to the semantically different
get[Declared]Annotations(Class) pair is going to be a very good
differentiator. Maybe "multiple" could be used in a different way, for
example: get[Declared]AnnotationsWithMultiples?
Also, I was just wondering if the getDeclaredAnnotation(Class) method
will be considered a backfilled "new legacy" method and have similar
semantics to getAnnotation(Class), or will it look through? If it looks
through then it should be renamed as well and we might want to
reconsider what the name of the method variant is.
-Mike
On 02/01/2013 8:46 PM, Alex Buckley wrote:
> Having spent today writing out the expected behavior of core
> reflection methods, I'm sympathetic to the idea that
> get[Declared]Annotations(Class) should be more clearly distinguished.
> I've avoided the term "repeating" in API names since repetition is not
> really the point - the point is multiple applications of the same
> annotation type, but "multiple" has its own downsides since there may
> only be one annotation for the new methods to return. I'd favor
> something more like getAll[Declared]Annotations(Class). Comments welcome.
>
> Alex
>
> On 1/2/2013 7:32 AM, Paul Benedict wrote:
>> BTW, I read something by Remi a few days back that was quite
>> interesting. It was from another thread. He said that correct method
>> overloading is not supposed to change behavior. Given that bit of
>> wisdom, that's why I recommend a renaming here. Behavior is changing,
>> thus a new name should be given.
>>
>> On Wed, Jan 2, 2013 at 9:22 AM, Paul Benedict <pbenedict at apache.org>
>> wrote:
>>> I like the new proposal better. Yet, there's one thing that bothers
>>> me, which is the naming of get[Declared]Annotations(Foo.class). It's
>>> way too easy to look at the API and miss the difference in behavior
>>> here. I propose giving it this name:
>>> get[Declared]RepeatingAnnotations(Foo.class) -- and do the same for
>>> language model's new typed method.
>>>
>>> Paul
More information about the enhanced-metadata-spec-discuss
mailing list