Illegal field name when trying to compile with a javax.swing.Action
David Alayachew
davidalayachew at gmail.com
Sun Aug 6 23:31:14 UTC 2023
Hello Amber Dev Team,
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.
Here are the commands that I am using, as well as their outputs.
$ javac -g -Xlint:all,-preview,-serial -Xdiags:verbose --enable-preview
--source 21 GUI.java
Note: GUI.java uses preview features of Java SE 21.
Note: Recompile with -Xlint:preview for details.
$ java --enable-preview GUI
Error: LinkageError occurred while loading main class GUI
java.lang.ClassFormatError: Illegal field name "" in class GUI
And here is the file that I am using.
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JButton;
import java.util.function.BiFunction;
public class GUI
{
public static void main(String[] args)
{
new GUI(null, null);
}
public GUI(final Object characterType, final Object icon)
{
}
private Object createConstraintPanel()
{
final JPanel constraintPanel = new JPanel();
final JButton button = new JButton();
CREATE_INPUT_SANITIZATION:
{
BUTTON_ACTION_LISTENER:
{
button
.addActionListener
(
_ ->
{
final BiFunction<String, Integer, JLabel> createLabel =
(text, width) ->
{
return null;
}
;
final JButton remove = new JButton();
remove
.addActionListener
(
_ ->
{
}
);
}
)
;
}
}
return constraintPanel;
}
}
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.
Please let me know if there is anything I am missing.
Thank you for your time and help!
David Alayachew
On Tue, Jul 18, 2023 at 1:54 AM David Alayachew <davidalayachew at gmail.com>
wrote:
> Ok, ty for the heads up.
>
> On Tue, Jul 18, 2023 at 1:18 AM - <liangchenblue at gmail.com> wrote:
>
>> Hi David,
>> 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.
>> 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.
>>
>> 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.
>>
>> Chen Liang
>>
>> On Tue, Jul 18, 2023 at 11:43 AM David Alayachew <
>> davidalayachew at gmail.com> wrote:
>>
>>> 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?
>>>
>>> Sorry for jerking everyone around here. I have multiple JDK's and got
>>> mixed up on which one I was using.
>>>
>>> On Sun, Jul 16, 2023 at 2:26 AM David Alayachew <
>>> davidalayachew at gmail.com> wrote:
>>>
>>>> Hmmmm, this one might actually be IDE specific. Please ignore.
>>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20230806/7dee59aa/attachment.htm>
More information about the amber-dev
mailing list