Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add java AWT support #2545

Open
SDIDSA opened this issue Jun 5, 2020 · 3 comments
Open

Add java AWT support #2545

SDIDSA opened this issue Jun 5, 2020 · 3 comments

Comments

@SDIDSA
Copy link

SDIDSA commented Jun 5, 2020

this feature request must be submitted to the substrate VM team but I don't know where can I do that

add java AWT support

the feature is related to the IllegalArgumentException that occurs when you try to run a native image of an AWT based java app that was compiled with GraalVM
java.lang.IllegalArgumentException: AWT is currently not supported on Substrate VM

the native image gets generated correctly and the exception would be thrown in run time whenever you try to use a java AWT function.

anyone who uses java AWT to develop desktop applications with java, and more generally anyone who needs a feature that is supported by java AWT and not JavaFX yet (adding system tray icons, for instance, or displaying system notifications are features that are not (yet) implemented in JavaFX and a developer has to use the said functionalities from AWT)

@SDIDSA SDIDSA added the feature label Jun 5, 2020
@fniephaus
Copy link
Member

TruffleSqueak uses AWT in JVM mode and we replace the display infrastructure with an SDL2 backend when AOT compiling with native image:
https://github.com/hpi-swa/trufflesqueak/blob/master/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/aot/SDL.java

@SDIDSA
Copy link
Author

SDIDSA commented Jun 6, 2020

TruffleSqueak uses AWT in JVM mode and we replace the display infrastructure with an SDL2 backend when AOT compiling with native image

This seems promising for my needs and assuming I understood correctly, I will need to replace any AWT use in my project with de.hpi.swa.trufflesqueak.aot before creating the native image
I still have some questions :

  • Does the SDL2 binding for SubstrateVM (provided with truffleSqueak) provide an implementation for all the functionalities provided by java AWT?
  • Will the resulting native-image be JVM independent?

@fniephaus
Copy link
Member

Does the SDL2 binding for SubstrateVM (provided with truffleSqueak) provide an implementation for all the functionalities provided by java AWT?

There's no direct mapping, you have to substitute your AWT-based components with an alternative SDL implementation. Here're TruffleSqueak's substitutions: https://github.com/hpi-swa/trufflesqueak/blob/6847f0220af9d65e352ffe1709b3cd2c3a48e664/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/aot/SqueakDisplaySubstitutions.java#L51

Will the resulting native-image be JVM independent?

Yes, but the binary will depend on SDL (which is available for different platforms). So that means users must install it on their system.

I'd consider this approach a workaround until AWT is fully supported by native image. I assume, however, that this will take some time unless someone really needs and builds it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants