JVMS changes for JEP 401

Clement Cherlin ccherlin at gmail.com
Mon Jan 29 15:30:01 UTC 2024


> On Tue, Jan 23, 2024 at 7:11 PM Dan Smith <daniel.smith at oracle.com> wrote:
>>
>> I've posted a revised spec change document for JEP 401, Value Classes and Objects, here:
>>
>> https://cr.openjdk.org/~dlsmith/jep401/jep401-20240116/specs/value-objects-jvms.html

[snip]

>> - The 4.9.2 rule about ACC_STRICT is hard to parse, will be rephrased somehow
>>
>> - 2.4 should say more about "sameness" as it relates to "identity"

On Tue, Jan 23, 2024 at 8:15 PM - <liangchenblue at gmail.com> wrote:
>
> Hi Dan,
> Thanks for sharing this document! It looks great!
> There's a typo in section 2.4, where the definition of "element type" for an array type is accidentally removed.
>
> The reference to the "start of object construction" can probably be changed to "before the super-call," taken from John's "Constructive Classes" essay. [1]
> The 4.9.2 rule is correct;

Unless I'm mistaken, the rule in 4.9.2 is not correct.

>From the proposal:
>> An instance field of this declared in the current class with its ACC_STRICT flag set may be assigned by a putfield instruction occurring in an instance initialization method only if another instance initialization method has not yet been called.

As I understand the current design intent, a constructor that calls
'this' is forbidden from assigning to a strict field, because that
will lead to a duplicate assignment in a constructor that calls
'super'.

This language appears to say the opposite. It seems to state that only
the first constructor of the current class can assign the class's
strict instance fields. If that is the case, then further constructors
(including the one that calls 'super') are forbidden from assigning to
strict instance fields.

> perhaps we can be more explicit, that such a putfield can only exist in an <init> that calls a direct superclass's <init>, and the putfield must exist before such a super-call.

I believe those are the correct requirements.

> [1] https://cr.openjdk.org/~jrose/jls/constructive-classes.html

Cheers,
Clement Cherlin


More information about the valhalla-spec-observers mailing list