[weld-dev] AnnotatedType and the SPI

Pete Muir pmuir at redhat.com
Tue Jan 12 07:10:01 EST 2010


Yeah, I misread your email.

We always merge annotations (I just checked the code for any annotated thing), which IMO is wrong. We should always take the annotations from the Annotated* if it exists.

What we do also do, is take the info from reflection if someone misses out the Annotated{Method,Field,Parameter, Constructor} object from the AnnotatedClass definition. Whilst this does make sense for Methods, Fields and Constructors (omitting them is ok), it doesn't work for parameters (Java requires you to provide all parameters). So IMO it should be an exception to not mirror accurately the class definition in the AnnotatedClass.

https://jira.jboss.org/jira/browse/WELD-371
https://jira.jboss.org/jira/browse/WELD-372

On 12 Jan 2010, at 11:52, Stuart Douglas wrote:

> I will double check then, I just had a quick look so there is a good chance I may have been wrong about the behaviour. The way I read the spec I am not sure if this is the correct behavior, from 11.4:
> 
> The container must use the operations of Annotated and its subinterfaces to discover program element types and annotations,
> instead of directly calling the Java Reflection API. In particular, the container must:
> 
> Which would imply that the container cannot use the reflection API to merge the annotations.
> 
> Stuart
> ________________________________________
> From: Pete Muir [pmuir at redhat.com]
> Sent: Tuesday, 12 January 2010 10:43 PM
> To: Stuart Douglas
> Cc: Weld-Dev
> Subject: Re: [weld-dev] AnnotatedType and the SPI
> 
> On 12 Jan 2010, at 09:46, Stuart Douglas wrote:
> 
>> Does the spec define what should happen if an AnnotatedType added through the SPI is missing a method/field/parameter etc that is present on the underlying class?
>> I had a look but I could not see anything in spec, and as far as I can tell weld is inconsistant with regard to how it treats it. If an AnnotatedParameter is missing it uses the Annotations on the underlying class, however if a field definition is missing it treats it as having no annotations (I have not actually tested this, just has a quick look at the code, so I could be wrong).
> 
> We should *always* merge the annotations from the underlying class with any specified through Annotated*. If Weld does differently, it's a bug :-)
> 
> _______________________________________________
> weld-dev mailing list
> weld-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/weld-dev




More information about the weld-dev mailing list