Call a Java method.
lw-ji
call-java-method full-method-name &rest args => result-of-java-method
full-method-name⇩ |
A string. |
args⇩ |
Lisp objects. |
result-of-java-method |
The result of calling the Java method full-method-name. |
The function call-java-method
calls a Java method on the supplied args.
full-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 returns the result.
The process of actually calling is the same as in ordinary Java callers defined by define-java-caller. See the documentation for define-java-caller for details.
If full-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
may call either static or non-static Java methods. If it finds both a static and a non-static method that match full-method-name and the argument types, then it calls the non-static method. Use jobject-call-method or call-java-static-method to enforce calling non-static or static methods.
call-java-method
needs to look up 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.
define-java-caller
call-java-method-error
jobject-call-method
call-java-static-method
call-java-non-virtual-method
15.2.2 Defining specific callers
LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:46