<div dir="ltr"><div>I think for the JLS justification in particular - that is something which fits within the "info" part of our model but also isn't particularly interesting for the target audience of "people who trigger compiler errors."<br><br> A motivating example I sent to Vicente (almost 9 months ago! God I'm unproductive) was the contrast between the information conveyed in this message<br><br><span style="font-family:monospace"> import java.util.List;</span><br style="font-family:monospace"><br style="font-family:monospace"><span style="font-family:monospace"> enum Ex {</span><br style="font-family:monospace"><span style="font-family:monospace"> A,</span><br style="font-family:monospace"><span style="font-family:monospace"> B</span><br style="font-family:monospace"><span style="font-family:monospace"> }</span><br style="font-family:monospace"><br style="font-family:monospace"><span style="font-family:monospace"> public class MyClass {</span><br style="font-family:monospace"><span style="font-family:monospace"> public static void main(String args[]) {</span><br style="font-family:monospace"><span style="font-family:monospace"> var ex = B;</span><br style="font-family:monospace"><span style="font-family:monospace"> }</span><br style="font-family:monospace"><span style="font-family:monospace"> }</span></div><div><font face="monospace"><br></font></div><div><font face="monospace"><br></font><br><span style="font-family:monospace"> /MyClass.java:10: error: cannot find symbol</span><br style="font-family:monospace"><span style="font-family:monospace"> var ex = B;</span><br style="font-family:monospace"><span style="font-family:monospace"> ^</span><br style="font-family:monospace"><span style="font-family:monospace"> symbol: variable B</span><br style="font-family:monospace"><span style="font-family:monospace"> location: class MyClass<br></span><br>As compared to that emitted by rustc<br><br><span style="font-family:monospace"> enum Ex {</span><br style="font-family:monospace"><span style="font-family:monospace"> A,</span><br style="font-family:monospace"><span style="font-family:monospace"> B</span><br style="font-family:monospace"><span style="font-family:monospace"> }</span><br style="font-family:monospace"><br style="font-family:monospace"><span style="font-family:monospace"> pub fn main() {</span><br style="font-family:monospace"><span style="font-family:monospace"> let ex = A;</span><br style="font-family:monospace"><span style="font-family:monospace"> }<br></span><br><font face="monospace"> error[E0425]: cannot find value `A` in this scope</font><br><font face="monospace"> --> src/main.rs:7:14</font><br><font face="monospace"> |</font><br><font face="monospace"> 7 | let ex = A;</font><br><font face="monospace"> | ^ not found in this scope</font><br><font face="monospace"> |</font><br><font face="monospace"> help: consider importing this unit variant</font><br><font face="monospace"> |</font><br><font face="monospace"> 1 | use crate::Ex::A;</font><br><font face="monospace"> |</font><br><br><font face="monospace"> For more information about this error, try `rustc --explain E0425`.</font><br><br>Which could look like (ignoring the finer details of the ascii art)<br><br><span style="font-family:monospace"> error[E0123]: cannot find symbol `A` in this scope</span><br style="font-family:monospace"><span style="font-family:monospace"> --> src/Main.java:9:18</span><br style="font-family:monospace"><span style="font-family:monospace"> |</span><br style="font-family:monospace"><span style="font-family:monospace"> 9 | var ex = B;</span><br style="font-family:monospace"><span style="font-family:monospace"> | ^ not found in this scope</span><br style="font-family:monospace"><span style="font-family:monospace"> |</span><br style="font-family:monospace"><span style="font-family:monospace"> help: consider importing this enum variant</span><br style="font-family:monospace"><span style="font-family:monospace"> |</span><br style="font-family:monospace"><span style="font-family:monospace"> 1 | import static Ex.B;</span><br style="font-family:monospace"><span style="font-family:monospace"> |</span><br style="font-family:monospace"><br style="font-family:monospace"><span style="font-family:monospace"> For more information about this error, try `javac --explain E0123`.<br></span><br>Where it is not enough to just "make a better message." There are structural deficiencies which preclude giving this sort of feedback.<br><br>The *desire* to give a hint on how to fix something or extra context on why something is an error is what I think the true monster hiding under the bed of JDK-6397027 was. Language kinda has to be irregular in order to contain multiple of these semantic elements - y'know?<br><br>(sorry if this isn't the most complete justification)<br><br>---</div><div><br>My strategy for making progress has been to recruit the help of some students for whom working out a prototype is their senior design project. It's slow going, but we're all learning.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Nov 10, 2022, 4:40 PM Ethan McCue <<a href="mailto:ethan@mccue.dev" target="_blank">ethan@mccue.dev</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div dir="auto"></div>Pithy instant response: it's not too big for mainstream rustc <div dir="auto"><br></div><div dir="auto"><br><div dir="auto"><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">On Thu, Nov 10, 2022, 4:31 PM Jonathan Gibbons <<a href="mailto:jonathan.gibbons@oracle.com" rel="noreferrer noreferrer" target="_blank">jonathan.gibbons@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<p>
</p><blockquote type="cite">
<div dir="auto"><br>
</div>
<div dir="auto">Our current brain scratcher is how to represent
suggestions on how to fix code that actually "makes the
correction for them" </div>
<div dir="auto"><br>
</div>
<div dir="auto">So like</div>
<div dir="auto"><br>
</div>
<div dir="auto"> int assert;</div>
<div dir="auto"><br>
</div>
<div dir="auto">How to model some code that can be later
formatted as a suggestion to rename the "assert" variable to
"assert_"</div>
<div dir="auto"><br>
</div>
<div dir="auto"><br>
</div>
<div dir="auto"><br>
</div>
</blockquote>
<p></p>
<p>While it sounds fun, it also sounds "too big" for mainstream
javac. That suggests there could be a plugin mechanism to add
more info to diagnostics. Maybe.</p>
<p>-- Jon</p>
<p><br>
</p>
<p><br>
</p>
<div>On 11/10/22 11:42 AM, Ethan McCue
wrote:<br>
</div>
<blockquote type="cite">
<div dir="auto">Thanks - we have been tracking the PR. It will be
helpful for us to track our progress.
<div dir="auto"><br>
</div>
<div dir="auto">---</div>
<div dir="auto"><br>
</div>
<div dir="auto">To springboard into something different but
related:</div>
<div dir="auto"><br>
</div>
<div dir="auto">We have been working on modeling how to add
kinds of information to JCDiagnostics that are semantically
different from a message as produced by DiagnosticInfo.</div>
<div dir="auto"><br>
</div>
<div dir="auto">In the current hypothesis there are two new
categories of information we are calling "help" and "info".</div>
<div dir="auto"><br>
</div>
<div dir="auto">"help" contains some suggestions on how to
rectify a given sort of error. In the simplest form this is a
codification of the "try using --enable-preview" type messages
which exist somewhat ad-hoc throughout the codebase. </div>
<div dir="auto"><br>
</div>
<div dir="auto">Our current brain scratcher is how to represent
suggestions on how to fix code that actually "makes the
correction for them" </div>
<div dir="auto"><br>
</div>
<div dir="auto">So like</div>
<div dir="auto"><br>
</div>
<div dir="auto"> int assert;</div>
<div dir="auto"><br>
</div>
<div dir="auto">How to model some code that can be later
formatted as a suggestion to rename the "assert" variable to
"assert_"</div>
<div dir="auto"><br>
</div>
<div dir="auto"><br>
</div>
<div dir="auto"><br>
</div>
<div dir="auto"><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Thu, Nov 10, 2022, 2:25 PM
Jonathan Gibbons <<a href="mailto:jonathan.gibbons@oracle.com" rel="noreferrer noreferrer noreferrer" target="_blank">jonathan.gibbons@oracle.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<p>As a followup, the code to generate diags-examples.html
needed some TLC, and was fixed in <a href="https://bugs.openjdk.org/browse/JDK-8296137" style="color:rgb(59,115,175);text-decoration:none" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">JDK-8296137</a>.</p>
<p>The command to generate the report is effectively this:</p>
<p>JAVA_HOME=$JDK $ANT \<br>
-Dlangtools.jdk.home=$JDK \<br>
-f make/langtools/diags-examples.xml<br>
</p>
<p>where: </p>
<ul>
<li>the current directory is the root of the OpenJDK repo</li>
<li>ANT refers to a recent executable for Ant,<br>
</li>
<li>JDK refers to a build of JDK in the same repo
containing the examples directory</li>
</ul>
<p>The report will be written to <font face="monospace">build/langtools/diags-examples/</font><br>
</p>
<div>-- Jon<br>
</div>
<div><br>
</div>
<div>On 10/3/22 1:22 PM, Jonathan Gibbons wrote:<br>
</div>
<blockquote type="cite">
<p>It's generated by the code in
open/test/langtools/tools/javac/diags/.</p>
<p>There are various classes there, like RunExamples.java,
CheckExamples.java etc. You are probably looking for
RunExamples.java; there are comments in the code on how
to use it.<br>
</p>
<p>-- Jon<br>
</p>
<div>On 10/3/22 7:31 AM, Ethan McCue wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Hey all,<br>
<br>
My group stumbled upon this page with a bunch of error
examples in a nice presentable format.<br>
<br>
<a title="https://cr.openjdk.java.net/~jjg/diags-examples.html" href="https://cr.openjdk.java.net/~jjg/diags-examples.html" rel="noreferrer noopener noreferrer noreferrer noreferrer noreferrer" role="button" style="margin:0px;padding:0px;border:0px;font-family:Whitney,"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:16px;vertical-align:baseline;outline:0px;word-break:break-word;white-space:break-spaces;background-color:rgba(4,4,5,0.07)" target="_blank">https://cr.openjdk.java.net/~jjg/diags-examples.html</a><br>
<br>
My suspicion is that this was generated by something
in the codebase - if so does anyone know the command
of the top of their head?</div>
</blockquote>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote></div></div></div></div>
</blockquote></div>