<div dir="ltr"><div class="gmail_default" style="font-family:monospace">I think you are correct. Regardless, another example to test against is good to have.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Aug 8, 2023 at 1:59 PM Florent Guillaume <<a href="mailto:florent.guillaume@gmail.com">florent.guillaume@gmail.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 dir="ltr">Hi,<div><br></div><div>I believe this is <a href="https://github.com/openjdk/jdk/pull/15083" target="_blank">https://github.com/openjdk/jdk/pull/15083</a><div><br></div><div>Florent</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Aug 7, 2023 at 9:12 PM Remi Forax <<a href="mailto:forax@univ-mlv.fr" target="_blank">forax@univ-mlv.fr</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><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)"><div>Hi David,<br></div><div>thanks for the bug report.<br></div><div><br></div><div>I was able to reproduce the issue with the latest early acces of 22,<br></div><div>There is no issue if  "-g" is not specified, so the bug seems to be in the debug information that are added to the classfile.<br></div><div><br></div><div><span style="font-family:monospace">  javac -g --enable-preview --source 22 GUI.java</span></div><div><br></div><div>Here is a simpler reproducer</div><div> <div style="background-color:rgb(255,255,255);color:rgb(8,8,8)"><pre style="font-family:"JetBrains Mono",monospace;font-size:9.8pt"><span style="color:rgb(0,51,179)">import </span><span style="color:rgb(0,0,0)">java.util.function.Consumer</span>;<br><br><span style="color:rgb(0,51,179)">public class </span><span style="color:rgb(0,0,0)">GUI </span>{<br>   <span style="color:rgb(0,51,179)">public static void </span><span style="color:rgb(0,98,122)">main</span>(<span style="color:rgb(0,0,0)">String</span>[] args) {<br>     <span style="color:rgb(0,0,0)">Consumer</span><<span style="color:rgb(0,0,0)">String</span>> <span style="color:rgb(0,0,0)">op </span>= _ -> {};<br>   }<br>}</pre></div></div><div><br></div><div>javap shows the issue, the LocalVariableTable is generated with the name ""<br></div><div><br></div><div> <span style="font-family:"courier new",courier,monaco,monospace,sans-serif">private static void lambda$main$0(java.lang.String);</span><br><span style="font-family:"courier new",courier,monaco,monospace,sans-serif">    descriptor: (Ljava/lang/String;)V</span><br><span style="font-family:"courier new",courier,monaco,monospace,sans-serif">    flags: (0x100a) ACC_PRIVATE, ACC_STATIC, ACC_SYNTHETIC</span><br><span style="font-family:"courier new",courier,monaco,monospace,sans-serif">    Code:</span><br><span style="font-family:"courier new",courier,monaco,monospace,sans-serif">      stack=0, locals=1, args_size=1</span><br><span style="font-family:"courier new",courier,monaco,monospace,sans-serif">         0: return</span><br><span style="font-family:"courier new",courier,monaco,monospace,sans-serif">      LineNumberTable:</span><br><span style="font-family:"courier new",courier,monaco,monospace,sans-serif">        line 5: 0</span><br><span style="font-family:"courier new",courier,monaco,monospace,sans-serif">      LocalVariableTable:</span><br><span style="font-family:"courier new",courier,monaco,monospace,sans-serif">        Start  Length  Slot  Name   Signature</span><br><span style="font-family:"courier new",courier,monaco,monospace,sans-serif">            0       1     0         Ljava/lang/String;</span><br><br></div><div>The JVM spec 4.7.13 said<br></div><div><span>"<br></span></div><div><span>name_index</span><p style="margin:0px"><a name="m_-5640994534864175891_m_5116022894237422989_jvms-4.7.13-300-D-B"></a> The value of the <code>name_index</code> item must be a valid index into the <code>constant_pool</code> table. The <code>constant_pool</code> entry at that index must contain a <code>CONSTANT_Utf8_info</code> structure representing a valid unqualified name denoting a local variable (<a href="https://docs.oracle.com/javase/specs/jvms/se20/html/jvms-4.html#jvms-4.2.2" title="4.2.2. Unqualified Names" target="_blank">§4.2.2</a>).</p><p style="margin:0px">"<br></p></div><div><br></div><div>And 4.2.2 said that the string must have at least one code point, so "" is an invalid name, rightly rejected by the VM (the error message is just not great, it's not about a field but a local variable name, here a parameter inside the LocalVariableTable).<br></div><div><br></div><div>So it's a bug in the compiler, I see two ways to fix it, either do not generate a line in the LocalVariableTable if the parameter is unamed or use "_" instead.<br></div><div><br></div><div>regards,<br></div><div>Rémi<br></div><div><br></div><hr id="m_-5640994534864175891m_5116022894237422989zwchr"><div><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><b>From: </b>"David Alayachew" <<a href="mailto:davidalayachew@gmail.com" target="_blank">davidalayachew@gmail.com</a>><br><b>To: </b>"amber-dev" <<a href="mailto:amber-dev@openjdk.org" target="_blank">amber-dev@openjdk.org</a>><br><b>Sent: </b>Sunday, August 6, 2023 4:31:54 PM<br><b>Subject: </b>Re: Illegal field name when trying to compile with a javax.swing.Action<br></blockquote></div><div><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><div dir="ltr"><div class="gmail_default" style="font-family:monospace">Also, here is my version info.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace"><br>$ java --version<br>openjdk 21-ea 2023-09-19<br>OpenJDK Runtime Environment (build 21-ea+31-2444)<br>OpenJDK 64-Bit Server VM (build 21-ea+31-2444, mixed mode, sharing)</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace"><br>$ javac --version<br>javac 21-ea<br><br><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Aug 6, 2023 at 7:31 PM David Alayachew <<a href="mailto:davidalayachew@gmail.com" target="_blank">davidalayachew@gmail.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 dir="ltr"><div style="font-family:monospace" class="gmail_default"></div><div dir="ltr"><div class="gmail_default" style="font-family:monospace">Hello Amber Dev Team,</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default"><span style="font-family:monospace">I ran into a problem that I am not sure what the cause is. It only seems to occur when I am using unnamed variables.</span></div><div class="gmail_default"><span style="font-family:monospace"><br></span></div><div class="gmail_default"><span style="font-family:monospace"><br></span></div><div class="gmail_default"><span style="font-family:monospace">Here are the commands that I am using, as well as their outputs.</span></div><div class="gmail_default"><span style="font-family:monospace"><br></span></div><span style="font-family:monospace"><br>$ javac -g -Xlint:all,-preview,-serial -Xdiags:verbose --enable-preview --source 21 GUI.java<br>Note: GUI.java uses preview features of Java SE 21.<br></span><div><span style="font-family:monospace">Note: Recompile with -Xlint:preview for details.</span></div><div><span style="font-family:monospace"><br></span></div><div><div style="font-family:monospace" class="gmail_default"><br>$ java --enable-preview GUI<br>Error: LinkageError occurred while loading main class GUI<br>        java.lang.ClassFormatError: Illegal field name "" in class GUI</div><div style="font-family:monospace" class="gmail_default"><br></div><div style="font-family:monospace" class="gmail_default">And here is the file that I am using.</div><div style="font-family:monospace" class="gmail_default"><br></div><div style="font-family:monospace" class="gmail_default"><br>import javax.swing.JPanel;<br>import javax.swing.JLabel;<br>import javax.swing.JButton;<br>import java.util.function.BiFunction;<br><br>public class GUI<br>{<br><br>   public static void main(String[] args)<br>   {<br>   <br>      new GUI(null, null);<br>   <br>   }<br>   <br>   public GUI(final Object characterType, final Object icon)<br>   {<br>   <br>   }<br><br>   private Object createConstraintPanel()<br>   {<br>   <br>      final JPanel constraintPanel = new JPanel();<br>      final JButton              button = new JButton();<br>   <br>      CREATE_INPUT_SANITIZATION:<br>      {<br>      <br>         BUTTON_ACTION_LISTENER:<br>         {<br>         <br>            button<br>               .addActionListener<br>               (<br>                  _ -><br>                  {<br>                  <br>                     final BiFunction<String, Integer, JLabel> createLabel =<br>                        (text, width) -><br>                        {<br>                        <br>                           return null;<br>                        <br>                        }<br>                        ;<br>                     <br>                     final JButton remove = new JButton();<br>                     remove<br>                        .addActionListener<br>                        (<br>                           _ -> <br>                           {<br>                           <br>                           <br>                           }<br>                        );<br>                  <br>                  }<br>               )<br>               ;<br>         <br>         }<br>      <br>      }<br>   <br>      return constraintPanel;<br>   <br>   }<br><br>}<br></div></div><br><div><div style="font-family:monospace" class="gmail_default">Technically, this issue also occurs if even 1 of the 2 unnamed variables is turned into a real variable. But regardless, the point is, this fails at run time.</div><div style="font-family:monospace" class="gmail_default"><br></div><div style="font-family:monospace" class="gmail_default">Please let me know if there is anything I am missing.</div><div style="font-family:monospace" class="gmail_default"><br></div><div style="font-family:monospace" class="gmail_default">Thank you for your time and help!</div><div style="font-family:monospace" class="gmail_default">David Alayachew<br></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 18, 2023 at 1:54 AM David Alayachew <<a href="mailto:davidalayachew@gmail.com" target="_blank">davidalayachew@gmail.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 dir="ltr"><div style="font-family:monospace">Ok, ty for the heads up.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 18, 2023 at 1:18 AM - <<a href="mailto:liangchenblue@gmail.com" target="_blank">liangchenblue@gmail.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 dir="ltr">Hi David,<div>Please do not ask for technical support in the development mailing list. There's no proof that this issue is with the core libraries instead of the Java compiler or another component.</div><div>I have already downloaded your zip, compiled the 4 files with JDK 22 (my local dev build for another unrelated patch) javac --enable-preview -release 22 *.java and java --enable-preview ToDoList, which just shows up a UI without any crash. Without enable-preview, yoru code does not compile at all for the usage of _ as an identifier.</div><br><div>This is most likely a problem with the compiler you are using; you have a gpj file, which probably means you are using jGrasp. Please report this issue to the relevant parties (i.e. the 3rd-party IDE or whatever supports using _ as identifer without --enable-preview) instead.</div><br><div>Chen Liang</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 18, 2023 at 11:43 AM David Alayachew <<a href="mailto:davidalayachew@gmail.com" target="_blank">davidalayachew@gmail.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 dir="ltr"><div style="font-family:monospace">Wait, nevermind. Don't ignore. I was able to recreate this issue on the command line using the abovementioned JDK. Could someone come back and take a look at this please?</div><div style="font-family:monospace"><br></div><div style="font-family:monospace">Sorry for jerking everyone around here. I have multiple JDK's and got mixed up on which one I was using.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jul 16, 2023 at 2:26 AM David Alayachew <<a href="mailto:davidalayachew@gmail.com" target="_blank">davidalayachew@gmail.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 dir="ltr"><div style="font-family:monospace">Hmmmm, this one might actually be IDE specific. Please ignore.<br></div></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div></div>
</blockquote></div><br></blockquote></div></div></div></blockquote></div>
</blockquote></div>