In the Contexts and Dependency Injection (CDI) 1.0 implementation, the getAnnotated method on a class that implements the
javax.enterprise.inject.spi.InjectionPoint interface can return an instance of javax.enterprise.inject.spi.Annotated.
In the CDI 1.2 implementation, the getAnnotated method must return an instance of AnnotatedField or
AnnotatedParameter, depending on whether the injection point is an injected field or a parameter on a constructor or method.
This rule flags calls to the Annotated constructor within a getAnnotated method on a class that implements the
javax.enterprise.inject.spi.InjectionPoint interface. For example, the following call to new Annotated() is flagged:
public class MyInjectionPoint implements InjectionPoint {
public Annotated getAnnotated() {
return new Annotated() {
public Set<Annotation> getAnnotations() {
return null;
}
...
};
}
...
}
The binary application scanner flags all getAnnotated methods on classes that implement the javax.enterprise.inject.spi.InjectionPoint
interface. If the flagged getAnnotated method returns an instance of AnnotatedParameter or AnnotatedField, this rule can
be ignored. If the getAnnotated method returns an instance of Annotated, the code must be changed.
In the CDI 1.2 implementation, the application containing class MyInjectionPoint does not start and throws the following exception:
org.jboss.weld.exceptions.IllegalArgumentException: WELD-001521: InjectionPoint.getAnnotated() must return either AnnotatedParameter or AnnotatedField
To resolve this issue, replace the call to new Annotated() with new AnnotatedField() or
new AnnotatedParameter(), depending on whether the injection point is an injected field or a parameter on a constructor or method.
For more information about the Java EE 7 CDI 1.2 implementation, see Contexts and Dependency Injection 1.2 behavior changes.