Spec: ACC_MANDATED
Leonid Kuskov
leonid.kuskov at oracle.com
Fri Nov 22 19:22:36 UTC 2019
Hi all,
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|,
or|method_info|structure (4.1
<https://docs.oracle.com/javase/specs/jvms/se12/html/jvms-4.html#jvms-4.1>,4.5
<https://docs.oracle.com/javase/specs/jvms/se12/html/jvms-4.html#jvms-4.5>,4.6
<https://docs.oracle.com/javase/specs/jvms/se12/html/jvms-4.html#jvms-4.6>).
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
<https://docs.oracle.com/javase/specs/jvms/se12/html/jvms-2.html#jvms-2.9.1>),
the class or interface initialization method (2.9.2
<https://docs.oracle.com/javase/specs/jvms/se12/html/jvms-2.html#jvms-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
JVMS specification
(https://docs.oracle.com/javase/specs/jvms/se13/html/index.html) permits
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?
And:
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?
Thanks,
Leonid
*)
http://cr.openjdk.java.net/~gbierman/jep359/jep359-20191031/specs/records-jvms.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20191122/23375adf/attachment-0001.html>
More information about the compiler-dev
mailing list