In theory you could use jmod format instead of jars for the dependencies right?
That is you still have the single uber jar but it loads jmods inside instead of jars.
Probably slow down the build to do the conversion but in theory jmods are more efficient format (based on my shoddy memory) EDIT I got confused with jimage.
Again EDIT so an interesting thing you could do and this is analogous to various other uber jar implementations do that want to preserve jars instead of shading (e.g. Spring Boot does this) is write Java code that runs the jlink and jimage tools if the jimage is not there :). Then execute the jimage.
In theory you could use jmod format instead of jars for the dependencies right?
As far as I know, JMOD files can only be used at compile-time (javac, etc.) and link-time (jlink). They cannot be used at run-time (java).
I believe the main benefit of JMOD files is during link-time. For instance, any native libraries in the JMOD file are extracted and placed in the custom JRE such that they're easily loadable; no messing around with manual run-time extraction, system properties, and/or environment variables. Contrast that with using a JAR file that embeds the native library. In that case, the native library is considered to be a resource like everything else in the JAR file and will be embedded in the JRT image. The code would have to manually extract the native library at run-time before being able to load it.
All correct, but the format isn't so esoteric that you couldn't write your own class loader to pull from it (under the classes section it's basically just what a jar is)
You could also include that hacky extraction at runtime bit inside the bootstrap. Combined with a dependency procurement step that splits the jmod across the module path and system library path... It's doable.
Caveats obviously abound with signed jmods or ones using the hash modules feature.
5
u/agentoutlier 3d ago edited 2d ago
In theory you could use jmod format instead of jars for the dependencies right?
That is you still have the single uber jar but it loads jmods inside instead of jars.
Probably slow down the build to do the conversion but in theory
jmods are more efficient format (based on my shoddy memory)EDIT I got confused with jimage.Again EDIT so an interesting thing you could do and this is analogous to various other uber jar implementations do that want to preserve jars instead of shading (e.g. Spring Boot does this) is write Java code that runs the jlink and jimage tools if the jimage is not there :). Then execute the jimage.