Bug 567958 - GraalVM: provide json config file for fields/methods to keep for native-to-Java invocation
Summary: GraalVM: provide json config file for fields/methods to keep for native-to-Ja...
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.18   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-17 03:26 EDT by Thomas Singer CLA
Modified: 2020-10-19 17:25 EDT (History)
4 users (show)

See Also:


Attachments
script, configuration for tiny SWT code (1.89 KB, application/x-zip-compressed)
2020-10-17 03:27 EDT, Thomas Singer CLA
no flags Details
build script with some stuff I had to add. (649 bytes, application/octet-stream)
2020-10-18 05:51 EDT, Wim Jongman CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Singer CLA 2020-10-17 03:26:34 EDT
I'm experimenting with GraalVM to compile an SWT application to native. So far it worked out, but only by a lot of manual steps for the json file that contains a list of all Java fields/methods that need to be kept for accessing from swt native libraries.
Comment 1 Thomas Singer CLA 2020-10-17 03:27:57 EDT
Created attachment 284492 [details]
script, configuration for tiny SWT code
Comment 2 Thomas Singer CLA 2020-10-17 03:30:49 EDT
- unpack the .zip file in an empty directory
- put the org.eclipse.swt.win32.win32.x86_64.jar as swt.jar in that directory
- extract the swt-win32-<build>.dll from the swt.jar as swt-win32.dll in parallel
- invoke build.cmd
=> an .exe file of ~15MB will be created
- run that .exe file and enjoy a native SWT application
Comment 3 Wim Jongman CLA 2020-10-17 08:20:52 EDT
Thomas, this is very interesting. However, it is not clear what you request with this bug.
Comment 4 Thomas Singer CLA 2020-10-17 14:49:38 EDT
I thought, the subject would be clear enough?
Comment 5 Wim Jongman CLA 2020-10-18 05:51:37 EDT
Created attachment 284499 [details]
build script with some stuff I had to add.

(In reply to Thomas Singer from comment #4)
> I thought, the subject would be clear enough?

If you think the subject has the complete requirement then it is fine. I did not know GraalVM so I would have liked some more information.

(In reply to Thomas Singer from comment #1)
> Created attachment 284492 [details]
> script, configuration for tiny SWT code

I tried your example from scratch.

* After downloading GraalVM the script complained about missing install-image
* I did: gu install native-image

Then I found that it required VS so I installed the community edition and the C++ components. 

After this was done, it still did not build. The process complained about DPUtil being intialized at build time and the script suggested to add:

* -H:+TraceClassInitialization

and after that it suggested to add:

* --initialize-at-build-time=org.eclipse.swt.internal.DPIUtil

After this was done, the buld succeeded. And I had a 23MB exe that worked.

I have attached the updated script for anyone interested.
Comment 6 Thomas Singer CLA 2020-10-19 03:30:46 EDT
My created executable has a size of 15MB and the steps work fine on 2 different systems. I just had to use the Visual Studio Installer 2019 to install the C++ build tools.

BTW, use

$ editbin /SUBSYSTEM:Windows main.exe

to remove the console window that occurs when launching. With RCEdit from https://github.com/electron/rcedit it is easy to set an icon for the created executable.