generate-java-class-definitions java-class-name &key lisp-name package-name prefix name-constructor export-p create-defpackage lisp-class-p lisp-supers => list-of-definitions, lisp-name-symbol, package-name-string
A string or
A function designator.
A generalized boolean.
A generalized boolean.
A generalized boolean.
A list of symbols.
generate-java-class-definitions returns a list of forms which are definitions of Java callers that call the public methods (including constructors) of the class specified by java-class-name, and accessors for public fields. These include inherited methods and fields.
generate-java-class-definitions is normally used indirectly by using import-java-class-definitions, but can also be used directly. write-java-class-definitions-to-file and write-java-class-definitions-to-stream do the same processing as
generate-java-class-definitions, and then generate output based on the result.
If lisp-name is supplied it must be a Lisp symbol. In this case it specifies the package to intern the names of definitions in, and if a CLOS class is defined, the name of this class. It is also automatically defined as a constant with a value the java-class-name. lisp-name can also be
package-name is used only if lisp-name is supplied as
nil, to specify the package where the names of the definitions are interned. It must be a string containing the package name (in the desired case). The package is created if it does not exist already. If lisp-name is
nil and package-name is
nil or not supplied, the current package is used.
prefix, if supplied, specifies a prefix to use for the names of the definitions. If prefix is not supplied or is
nil, the name of the Java class without the package part is uppercased and used as the prefix (for example for "java.io.File" the prefix is "FILE"). The prefix is passed to the name-constructor to construct names for the Java callers.
If name-constructor is supplied, it must be a function taking two string arguments: the prefix and the name of the Java method or field that the Java caller is going to call or access (for constructors, the string "new" is passed as the method name). It must return a string which is then interned (without changing the case) in the package to create the symbol that is used as the name of the caller. The name-constructor defaults to a function (default-name-constructor) that concatenates the prefix as it is, a dot and uppercase of the method/field name. For example, for the method "exists" in the Java class "java.io.File", the default name constructor with the default prefix would generate "FILE.EXISTS".
create-defpackage controls what form to generate to do the package manipulation. With the default,
generate-java-class-definitions generates a form that check that the package exists, otherwise creates it, and if export-p is
t, a form that exports all the symbols. If create-defpackage is non-nil,
generate-java-class-definitions generates a defpackage form instead. The default value of create-defpackage is
the reason the create-defpackage defaults to
nil is that the defpackage form would contain only the symbols that were defined by the importing, which would be wrong if the package needs to export other symbols too, which is quite likely with the default settings (because other classes in the same Java package will default to use the same Lisp package). create-defpackage is useful when you want to create a package that exports only the definitions for a single Java class.
lisp-supers and lisp-class-p control whether a CLOS class is defined for the Java class. By default, no CLOS class is defined. See in Creating CLOS class.
generate-java-class-definitions uses '/' rather than '.' as separator between the components. The definer macros accept both '/' and '.' as separators. The actual generated forms may contain additional keywords. Currently methods and constructors have the signatures.
generate-java-class-definitionsalso identifies pairs of methods where one has the name
set<something>and the other has the name
is<something>, which are assumed to be setter and getter for the same field. It then generates a
cl:setfdefinition to allow using
cl:setfon the symbol corresponding to
is<something>name to call the
generate-java-class-definitionsalso generates a symbol macro with a name that is the symbol name preceded and followed by the
*character, and allows getting and the setting the field using this symbol.
Note: see the discussion CLOS partial integration.
If lisp-supers is supplied and non-nil (and lisp-name is non-nil) a class is created, using a plain defclass form, and the value lisp-class-p is ignored. lisp-supers must be a list of symbols naming classes, of which at least one is standard-java-object or a subclass of it. This list defines the superclasses of the class that is defined.
If lisp-class-p is non-nil and lisp-supers is
nil (and lisp-name is non-nil) a class is created using ensure-lisp-classes-from-tree. If lisp-class-p is the keyword
:complete, the force-p argument is passed is
t, otherwise it is
nil. See ensure-lisp-classes-from-tree for details.
LispWorks User Guide and Reference Manual - 20 Sep 2017