[cdi-dev] [JBoss JIRA] (CDI-298) @WithAnnotations needs to consider annotations on superclasses

Jozef Hartinger (JIRA) jira-events at lists.jboss.org
Mon Jan 28 06:58:47 EST 2013

     [ https://issues.jboss.org/browse/CDI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jozef Hartinger reopened CDI-298:

Reopening for the following issue to be considered.

An AnnotatedType does not provide information about a superclass of the type. Instead, it provides a merged view of the type structure. As a result, some annotations defined on a superclass or its members may be accessed using the AnnotatedType (e.g. an annotation defined on a field of a superclass or a type-level annotation with @Inherited meta annotation) whereas others cannot (a type-level annotation without @Inherited).

The first consequence is that a ProcessAnnotatedType event observer with @WithAnnotation(Foo.class) may be notified of an AnnotatedType even when the @Foo cannot be seen using AnnotatedType methods (e.g. Foo is a non-inherited annotation defined on a superclass of the type)

The more serious consequence is related to synthetic annotated types. When an AnnotatedType is registered via BeforeBeanDiscovery.addAnnotatedType(), the CDI implementation only works with the merged view of the type hierarchy and cannot therefore examine the annotations on superclasses. Using reflection would be a mistake since the AnnotatedType overrides reflection metadata. Operating only on annotations available via AnnotatedType methods would create an inconsistency between how implicit and synthetic AnnotatedTypes are treated.

I think the solution would be to redefine @WithAnnotations behavior to only match those annotations accessible via AnnotatedType methods.
> @WithAnnotations needs to consider annotations on superclasses
> --------------------------------------------------------------
>                 Key: CDI-298
>                 URL: https://issues.jboss.org/browse/CDI-298
>             Project: CDI Specification Issues
>          Issue Type: Bug
>            Reporter: Pete Muir
>            Assignee: Pete Muir
>            Priority: Minor
>              Labels: with-annotations
>             Fix For: 1.1.PFD
> The wording current prohibits this, it's a mistake in the wording.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

More information about the cdi-dev mailing list