Call a Java static method.
lw-ji
call-java-static-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-static-method
calls a Java static method named full-method-name with 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.lang.Array.sort"
. call-java-static-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 with :static-p t
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 with :static-p t
. 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 static method cannot be found), call-java-static-method
signals an error of type call-java-method-error, which reports the actual failure.
call-java-static-method
is new in LispWorks 8.0. Previous versions had only call-java-method, which may call either static or non-static methods. call-java-static-method
is guaranteed to call only static methods, and is therefore a better match the the calls from Java code.
To call non-static method only, use jobject-call-method.
call-java-static-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
jobject-call-method
call-java-method-error
15.2.2 Defining specific callers
LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:46