Description
While having multiple annotations of the same type declared on a member or type is not permitted in the Java language prior to Java 8, the CDI specification does not set any particular restriction in its SPI that enables to alter bean metadata, e.g. in Annotated.getAnnotations() and BeanAttributes.getQualifiers(), in a way to add multiple annotations of the same type.
Having multiple CDI qualifiers of the same type can prove to be useful when this type declares binding attributes.
Unfortunately, in such situation, the following exception is thrown by OWB version 2.0-SNASHOT:
javax.enterprise.inject.spi.DefinitionException: java.lang.IllegalArgumentException: Manager.resolveDecorators() method parameter qualifiers array argument can not define duplicate qualifier annotation with name : @org.apache.camel.cdi.ContextName at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:284) at org.apache.webbeans.lifecycle.AbstractLifeCycle.bootstrapApplication(AbstractLifeCycle.java:138) at org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(AbstractLifeCycle.java:104) at org.apache.webbeans.arquillian.standalone.OwbStandaloneContainer.deploy(OwbStandaloneContainer.java:122)
IMO, preventing the ability to add multiple annotations of the same type via the CDI SPI restricts powerful use cases (I can share more details on these use cases if needed). Last but not least, having this ability built-in in the Java 8 language is another incentive to provide that support.