RFR: 8354675: Create separate image builder for hermetic [v3]

Severin Gehwolf sgehwolf at openjdk.org
Tue Apr 15 14:41:57 UTC 2025


> This is a start of a simple refactoring for moving hermetic handling into dedicated implementation classes. In this case I cover `ImageBuilder` and `ExecutableImage`. A similar change should be done for `ImageFileCreator` but that's for another PR.
> 
> @jianglizhou Please take a look. Thanks!
> 
> While at it I've observed the following:
> 
> 1. `<hermetic-image-file> --list-modules` doesn't seem to work. Shows [1] for me.
> 2. `strip -g <hermetic-image-file>` will destroy the image. Looks like [2]. Probably a drawback for tucking on the offset after the modules file? We might want to consider building in debuginfo handling into `jlink` itself. Like the `--strip-native-debug-symbols` plugin does (but doesn't work for hermetic, yet).
> 
> Thoughts?
> 
> [1]
> 
> $ ./demo-image -m mod.example/com.example.demo.Main
> [0.017s][warning][cds] Failed to open shared archive file (Not a directory)
> Hi
> $
> ./demo-image --list-modules
> [0.020s][warning][cds] Failed to open shared archive file (Not a directory)
> Exception in thread "main" java.lang.InternalError: Unable to detect the run-time image
> 	at java.base/jdk.internal.module.SystemModuleFinders.ofSystem(Unknown Source)
> 	at java.base/java.lang.module.ModuleFinder.ofSystem(Unknown Source)
> 	at java.base/jdk.internal.module.ModuleBootstrap.unlimitedFinder(Unknown Source)
> 	at java.base/jdk.internal.module.ModuleBootstrap.limitedFinder(Unknown Source)
> 	at java.base/sun.launcher.LauncherHelper.listModules(Unknown Source)
> 
> 
> [2] This is a build with `--with-native-debug-symbols=internal` (fastdebug)
> 
> $ ll -lh ./demo-image 
> -rwxr-xr-x. 1 sgehwolf sgehwolf 909M Apr 10 17:36 ./demo-image
> $ strip -g ./demo-image 
> $ ll -lh ./demo-image 
> -rwxr-xr-x. 1 sgehwolf sgehwolf 50M Apr 10 18:07 ./demo-image
> $ ./demo-image -m mod.example/com.example.demo.Main
> Error occurred during initialization of VM
> Failed setting boot class path.

Severin Gehwolf has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:

 - Merge branch 'hermetic-java-runtime' into hermetic-image-builder-cleanup
 - Review feedback
 - Create a separate image builder for hermetic

-------------

Changes:
  - all: https://git.openjdk.org/leyden/pull/55/files
  - new: https://git.openjdk.org/leyden/pull/55/files/cd2c884a..1d831551

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=leyden&pr=55&range=02
 - incr: https://webrevs.openjdk.org/?repo=leyden&pr=55&range=01-02

  Stats: 211168 lines in 860 files changed: 24075 ins; 183487 del; 3606 mod
  Patch: https://git.openjdk.org/leyden/pull/55.diff
  Fetch: git fetch https://git.openjdk.org/leyden.git pull/55/head:pull/55

PR: https://git.openjdk.org/leyden/pull/55


More information about the leyden-dev mailing list