[cdi-dev] Mutable annotation literals

Pete Muir pmuir at redhat.com
Thu Aug 16 07:43:49 EDT 2012


Marko has added caching for the hashcode value on AnnotationLiteral, which is based on the premise that an AnnotationLiteral is not mutable.


This is a reasonable thing to require (as real annotations are normally immutable!) and a very good optimisation, however it is not backwards compatible, as we have not previously required AnnotationLiteral to be immutable.

An alternative option is to introduce the ImmutableAnnotationLiteral subclass, which would require any concrete instances to be immutable and could use this optimisation. We could "deprecate" AnnotationLiteral (as described in java.net/projects/javaee-spec/pages/CompatibilityRequirements).

Note that regardless, we can apply the minor optimisation suggested by Mark, that we return 0 if the annotation has no members.


More information about the cdi-dev mailing list