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

define-field-accessor Macro

Summary

Defines a Java field accessor.

Package

lw-ji

Signature

define-field-accessor name class-name field-name static-p &optional is-final => name

Arguments
name
A symbol.
class-name
A string.
field-name
A string.
static-p
A boolean.
is-final
A boolean.
Values
name
A symbol.
Description

The macro define-field-accessor defines a field accessor for a field in a Java class.

name, class-name, field-name, static-p and is-final are interpreted as for setup-field-accessor.

Unlike setup-field-accessor, define-field-accessor does not look up anything. The accessor does the look up first time it is called, and signals an error if something failed. This error should be of type:

Failed to find the class.

Failed to find the field, or found the field but wrong static-p value.

Got an exception trying to access the field.

Notes
  1. In general, accessing fields should be avoided, because they are typically a less well-defined and implemented interface than methods, but sometimes it is necessary.
  2. The importing interface generates appropriate define-field-accessor forms for public fields.
See also

setup-field-accessor


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:46