jakartaee / jakartaee/cdi

clarify TYPE_USE for qualifier and interceptor binding type annotations

Open
#877 18 comments 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
240
Forks
83
PR merge metrics
No merged PRs in 30d

Description

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

```java
@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:

```java
@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.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the CDI specification rules for qualifier and interceptor binding annotations, especially how TYPE_USE annotations relate to injection points. Determine whether the specification should require recognition on the annotated type use, and document the resulting wording for both qualifiers and interceptor bindings.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.