Anyone using Lanterna and GraalVM native-image?

41 views
Skip to first unread message

Steve George

unread,
May 23, 2020, 4:06:21 AM5/23/20
to lanterna-discuss
Hi,

I'm wondering if anyone has had any success creating GraalVM native-image's when using Lanterna?

So far I've discovered that Graal doesn't work with AWT/Swing so this discounts DefaultTerminalFactory.  Before I try further hoping someone has done this and can provide any hints or an example.

Thanks,

Steve


Martin Berglund

unread,
May 31, 2020, 2:07:18 AM5/31/20
to lanterna...@googlegroups.com
Hi Steve,
There are some discussions about GraalVM here:
I haven't looked into it myself.

Martin

--
Det här meddelandet skickas till dig eftersom du prenumererar på gruppen "lanterna-discuss" i Google Grupper.
Om du vill sluta prenumerera på den här gruppen och inte längre få någon e-post från den skickar du ett e-postmeddelande till lanterna-discu...@googlegroups.com.
Om du vill visa den här diskussionen på webben besöker du https://groups.google.com/d/msgid/lanterna-discuss/84eacd5a-a834-488a-875a-682339f1e9b3%40googlegroups.com.

Steve George

unread,
Jun 15, 2020, 6:47:36 AM6/15/20
to lanterna-discuss
Hi Martin,

I've got this working on GraalVM 20.1.0 which is the current release. I have worked through the tutorial and compiled terminal, screen and GUI programs to full native image.

I've commented on the GitHub issue so others know it is possible. I think it's clear on the issue that it is possible, but here are some details on what I've done so far.

I'm using OpenJDK 11 and Clojure 1.10.1, I did create one test (terminal) program in Java and that was also fine. I'm compiling and testing under Linux (Ubuntu 16.04 / 20.04) with Xterm.

There were two issues:

1. Swing/AWT dependency
GraalVM doesn't support either of these: there's a lot of differing reports but pretty much all failure for both. I think there might be better ways to do this, but I just stopped using `DefaultTerminalFactory` and directly call UnixTerminal

In Clojure this means that I import com.googlecode.lanterna.terminal.Terminal and com.googlecode.lanterna.terminal.ansi.UnixTerminal

2. Class Dependencies when compiling
It's sometimes a bit difficult to work out all the classes that GraalVM will need. It has a "tracing agent" that you can run and it will figure out the classes that are used at runtime, this can then be fed into the compile stage. This made things easier for me, though may not be strictly necessary.

I've got the basics going, WindowBasedTextGUI adding Buttons and Labels. So far no reason to believe that other Components won't be fine as well.

Thanks,

Steve


On Sunday, May 31, 2020 at 7:07:18 AM UTC+1, Martin wrote:
Hi Steve,
There are some discussions about GraalVM here:
I haven't looked into it myself.

Martin

Den lör 23 maj 2020 kl 17:06 skrev Steve George <slge...@gmail.com>:
Hi,

I'm wondering if anyone has had any success creating GraalVM native-image's when using Lanterna?

So far I've discovered that Graal doesn't work with AWT/Swing so this discounts DefaultTerminalFactory.  Before I try further hoping someone has done this and can provide any hints or an example.

Thanks,

Steve


--
Det här meddelandet skickas till dig eftersom du prenumererar på gruppen "lanterna-discuss" i Google Grupper.
Om du vill sluta prenumerera på den här gruppen och inte längre få någon e-post från den skickar du ett e-postmeddelande till lanterna...@googlegroups.com.

Martin Berglund

unread,
Jun 21, 2020, 6:32:51 AM6/21/20
to lanterna...@googlegroups.com
I've backported the reflection calls on DefaultTerminalFactory to 3.0, so it doesn't try to import any of the AWT/Swing classes, but I'm not sure if it's enough to make it work.

Martin

Om du vill sluta prenumerera på den här gruppen och inte längre få någon e-post från den skickar du ett e-postmeddelande till lanterna-discu...@googlegroups.com.
Om du vill visa den här diskussionen på webben besöker du https://groups.google.com/d/msgid/lanterna-discuss/931f5bfa-7671-4b6d-b693-d7f6c77f60eao%40googlegroups.com.

Steve George

unread,
Jun 29, 2020, 7:40:42 AM6/29/20
to lanterna...@googlegroups.com
Hi Martin,

I spent quite a lot of time on this, it gets further but I couldn't get it to complete.

I created a new issue:


Thanks,

Steve

Reply all
Reply to author
Forward
0 new messages