The function call-java-method
calls a Java method on the supplied args.
method-name must specify the full name of the Java method to call, including the package, class and method name, for example "java.io.File.exists"
. call-java-method
first uses the string to lookup a caller, and if that fails it produces a caller in the same way that define-java-caller and setup-java-caller do and caches it. It then uses the caller to call the Java method with args, and return the result.
The process of actual calling is the same as in ordinary Java callers defined by define-java-caller. See the entry for define-java-caller for details.
If method-name is incorrect (does not have class and method name, class cannot be found or method cannot be found), call-java-method
signals an error of type call-java-method-error, which reports the actual failure.
call-java-method
needs to lookup the caller using the string, so the call is slightly slower than calls for ordinary Java callers, but the difference is not significant. There is also no way to verify that the string is correct. It also has to keep some extra code that can be shaken out if only define-java-caller is used, but not much. If you find it convenient, there is no reason not to use it.
LispWorks User Guide and Reference Manual - 20 Sep 2017