[cdi-dev] [JBoss JIRA] (CDI-318) @WithAnnotations types can appear on any supertype

Martin Kouba (JIRA) jira-events at lists.jboss.org
Mon Dec 9 12:28:06 EST 2013


    [ https://issues.jboss.org/browse/CDI-318?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12929478#comment-12929478 ] 

Martin Kouba edited comment on CDI-318 at 12/9/13 12:26 PM:
------------------------------------------------------------

Actually this is an inconsistency between the spec wording and javadoc.

An example:
{code}
@Target({ TYPE, METHOD, PARAMETER, FIELD, CONSTRUCTOR })
@Retention(RUNTIME)
@Inherited
public @interface Marker {
}
@Marker
public interface Foo {
}
public class Bar implements Foo {
}
{code}
and observer:
{code}
public void observeMarker(@WithAnnotations({ Marker.class }) @Observes ProcessAnnotatedType<?> pat) {
}
{code} 
@WithAnnotations javadoc defines the PAT for Bar should be observed (CDI does not follow JSL rules here) whereas the spec text states CDI should follow JSL rules.
                
      was (Author: mkouba):
    Actually this is not a real issue but rather a hint for clarification.

An example:
{code}
@Target({ TYPE, METHOD, PARAMETER, FIELD, CONSTRUCTOR })
@Retention(RUNTIME)
@Inherited
public @interface Marker {
}
@Marker
public interface Foo {
}
public class Bar implements Foo {
}
{code}
and observer:
{code}
public void observeMarker(@WithAnnotations({ Marker.class }) @Observes ProcessAnnotatedType<?> pat) {
}
{code} 
I think PAT for Bar should be observed because @Marker is inherited (CDI follows JSL rules here). The question is whether this makes sense because "A bean may inherit type-level metadata and members from its superclasses", not superinterfaces.

                  
> @WithAnnotations types can appear on any supertype
> --------------------------------------------------
>
>                 Key: CDI-318
>                 URL: https://issues.jboss.org/browse/CDI-318
>             Project: CDI Specification Issues
>          Issue Type: Clarification
>            Reporter: Martin Kouba
>            Priority: Minor
>              Labels: cdi-1.1-mr
>
> Is this intentional? Supertypes also include interfaces which are not very useful here as beans may inherit type-level metadata and members from superclasses only.
> Is there any special use-case for this?

--
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