-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
Make Javalin more GraalVM friendly #236
Comments
How can we achieve that while still targeting Java 17? |
Not sure, that would have to be looked into. The first thing that comes to mind is that it's maybe possible to refactor ReflectiveVirtualThreadBuilder so that the "unstarted" method gets correctly invoked by GraalVMs native-image compiler. One would have to experiment with different solutions until one finds something that works. How does the other frameworks solve this problem (Spring, Micronaut etc)? |
One possible solution could be to create a single instance of a virtual thread factory ( |
I got around this issue when upgrading to Javalin 6. I can now set the Jetty thread pool directly myself.
For reference I previously used the GraalVM SDK to override the use of reflection in Javalin's NamedVirtualThreadFactory. This has now been removed.
|
I assume this issue can be closed. Maybe the Javalin documentation can be updated with the code above in case someone else tries to use Javalin with GraalVM? |
Is your feature request related to a problem? Please describe.
I've been looking into having Javalin run on GraalVM. In that process I ran into a bug in GraalVM as described here. This bug prevents you from running Javalin with virtual threads in a native image.
The main problem is that GraalVM fails to correctly handle a reflective call in ConcurrencyUtil.kt when creating a new virtual thread.
Even though this isn't Javalins fault it will still block anyone who wants to use GraalVM and Javalin. I also suspect this bug wont get fixed for a while at GraalVMs side. Since the official release of virtual threads in Java 21 is just around the corner I think it'd be beneficial if this problem could get fixed at Javalins side before Java 21 is released.
Describe the solution you'd like
The fix would mean rewriting ConcurrencyUtil.kt to either not use reflection, or refactor it in such a way that it works with GraalVM.
Additional context
As a sidenote I have managed to create a temporary workaround as described in this thread in the GraalVM slack chat.
The text was updated successfully, but these errors were encountered: