[weld-dev] are AnnotatedType and Co immutable?

Mark Struberg struberg at yahoo.de
Fri Mar 18 05:54:18 EDT 2011


Hmm, I wouldn't argue that way.

The spec _and_ the JavaDocs just say "Returns: all annotations of the program element, or an empty set if no annotations are present" 

There is a hint in the spec which might underline your interpretation: "Any observer of this event is permitted to _wrap_ and/or replace the AnnotatedType". But that sentence doesn't rule out the simple modification.

If they are all immutable, then we should express this explicitly in the CDI-1.1 spec!

LieGrue,
strub

--- On Fri, 3/18/11, Stuart Douglas <stuart.w.douglas at gmail.com> wrote:

> From: Stuart Douglas <stuart.w.douglas at gmail.com>
> Subject: Re: [weld-dev] are AnnotatedType and Co immutable?
> To: "Mark Struberg" <struberg at yahoo.de>
> Cc: "weld-dev at lists.jboss.org" <weld-dev at lists.jboss.org>
> Date: Friday, March 18, 2011, 9:35 AM
> In weld the sets are immutable (or
> defensive copies, can't remember). 
> 
> I don't think that just because the spec does not mention
> immutability that you could expect to modify internal state
> of the annotated type through the set.
> 
> Stuart
> 
> Sent from my iPhone
> 
> On 18/03/2011, at 20:24, Mark Struberg <struberg at yahoo.de>
> wrote:
> 
> > Hi folks!
> > 
> > If I pat(@Observes ProcessAnnotatedType
> annotatedType), is it allowed to simply modify the Sets?
> > 
> > E.g. call 
> > annotatedType.getAnnotations().add(myOwnAnnotation) ?
> > 
> > The spec imo doesn't mention that those Sets are
> immutable, so it should work. It works in OWB at least, but
> what about Weld and CanDI?
> > 
> > txs and LieGrue,
> > strub
> > 
> > 
> > 
> > 
> > 
> > _______________________________________________
> > 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