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

NextPrevUpTopContentsIndex

create-java-object

Function
Summary

Invoke the Java constructor.

Package

lw-ji

Signature

create-java-object class-name &rest args => result

Arguments

class-name

A string.

args

Lisp objects.

Values

result

A Java object.

Description

The function create-java-object invokes the Java constructor for the class class-name with the supplied args.

class-name must specify a Java class. create-java-object first uses class-name to lookup a caller, and if that fails it produces a caller in the same way that define-java-constructor and setup-java-constructor do and caches it. It then uses the caller to call the constructor with args, and returns the result.

The process of actual calling is the same as in ordinary Java callers defined by define-java-constructor. See the entry for define-java-constructor for details.

If the string is incorrect (that is, it does not look like a Java class name or the class cannot be found), create-java-object signals an error of type create-java-object-error, which reports the actual failure.

Notes

create-java-object needs to lookup the caller using the string, so the call is slightly slower than calls for ordinary Java constructors, but the different is not significant. It also has to keep some extra code that can be shaken out if only define-java-constructor is used, but not much. If you find it convenient, there is no reason not to use it.

See also

define-java-constructor


LispWorks User Guide and Reference Manual - 20 Sep 2017

NextPrevUpTopContentsIndex