<div dir="ltr"><div dir="ltr">On Tue, Jan 31, 2023 at 2:45 PM Archie Cobbs <<a href="mailto:archie.cobbs@gmail.com" target="_blank">archie.cobbs@gmail.com</a>> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Obviously this change requires a JEP, and so we have this JEP draft for review:<div><br></div><div style="margin-left:40px"><a href="https://bugs.openjdk.org/browse/JDK-8300786" target="_blank">JDK-8300786</a> - No longer require super() and this() to appear first in a constructor</div></div></blockquote><div><br></div>Update on this JEP.</div><div class="gmail_quote"><br></div><div class="gmail_quote">Doing a little more research I discovered that since Java 8 the compiler has not been following the spec as it applies to allowing type parameters inside <span style="font-family:monospace">super()</span> calls (bug filed as <a href="https://bugs.openjdk.org/browse/JDK-8301649">JDK-8301649</a>).</div><div class="gmail_quote"><div class="gmail_quote"><br></div><div class="gmail_quote">The spec 
says this is a "static context", so type parameters are in theory not 
allowed. But the compiler allows it, and in fact it seems the spec is being too restrictive.<br></div><div class="gmail_quote"><br><div class="gmail_quote">With the change in this JEP, this discrepancy will only get worse, because the "static context" that's part of a constructor can now include a lot more stuff.<br></div><div class="gmail_quote"><br></div></div></div><div class="gmail_quote">In <a href="https://mail.openjdk.org/pipermail/compiler-dev/2023-February/021960.html" target="_blank">this discussion on compiler-dev</a> it was generally agreed that the spec should probably be fixed as part of this JEP.</div><div class="gmail_quote"><br></div><div class="gmail_quote">So I'm wondering about people's thoughts on this list - not only whether to fix the spec, but also how exactly to do so, any other suggestions, etc.<br></div><div class="gmail_quote"><br></div><div class="gmail_quote">I see two options:</div><ol><li>Split "static context" in two:<br></li><ol><li>The old "static context" gets renamed to "lexically static context". References to anything non-static are disallowed - same as now.<br></li><li>Define a new "referentially static context" which disallows any references to 'this' (explicit or implicit) but allows type parameters, etc.</li></ol><li>Leave "static context" alone, but add an exception to how it applies prior to <span style="font-family:monospace">super()</span> so that it permits type parameters, etc.</li></ol><div><div class="gmail_quote">Or maybe there is another option... ?</div><div class="gmail_quote"><br></div><div class="gmail_quote">Thoughts?<br></div><div class="gmail_quote"><br></div><div class="gmail_quote">Thanks,<br></div><div class="gmail_quote">-Archie<br></div><br>-- <br><div dir="ltr">Archie L. Cobbs<br></div></div></div>