Macro | Package: net.jlinker | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 10.1 Unrevised from 10.0 to 10.1. 10.0 version

## def-java-constructor

Arguments: lisp-name (lisp-class &rest argtypes)

This macro defines a Lisp function that calls a Java constructor. The first argument is the name of the new Lisp function. The second argument is an argument list where the first item is the Lisp name of a class previously defined with def-java-class. The Lisp name is defined as a function of n arguments, where n is the number of argtypes specified. Each argtype is a string or symbol that denotes a Java class. The Lisp class must be defined to represent exactly one Java class. If the Lisp class was defined to represent more than one Java class, an error is signaled when the macro is expanded.

### Examples

    (def-java-class (string-buffer "java.lang.StringBuffer")
    (application-buffer)
        ()
        ()
        ((source :initform "Java")))

    (def-java-constructor new-string-buffer-int (string-buffer "int"))

This form defines a Lisp function new-string-buffer-int that calls Java to create an instance of the Java class `java.lang.StringBuffer`, and returns a remote reference to the instance. The remote reference will be a Lisp instance of the class `string-buffer`.

The constructor is called as an ordinary Lisp function:

    (new-string-buffer-int 17)

is an example of such a call.

    (def-java-constructor new-string-buffer-str
        (string-buffer "java.lang.String"))

This form defines another Lisp function (new-string-buffer-str that calls a different constructor of the `java.lang.StringBuffer` class. The Lisp function must have a different name because the constructors are ordinary functions, not generic functions, and thus cannot be overloaded in any way.

The constructor is also called as an ordinary Lisp function:

    (new-string-buffer-str "abc")

See jlinker.htm for more information on the jLinker facility.

Copyright (c) 1998-2022, Franz Inc. Lafayette, CA., USA. All rights reserved.
This page was not revised from the 10.0 page.
Created 2019.8.20.

|  | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 10.1 Unrevised from 10.0 to 10.1. 10.0 version