<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
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.<br id="lineBreakAtBeginningOfMessage">
<div><br>
</div>
<div>This will be corrected in the next edition of the JLS.</div>
<div><br>
</div>
<div>Many thanks,</div>
<div>Gavin</div>
<div><br>
</div>
<div><br>
<blockquote type="cite">
<div>On 9 Jan 2024, at 16:05, mazas.marc@gmail.com wrote:</div>
<br class="Apple-interchange-newline">
<div>
<div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">Hi all<o:p></o:p></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">This if of any help.<o:p></o:p></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US">While writing a parser of the JLS (in fact a translator from the JLS grammar to a corresponding JavaCC grammar), I found some discrepancies.<o:p></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US"><o:p> </o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US">The most interesting one is in JLS 14+ (e.g. for JLS 21:<span class="Apple-converted-space"> </span><a href="https://docs.oracle.com/javase/specs/jls/se21/html/jls-19.html" style="color: rgb(5, 99, 193); text-decoration: underline;">https://docs.oracle.com/javase/specs/jls/se21/html/jls-19.html</a>):<o:p></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US">The (last) production<span class="Apple-converted-space"> </span><b>ConstantExpression</b><span class="Apple-converted-space"> </span>is no more called in other
productions; formerly it was called in<span class="Apple-converted-space"> </span><b>SwitchLabel</b>, which now calls <b>CaseConstant {, CaseConstant}</b>.<o:p></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US">The corresponding chapters (e</span><span lang="EN-US" style="font-size: 12pt;">.g.<span class="Apple-converted-space"> </span><a href="https://docs.oracle.com/javase/specs/jls/se14/html/jls-15.html#jls-15.29" style="color: rgb(5, 99, 193); text-decoration: underline;">https://docs.oracle.com/javase/specs/jls/se14/html/jls-15.html#jls-15.29</a>)
still uses the term “<i>Constant Expressions</i>”; shouldn’t it use “<i>Case Constants</i>” ?<o:p></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US"><o:p> </o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US">Another one was<span class="Apple-converted-space"> </span><b>PackageName</b><span class="Apple-converted-space"> </span>in JLS 1.8, defined but not called, but
now it is called.<o:p></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US"><o:p> </o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US">The<span class="Apple-converted-space"> </span><b>Type</b><span class="Apple-converted-space"> </span>production is also defined but not called (one can understand
that).<o:p></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US"><o:p> </o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US">And of course the<span class="Apple-converted-space"> </span><b>CompilationUnit</b><span class="Apple-converted-space"> </span>is defined and not called.<o:p></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US"><o:p> </o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US">Regards<o:p></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US">Marc Mazas</span></div>
</div>
</div>
</blockquote>
</div>
<br>
</body>
</html>