Question

I need something simple like this

@Produces
@Annotated(Licensed.class) //Qualifier
public Set<Class<?>> getLicensedClasses() {
    return licensed;
}

However this does not work. CDI behaves according documentation:

If a producer field type contains a wildcard type parameter the container automatically detects the problem and treats it as a definition error.

Set in the snippet contains bunch of classes obtained via reflection. It is a set of classes annotated with @Licensed annotation.

Was it helpful?

Solution

Just drop the wildcard:

@Produces
@Annotated(Licensed.class) //Qualifier
public Set<Class> getLicensedClasses() {
    return licensed;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top