Inject accessor methods for the field denoted using an
annotation. All loads and
stores to the original field are redirected to accessor methods located in the class provided in
property. The class must implement the marker interface
. The accessor methods are static methods in that class, named either
for a field name
Depending on the kind of accessor (get / set for a static / non-static field), the accessor must
have 0, 1, or 2 parameters.
If the field is non-static, the first method parameter is the accessed object. The type of the
parameter must be the class that declared the field. The null check on the object is performed
before the accessor is called, in the same way as the null check for a regular field access.
For get-accessors, the return type of the method must be the type of the field. For
set-accessors, the last method parameter must be the type of the field and denotes the value
stored to the field.
If no set-accessor is provided, stores to the field lead to a fatal error during image
generation. If no get-accessor is provided, loads of the field lead to a fatal error during image
The injected accessors must not access the original field. Since all field accesses use the
accessors, that would lead to a recursive call of the accessors. Instead, data must be stored in
either a new static field, or an