Dne 22.11.2016 v 03:26 John Ament napsal(a):
I looked at your implementation. While its not perfect, it does
work.
It does have one critical flaw. You're assuming how the JDK does
repeatable annotations.
That's a good point.
I did come up with a way that doesn't make this
assumption and is less cumbersome.
I'm afraid your solution will not always work because
Annotated.getBaseType() does not return the annotated element for
methods, fields and parameters. Instead, it returns the type of an
injection point, event parameter, etc.
So we would have to inspect AnnotatedMember.getJavaMember()...
The problem is that the recommended implementation is a compile-time
thing. So in theory, other JDKs can do it differently.
I've raised a PR. I figure we'll have some back and forth on it.
John
------------------------------------------------------------------------
*From:* Martin Kouba <mkouba(a)redhat.com>
*Sent:* Monday, November 21, 2016 9:00 AM
*To:* John Ament; cdi-dev
*Subject:* Re: [cdi-dev] CDI-471 and repeatable annotations
Hi John,
No problem, #4 was optional ;-)
By the way, this is the default implementation from Weld experimental API:
https://github.com/weld/api/blob/master/weld/src/main/java/org/jboss/weld...
It's not perfect. E.g. Class.getMethod() should be used with privileges
enabled if a SecurityManager is used. But it could be a good base to
start with.
Thanks,
Martin
Dne 21.11.2016 v 14:47 John Ament napsal(a):
> Martin,
>
>
> I'll make these changes for #1-#3. I'm not in favor of #4. Its not
> consistent with our existing method. (I'd prefer consistency of our API
> over consistency with the Java lang's spec)
>
>
> I may get to them this evening.
>
>
> John
>
>
>
> ------------------------------------------------------------------------
> *From:* cdi-dev-bounces(a)lists.jboss.org
> <cdi-dev-bounces(a)lists.jboss.org> on behalf of Martin Kouba
> <mkouba(a)redhat.com>
> *Sent:* Monday, November 21, 2016 8:25 AM
> *To:* cdi-dev
> *Subject:* [cdi-dev] CDI-471 and repeatable annotations
>
> Dear EG,
>
> during the review of CDI API 2.0.Alpha5 with modified Annotated SPI [1]
> I came across few questionable parts:
>
> 1. We should be more clear that the original methods like
> Annotated.getAnnotations() or Annotated.isAnnotationPresent() DO NOT
> support repeatable annotations - this is what Reflection API does to
> remain backward compatible - see also AnnotatedElement javadoc [2]
> 2. Thus AnnotatedElement.getAnnotation(Class<T>) should not be
> deprecated - for the same reasons as
> AnnotatedElement.getAnnotation(Class<T>) is not
> 3. We should provide a default implementation of
> Annotated.getAnnotations(Class<T>), otherwise a lot of extensions
> providing their own Annotated implementations would be broken
> 4. We should consider renaming the method to "getAnnotationsByType()" to
> keep it simple for users used to Reflection API
>
> Thanks,
>
> Martin
>
> [1]
>
https://github.com/cdi-spec/cdi/pull/330
<
https://github.com/cdi-spec/cdi/pull/330>
CDI-471 Introduce SPI for retrieving multiple annotations of the same…
by johnament · Pull Request #330 · cdi-spec/cdi
<
https://github.com/cdi-spec/cdi/pull/330>
github.com
… type, deprecating the old one. Updated spec docs for qualifiers to
reflect repeatability and spec docs for annotated for new method.