All Manuals > LispWorks User Guide and Reference Manual > 41 The LW-JI Package

NextPrevUpTopContentsIndex

call-java-method

Function
Summary

Call a Java method.

Package

lw-ji

Signature

call-java-method method-name &rest args

Arguments

method-name

A string.

args

Lisp objects.

Description

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 default-constructor-arguments 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 default-constructor-arguments. See the entry for default-constructor-arguments 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.

Notes

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 default-constructor-arguments is used, but not much. If you find it convenient, there is no reason not to use it.

See also

default-constructor-arguments
call-java-method-error
Defining specific callers


LispWorks User Guide and Reference Manual - 13 Feb 2015

NextPrevUpTopContentsIndex