[cdi-dev] CDI-471 and repeatable annotations

Martin Kouba mkouba at redhat.com
Mon Nov 21 09:00:46 EST 2016


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/experimental/ExperimentalAnnotated.java

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 at lists.jboss.org
> <cdi-dev-bounces at lists.jboss.org> on behalf of Martin Kouba
> <mkouba at 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.
>
>
>
>
> [2]
> https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/AnnotatedElement.html
>
> AnnotatedElement (Java Platform SE 8 ) - Oracle
> <https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/AnnotatedElement.html>
> docs.oracle.com
> Represents an annotated element of the program currently running in this
> VM. This interface allows annotations to be read reflectively. All
> annotations returned by ...
>
>
>
> _______________________________________________
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/cdi-dev
> cdi-dev Info Page - JBoss Developer
> <https://lists.jboss.org/mailman/listinfo/cdi-dev>
> lists.jboss.org
> List to discuss the development of CDI (the specification) To see the
> collection of prior postings to the list, visit the cdi-dev Archives.
>


More information about the cdi-dev mailing list