Skip to content

clarify TYPE_USE for qualifier and interceptor binding type annotations #877

@gavinking

Description

@gavinking

The specification does not clearly say whether I can usefully declare a @Qualfier type like this:

@Qualifier
@Retention(RUNTIME)
@Target({TYPE, TYPE_USE})
public @interface Special {}

To be clear, it doesn't disallow this, but it's unclear if an implementation is required to recognize the qualifier when it occurs as follows:

@Inject @Special Thing thing;

The reason being, of course, that here @Special is an annotation of the type use Thing, and not of the field thing.

In fact, it's extremely natural to view qualifier annotations as qualifying the type use rather than the injection point itself, and I guess the reason we didn't define it that was in CDI 1.0 was that we didn't have type annotations at that time.

Some implementation probably already allow this. I think the spec should be changed to clarify that this is a required feature.

All of the above also applies to interceptor binding types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions