Two Uncertain Technical Errors and Omissions of JLS 21

Gavin Bierman gavin.bierman at oracle.com
Mon Nov 25 17:54:44 UTC 2024


Dear Jim,

Thanks for your email.

On 3 Nov 2023, at 07:23, jim <jimdragongod at 126.com> wrote:

Dear Authors of JLS 21:
    I've found two uncertain technical errors and omissions of 《The Java® Language Specification Java SE 21 Edition》,as follows:
(1)uncertain omission
      The "Chapter 19. Syntax" says: "This chapter repeats the syntactic grammar given in Chapters 4, 6-10, 14, and 15, as well as key parts of the lexical grammar from Chapter 3, using the notation from §2.4."  I checked over all the repeated productions after Chapter 3, and found that the "Productions from §14 (Blocks, Statements, and Patterns)" lacked the definition of production "VariableAccess", which is:
    VariableAccess:
        ExpressionName
        FieldAccess
I think this may be an omission, because all other productions after Chapter 3 are present.

Indeed it is an omission! Thanks. This will be corrected in the next edition of the JLS.


(2)uncertain error comment
Sited from the two possible execution order "Example 17.4.5-1" in Chapter 17:
1: B = 1;
3: A = 2;
2: r2 = A; // sees initial write of 0
4: r1 = B; // sees initial write of 0
and
1: r2 = A; // sees write of A = 2
3: r1 = B; // sees write of B = 1
2: B = 1;
4: A = 2;
I think there should be a swap between the above comments,is it right?


No, I don’t think so. If you read to the end of the example (I highlight the import part in bold):

In this execution, the reads see writes that occur later in the execution order. This may seem
counterintuitive, but is allowed by happens-before consistency. Allowing reads to see later
writes can sometimes produce unacceptable behaviors.


You are being confused by the “counterintuitive” semantics I think!

Thanks,
Gavin


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jls-jvms-spec-comments/attachments/20241125/40036499/attachment.htm>


More information about the jls-jvms-spec-comments mailing list