diff --git a/spec/src/main/asciidoc/core/invokers.asciidoc b/spec/src/main/asciidoc/core/invokers.asciidoc index bb506626..6b83b246 100644 --- a/spec/src/main/asciidoc/core/invokers.asciidoc +++ b/spec/src/main/asciidoc/core/invokers.asciidoc @@ -47,6 +47,7 @@ public interface Invoker { ---- Calling `invoke()` invokes the target method on given `instance` of the target bean, passing given `arguments`, and propagates back the return value or thrown exception. +The `instance` may be a non-contextual object. Invoker implementations must be thread-safe. A single invoker instance may be used to perform multiple, possibly concurrent, invocations of the target method, possibly on different instances of the target bean, possibly with different arguments. @@ -57,8 +58,16 @@ Whenever a direct invocation of a method on an object is a business method invoc If the target method is `static`, the `instance` is ignored; by convention, it should be `null`. If the target method is not `static` and `instance` is `null`, a `RuntimeException` is thrown. -If the target method is not `static` and the class of the `instance` is not a subclass of the bean class of the target bean, a `RuntimeException` is thrown. +If the target method is not `static` and the class of the `instance` makes it impossible to invoke the target method, a `RuntimeException` is thrown. +[NOTE] +==== +Usually, the class of the `instance` should be the bean class of the target bean (or a subclass), in which case, it is possible to invoke all target methods. +This is true when `instance` is a contextual reference for the target bean obtained using the bean class as the required type. + +It is however permissible for the `instance` to be a reference to a type that cannot be cast to the bean class (see <>). +In this case, invoking some target methods may be impossible. +==== Correspondence between given `arguments` and declared parameters of the target method is positional: the Nth element of the `arguments` array is passed as the Nth argument to the target method. If the target method is a variable arity method, the last element of the `arguments` array corresponds to the variable arity parameter (and therefore must be an array).