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

NextPrevUpTopContentsIndex

import-java-class-definitions

Macro
Summary

Generates all the definitions for a Java class.

Package

lw-ji

Signature

import-java-class-definitions java-class-name &key lisp-class-p lisp-name export-p package-name name-constructor lisp-supers => lisp-name-symbol

Arguments

java-class-name

A string.

lisp-class-p

A generalized boolean.

lisp-name

A symbol.

export-p

A generalized boolean.

package-name

A package designator.

name-constructor

A function designator.

lisp-supers

A list of symbols.

Values

lisp-name-symbol

A symbol.

Description

The macro import-java-class-definitions generates all the definitions for the class java-class-name, and wraps cl:progn around them, and returns this from the macroexpansion. Therefore evaluation of an import-java-class-definitions form defines all the callers for java-class-name.

java-class-name name must name a Java Class, and it must be the precise full name.

The generation of the definitions is done by generate-java-class-definitions, and all the keywords are passed to it. See the entry for generate-java-class-definitions for the effects of the keywords.

During macroexpansion, import-java-class-definitions needs to be able to find the class definitions, for which it needs running Java, which means a Java Virtual Machine running and the class being accessible. The evaluation of the definitions does not require Java. Thus if you compile a file containing an import-java-class-definitions form, the binary file can be loaded without Java, but the compilation needs running Java, and loading the source file also requires running Java.

The returned value lisp-name-symbol is the Lisp name (which is lisp-name, or is generated by generate-java-class-definitions if lisp-name was not supplied).

See Importing classes for discussion.

Notes
  1. You can avoid the need for running Java during compilation by writing the definitions using the writers (write-java-class-definitions-to-file or write-java-class-definitions-to-stream) once, and incorporate the output into your sources.
  2. Even when you use import-java-class-definitions, it is probably useful to look at the output of the writers to have a better idea what is actually being generated.
Examples
(import-java-class-definitions "java.io.File")
See also

generate-java-class-definitions
write-java-class-definitions-to-file
write-java-class-definitions-to-stream
Importing classes


LispWorks User Guide and Reference Manual - 20 Sep 2017

NextPrevUpTopContentsIndex