[cdi-dev] [JBoss JIRA] (CDI-234) behavior of arrays without @Nonbinding

Jozef Hartinger (JIRA) jira-events at lists.jboss.org
Thu Aug 23 06:15:15 EDT 2012


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

Jozef Hartinger commented on CDI-234:
-------------------------------------

There may be a glitch with the proposed handling of annotation members of qualifiers. Consider this example:

{code:JAVA}
@Qualifier
@Target({ TYPE, METHOD, PARAMETER, FIELD })
@Retention(RUNTIME)
public @interface Language {

    String value();

    @Nonbinding
    String level() default "beginner";
}

@Qualifier
@Target({ TYPE, METHOD, PARAMETER, FIELD })
@Retention(RUNTIME)
public @interface Languages {

    Language[] value();
}

public class LanguageSchool {

    @Produces
    @Languages({ 
        @Language(value = "english", level = "intermediate"), 
        @Language(value = "spanish", level = "beginner") }
    )
    final Person joe = new Person();
}

public class Foo {

    @Inject
    @Languages({
        @Language("english"),
        @Language("spanish")
    })
    Object candidate;
}
{code}

Although the *level* member of the Language qualifier is annotated @Nonbinding it *won't be excluded* from consideration during typesafe resolution if the qualifier is used as a annotation member of another qualifier (@Languages). On the other hand, @Nonbinding will work as expected if applied directly to a bean / injection point.
                
> behavior of arrays without @Nonbinding
> --------------------------------------
>
>                 Key: CDI-234
>                 URL: https://issues.jboss.org/browse/CDI-234
>             Project: CDI Specification Issues
>          Issue Type: Feature Request
>          Components: Concepts
>    Affects Versions: 1.0
>            Reporter: Romain Manni-Bucau
>            Assignee: Pete Muir
>            Priority: Minor
>             Fix For: 1.1.PRD
>
>
> The spec says:
> "Array-valued or annotation-valued members of a qualifier type should be annotated @Nonbinding in a portable application.
> If an array-valued or annotation-valued member of a qualifier type is not annotated @Nonbinding, non-portable behavior
> results."
> The case of arrays without this annotation should be managed to get a better portability. The equality of arrays is determined through "Arrays" helper (http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/annotation/Annotation.html) so i don't think there is any technical issue to consider arrays as a field.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the cdi-dev mailing list