On 11/22/2019 12:04 PM, Alex Buckley wrote:
(This question was asked internally, and it wasn't clear if it was
about JEP 359 (Records) specifically or ACC_MANDATED more broadly.
Since the question is being driven by JEP 359 changes, and since JEP
359 is in any case the next feature which will change the JVMS, let's
discuss on amber-spec-experts, NOT on compiler-dev. I have REMOVED
compiler-dev from the header.)
On 11/22/2019 11:22 AM, Leonid Kuskov wrote:
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".
...
Does it make sense to add a definition of ACC_MANDATED to the tables?
Good question. The mask 0x8000 is presently defined as ACC_MODULE in
ClassFile.access_flags, but it would be legitimate to define the same
mask as ACC_MANDATED in {field_info,method_info}.access_flags. This
would mirror the situation for the mask 0x0020, which is defined as
ACC_SUPER in ClassFile.access_flags but defined as ACC_SYNCHRONIZED in
method_info.access_flags. I'm sure we have discussed ACC_MANDATED
before so I'm not sure why the JEP 359 JVMS draft is silent on the
matter.
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?
JVMS 4.7.8 should cross-ref to all JLS sections which define mandated
members. JVMS 4.7.8 should not list them explicitly. (There are
numerous "JLS §..." cross-refs in JVMS ch.4, they are quite legitimate.)
And the setting of this flag will be implementation-specific?
No, the presence of mandated members is JLS-defined. Search for
"mandated" in JLS 13.1 to dispel any notion that mandated members are
implementation-specific.
Should the JCK signature test take into account the ACC_MANDATED flag?
If ACC_MANDATED is added to {field_info,method_info}.access_flags,
then yes, its presence on certain members of enum and record types is
required.
Alex
Could someone also specify definitively the behavior when a user chooses
to explicitly define a method, such as `equals` or `hashCode` for a
record. In other words, just because a method may be mandated in JLS,
I'm expecting that this does not imply the use of ACC_MANDATED in those
situations where the user explicitly defines the method.
-- jon