Next: Interfaces.
Up: Applying the simplify algorithm
Previous: Local variable declarations
Contents
Index
Field declarations
Expressions can appear as initializers in field declarations. If these
expressions need simplification, and the field is declared in a class, the
field initialization can be moved into an instance initializer block
(if the field is an instance varible) or a static initializer block
(if the field is a class variable) in the class. The case of a field
declared in an interface will be considered at the end of this section.
We visit every field declaration in a source class in textual order.
Consider a field variable declaration of the form
where
is an optional list of modifiers, and other
declarations are as in section A.3.3.
We assume this is an instance variable (respectively static variable)
declaration.
Visit each variable declarator in this declaration in exactly
the same way as described in the preceding section on local variable
declarations.
The field declaration is processed in essentially the same way.
The only significant change is in the definition of the
.
If
is empty, then
is just:
Otherwise, we break the declaration into an
uninitialized single-variable declaration and an instance initializer
block:
(respectively static initializer block:
).
Subsections
Next: Interfaces.
Up: Applying the simplify algorithm
Previous: Local variable declarations
Contents
Index
Bryan Carpenter
2003-04-15