<div dir="ltr"><div dir="ltr"><div><div>The proposed JLS changes for JEP 492 are saying that this example should no longer compile*:<br></div></div><div><br></div><div>    static {<br>        class Local1 {<br>            class Local2 {<br>                public static void m() {<br>                    new Local1();  // error<br>                }<br>            }<br>        }<br>    }</div><div><br></div><div>but that seems wrong - that exampple has been allowed since JDK-8254321, and as it has nothing to do with flexible constructors, it should continue to be allowed.<br></div></div><div dir="ltr"><br></div><div>The JEP 492 spec says (new additions in bold):</div><div><p>  If <em>C</em> is an inner local class, then:</p>
<ul><li><p>If <em>C</em> occurs in a static context, then <em>i</em> has no
immediately enclosing instance. <strong>Let <em>S</em> be the nearest
<code>static</code> method declaration, <code>static</code> field
declaration, or static initializer that encloses the declaration of
<em>C</em>. If the nearest <code>static</code> method declaration,
<code>static</code> field declaration, or static initializer that
encloses the class instance creation expression is not <em>S</em>, then
a compile-time error occurs.</strong></p>
</li></ul></div><div>Should there be an <b>Otherwise</b> at the beginning of the newly added sentence? (And same thing in the previous paragraph regarding anonymous classes)<br></div><div><br></div><div>-Archie<br></div><div dir="ltr"><br></div><div dir="ltr">* See <a href="https://bugs.openjdk.org/browse/JDK-8345953">JDK-8345953</a> JEP 492: instantiating local classes in a different static context should not be allowed</div><div dir="ltr"><span class="gmail_signature_prefix"><br></span></div><div dir="ltr"><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">Archie L. Cobbs<br></div></div>
</div>