leonid.kuskov at oracle.com
Fri Nov 22 19:22:36 UTC 2019
The draft JVM spec for JEP 359(Records)* states in chapter 4.7.8 that:
"The|Synthetic|attribute is a fixed-length attribute in
the|attributes|table of a|ClassFile|,|field_info|,
A class member that does not appear in the source code must be marked
using a|Synthetic|attribute, or else it must have its|ACC_SYNTHETIC|flag
set. The only exceptions to this requirement are compiler-generated
methods which are not considered implementation artifacts, namely the
instance initialization method representing a default constructor of the
Java programming language (2.9.1
the class or interface initialization method (2.9.2
andthe|Enum.values()|and|Enum.valueOf()|methods*mandated members of
enums and records*."
So specification allows RI to mark final fields associated with
components and some methods by ACC_MANDATED flag (0x8000). The latest
this flag only for 2 attributes: MethodParameters_attribute,
Module_attribute . The flag is not mentioned in both tables: Table
4.5-A. "Field access and property flags", Table 4.6-A. "Method access
and property flags".
From my point of view, usage of this flag with methods/fields
contradicts the assertions:
>> All bits of the access_flags item not assigned in Table 4.5-A are reserved for future
use. *They should be* *set to zero* in generated class files and should
be ignored by Java Virtual Machine implementations.
>> All bits of the access_flags item not assigned in Table 4.6-A are
reserved for future use. They should be set to zero in generated class
files and should be ignored by Java Virtual Machine implementations.
Does it make sense to add a definition of ACC_MANDATED to the tables?
Earlier the spec stated that the Enum.values() and Enum.valueOf() are
exceptions to the requirement that a class member that does not appear
in the source code must be marked using a Synthetic attribute, or have
its ACC_SYNTHETIC flag set.
Now names of methods are removed and the more loose statement "mandated
members of enums and records" is used. Does it mean that spec won't
enumerate "mandated" methods anymore? And the setting of this flag will
be implementation-specific? From my point of view, it might break the
unambiguity of the signature tests.
Should the JCK signature test take into account the ACC_MANDATED flag?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the amber-spec-experts