ajalt / mordant

Multiplatform text styling for Kotlin command-line applications
https://ajalt.github.io/mordant/
Apache License 2.0
976 stars 34 forks source link

Static JNI #174

Closed sgammon closed 3 months ago

sgammon commented 3 months ago

Heya @ajalt,

We at Elide use Mordant and soon will be using Clikt (thank you for your hard work!) to drive our CLI. However, we end up with a bunch of FFM, JNI, and JNA options at runtime, across all these different libraries. I know you have worked hard to thin the JNA requirement for Mordant, and along those lines, we have come up with a technique to make JNA easier, more reliable, and perhaps more performant by avoiding the initial library unpacking step altogether, at least for users building native via native-image.

Would you be open to adopting in Mordant should this linked PR get merged? If so, would you be open to helping review and test? JNA is a sensitive project and I am literally terrified contributing to it 😅 , so I am hoping to gather strength in numbers. Hopefully, if JNA over static JNI can improve startup speed for a lot of apps, then we can get it properly reviewed/vetted and merged.

Thanks either way for your awesome libraries. We really love using them!

Sam

ajalt commented 3 months ago

Thanks for the kind words! Your technique certainly looks interesting, but mordant uses graal's FFI directly for native-image. JNA is only used for regular JVM execution, so I don't believe that your change affects this library.

As an aside, the plan is to eventually add an FFM implementation so that JNA can be optional unless you're running on an old JDK.

sgammon commented 3 months ago

@ajalt No worries :) thanks for the response and for your awesome libs.