diff --git a/api/src/main/java/jakarta/enterprise/invoke/InvokerBuilder.java b/api/src/main/java/jakarta/enterprise/invoke/InvokerBuilder.java index 41ccc4c3..dd950f79 100644 --- a/api/src/main/java/jakarta/enterprise/invoke/InvokerBuilder.java +++ b/api/src/main/java/jakarta/enterprise/invoke/InvokerBuilder.java @@ -67,7 +67,7 @@ public interface InvokerBuilder { /** * Enables lookup of the argument on given {@code position}. * - * @param position zero-based argument position for which lookup is enabled + * @param position zero-based position of the target method parameter for which lookup should be enabled * @return this builder * @throws IllegalArgumentException if {@code position} is less than 0 or greater than * or equal to the number of parameters declared by the target method diff --git a/spec/src/main/asciidoc/core/invokers.asciidoc b/spec/src/main/asciidoc/core/invokers.asciidoc index 4f45b2b6..1ab799b9 100644 --- a/spec/src/main/asciidoc/core/invokers.asciidoc +++ b/spec/src/main/asciidoc/core/invokers.asciidoc @@ -185,13 +185,18 @@ public interface InvokerBuilder { When `withInstanceLookup()` is called on an invoker builder and the target method is not `static`, the `invoke()` method of the built invoker shall ignore the `instance` argument and instead obtain and use a contextual reference for the target bean and the bean type that declares the target method. Calling `withInstanceLookup()` on an invoker builder for a `static` target method has no effect. -When `withArgumentLookup()` is called on an invoker builder, the `invoke()` method of the built invoker shall ignore the given element of the `arguments` array and instead obtain and use an injectable reference for an injection point that is the corresponding parameter of the target method. +When `withArgumentLookup()` is called on an invoker builder, the `invoke()` method of the built invoker shall ignore the given element of the `arguments` array and instead: + +1. identify a bean according to the rules of typesafe resolution, as defined in <>, where the required type is the declared type of the corresponding parameter of the target method and the required qualifiers are all qualifiers present on the parameter, resolving ambiguities according to <>; +2. obtain and use a contextual reference for the identified bean and the declared type of the parameter. + Calling `withArgumentLookup()` with `position` less than 0 or greater than or equal to the number of parameters of the target method leads to an `IllegalArgumentException`. In the following paragraphs, the beans whose instances shall be obtained by `Invoker.invoke()` as a result of calling `withInstanceLookup()` and `withArgumentLookup()` are called _looked up beans_. -During deployment validation, implementations are required to identify all looked up beans for all built invokers, according to the rules of typesafe resolution, as defined in <>, resolving ambiguities according to <>. +During deployment validation, implementations are required to identify all looked up beans for all built invokers, as described above. It is a deployment problem if an attempt to identify a looked up bean results in an unsatisfied dependency or an ambiguous dependency that is not resolvable. +Implementations are permitted to remember the identified beans and not repeat the resolution process for each invocation of `Invoker.invoke()`. All instances of `@Dependent` looked up beans obtained during `Invoker.invoke()` are destroyed before the `invoke()` method returns or throws. The order in which the instances of `@Dependent` looked up beans are destroyed is not specified.