Small discrepancies in JLS 14+

Gavin Bierman gavin.bierman at oracle.com
Mon Nov 25 23:10:38 UTC 2024


Thanks for your email, Marc. You are correct, there is no point to the production for ConstantExpression, as the nonterminal is not used anywhere. It should have been removed when we refactored the switch grammars in JEP 361. Of course, we still use the phrase “constant expression”  but it isn’t defined syntactically by a grammar; 15.29 does not define "constant expression" syntactically as "Anything that matches ConstantExpression". Rather, 15.29 defines it _semantically_, as an expression that meets various criteria.

This will be corrected in the next edition of the JLS.

Many thanks,
Gavin


On 9 Jan 2024, at 16:05, mazas.marc at gmail.com wrote:

Hi all

This if of any help.

While writing a parser of the JLS (in fact a translator from the JLS grammar to a corresponding JavaCC grammar), I found some discrepancies.

The most interesting one is in JLS 14+ (e.g. for JLS 21: https://docs.oracle.com/javase/specs/jls/se21/html/jls-19.html):
The (last) production ConstantExpression is no more called in other productions; formerly it was called in SwitchLabel, which now calls  CaseConstant {, CaseConstant}.
The corresponding chapters (e.g. https://docs.oracle.com/javase/specs/jls/se14/html/jls-15.html#jls-15.29) still uses the term “Constant Expressions”; shouldn’t it use “Case Constants” ?

Another one was PackageName in JLS 1.8, defined but not called, but now it is called.

The Type production is also defined but not called (one can understand that).

And of course the CompilationUnit is defined and not called.

Regards
Marc Mazas

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


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