Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api/src/main/java/jakarta/enterprise/event/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
* </p>
*
* <ul>
* <li>the <em>specified type</em> is the type parameter specified at the injection point, and</li>
* <li>the <em>specified type</em> is the type argument specified at the injection point, or the type argument's
* lower bound if the type argument is a wildcard, and</li>
* <li>the <em>specified qualifiers</em> are the qualifiers specified at the injection point.</li>
* </ul>
*
Expand Down
3 changes: 2 additions & 1 deletion api/src/main/java/jakarta/enterprise/inject/Instance.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
* </p>
*
* <ul>
* <li>the <em>required type</em> is the type parameter specified at the injection point, and</li>
* <li>the <em>required type</em> is the type argument specified at the injection point, or the type argument's
* upper bound if the type argument is a wildcard, and</li>
* <li>the <em>required qualifiers</em> are the qualifiers specified at the injection point.</li>
* </ul>
*
Expand Down
17 changes: 10 additions & 7 deletions spec/src/main/asciidoc/core/events.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public interface Event<T> {

For an injected `Event`:

* the _specified type_ is the type parameter specified at the injection point, and
* the _specified type_ is the type argument specified at the injection point, or the type argument's lower bound if the type argument is a wildcard, and
* the _specified qualifiers_ are the qualifiers specified at the injection point.


Expand All @@ -167,9 +167,7 @@ Event<AdminLoggedInEvent> admin = any.select(

If the specified type contains a type variable, an `IllegalArgumentException` is thrown.

The specified type must not be a wildcard type.
If an injected `Event` has a specified type that is a wildcard type, the container treats it as a definition error.
If a programmatically obtained `Event` has a specified type that is a wildcard type, non-portable behavior results.
If the application attempts to programmatically obtain an `Event` whose specified type is a wildcard without lower bound, an `IllegalArgumentException` is thrown.

If two instances of the same non repeating qualifier type are passed to `select()`, an `IllegalArgumentException` is thrown.

Expand Down Expand Up @@ -197,14 +195,19 @@ If the runtime type of the event object is assignable to the type of a container

The container must provide a built-in bean with:

* `Event<X>` in its set of bean types, for every Java type `X` that does not contain a type variable,
* every event qualifier type in its set of qualifier types,
* bean type `Event<X>`, where `X` is a type variable without bounds,
* qualifier `@Default`,
* scope `@Dependent`,
* no bean name, and
* an implementation provided automatically by the container.

If an injection point of

If an injection point of raw type `Event` is defined, the container automatically detects the problem and treats it as a definition error.
* raw type `Event`, or
* type `Event<?>`, or
* type `Event<? extends X>`, for any type `X`,
Comment on lines +207 to +208

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two bullet points could be collapsed, since Event<?> is the same type as Event<? extends Object>.


is defined, the container automatically detects the problem and treats it as a definition error.

[[observer_resolution]]

Expand Down
31 changes: 20 additions & 11 deletions spec/src/main/asciidoc/core/injectionandresolution.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ Parameterized and raw types are considered to match if they are identical or if
* The bean has all the required qualifiers.
If no required qualifiers were explicitly specified, the container assumes the required qualifier `@Default`. A bean has a required qualifier if it has a qualifier with (a) the same type and (b) the same annotation member value for each member which is not annotated `@jakarta.enterprise.util.Nonbinding`.

For the built-in beans defined in <<builtin_instance>> and <<builtin_event>>, the rules above do not apply.
Instead:

* The built-in bean for `Instance` is assignable to all injection points with required type `Instance<X>` or `Provider<X>`, where `X` is a legal bean type, regardless of required qualifiers.
* The built-in bean for `Event` is assignable to all injection points with required type `Event<X>`, where `X` is a type that does not contain a type variable, regardless of required qualifiers.

A bean is eligible for injection to a certain injection point if:

* it is available for injection in the module that contains the class that declares the injection point, and
Expand Down Expand Up @@ -677,7 +683,7 @@ public interface Instance<T> extends Iterable<T>, Provider<T> {

For an injected `Instance`:

* the _required type_ is the type parameter specified at the injection point, and
* the _required type_ is the type argument specified at the injection point, or the type argument's upper bound if the type argument is a wildcard, and
* the _required qualifiers_ are the qualifiers specified at the injection point.


Expand All @@ -700,12 +706,15 @@ Instance<AsynchronousPaymentProcessor> async = anyPaymentProcessor.select(
AsynchronousPaymentProcessor.class, new AsynchronousQualifier() );
----

The required type must not be a wildcard type.
If an injected `Instance` has a required type that is either a wildcard type or an `Event` whose specified type is a wildcard type, the container treats it as a definition error.
If a programmatically obtained `Instance` has a required type that is a wildcard type, non-portable behavior results.
If an injection point of

* raw type `Instance`, or
* type `Instance<? super X>`, for any type `X`, or
* type `Instance<X>` or `Instance<? extends X>`, where `X` is a type for which an injection point may not exist, as specified in <<builtin_event>>,

is defined, the container automatically detects the problem and treats it as a definition error.

If an injection point of raw type `Instance` is defined, the container automatically detects the problem and treats it as a definition error.
If the application attempts to programmatically obtain an `Instance` whose required type is a wildcard with lower bound, an `IllegalArgumentException` is thrown.

If two instances of the same non repeating qualifier type are passed to `select()`, an `IllegalArgumentException` is thrown.

Expand Down Expand Up @@ -791,13 +800,13 @@ The `close()` method delegates to the aforementioned `destroy()` method.

==== The built-in `Instance`

The container must provide a built-in bean that:
The container must provide a built-in bean with:

* is eligible for injection to any injection point with required type `Instance<X>` or `Provider<X>`, for any legal bean type `X`,
* has any qualifiers
* has scope `@Dependent`,
* has no bean name, and
* has an implementation provided automatically by the container.
* bean types `Instance<X>` and `Provider<X>`, where `X` is a type variable without bounds,
* qualifier `@Default`,
* scope `@Dependent`,
* no bean name, and
* an implementation provided automatically by the container.

[[annotationliteral_typeliteral]]

Expand Down
Loading