badass-runtime-plugin icon indicating copy to clipboard operation
badass-runtime-plugin copied to clipboard

Improve support for JDKs like Temurin that implement JEP 493 (Linking Run-Time Images without JMODs)

Open xzel23 opened this issue 3 months ago • 1 comments

I have applied PR #160 so that we have initial support for JEP 493 enabled JDKs like Temurin 24. This works if the user supplies the list of modules; the SuggestedModulesBuilder class however still relies on the jmods being present so the list of modules cannot be determined automatically.

A quick outline to fully support JEP 493 (untested, suggested by AI Assistant, but seems doable):

What to do:

  • Mount the runtime image via FileSystems.newFileSystem(URI.create("jrt:/"), Map.of()) or getFileSystem if already mounted.
  • Iterate /modules//module-info.class.
  • For each module-info.class, read bytes and call ModuleDescriptor.read(InputStream).
  • Collect md.exports().stream().map(Exports::source) per module.

Why this works:

  • It uses only public APIs and works for both: JDKs with jmods and JDKs without them (using the modules image).
  • No dependency on internal jimage APIs or on the existence of $JAVA_HOME/jmods.
  • Works on any modular JDK.

xzel23 avatar Sep 30 '25 11:09 xzel23

Note to self: use ${JAVA_HOME}/lib/rt-fs.jar introduced in Java 11.

xzel23 avatar Oct 01 '25 00:10 xzel23