git: openjdk/leyden: hermetic-java-runtime: Support accessing hermetic `modules` image (in host JDK only, currently) from jrtfs.

duke duke at openjdk.org
Tue Jan 23 23:07:27 UTC 2024


Changeset: e1f35d09
Author:    Jiangli Zhou <jianglizhou at google.com>
Date:      2024-01-23 14:38:50 +0000
URL:       https://git.openjdk.org/leyden/commit/e1f35d09ace675d8ff5093885313b5067a326e6f

Support accessing hermetic `modules` image (in host JDK only, currently) from jrtfs.

- Add jdk.internal.jimage.HermeticImageHelper. This class is packaged together with the jrtfs implementation classes. This solution is suggested by Liam Miller-Cushon, to allow properly supporting different cases described below. HermeticImageHelper's hermetic states are initialized during jdk.internal.misc.JavaHome <clinit> if executed in hermetic Java mode. HermeticImageHelper is used by jdk.internal.jrtfs.SystemImage if its CodeSource is null (target JDK == current JDK).

- Explicitly initialize jdk.internal.misc.JavaHome during VM initialization. This provides better control of initialization order related to JavaHome.

Discussed the approach (on the high-level) and different use cases with Alan Bateman, Liam Miller-Cushon, Ron Pressler and Severin Gehwolf. Following are the different cases:

Case 1 (new case): supported by this PR
- Host JDK = Target JDK
- Tool (host JDK) executes in hermetic mode

Case 2 (existing)
- Host JDK = Target JDK
- Tool (host JDK) executes non-hermetic

Case 3 (new case): not yet supported
- Host JDK != Target JDK
- Tool (host JDK) executes in hermetic mode
- Target JDK hermetic packaged

Case 4 (new case): works with existing OpenJDK jrtfs implementation
- Host JDK != Target JDK
- Tool (host JDK) executes in hermetic mode
- Target JDK not hermetic packaged

Case 5 (new case): not yet supported
- Host JDK != Target JDK
- Tool (host JDK) executes non-hermetic
- Tool (host JDK) executes in hermetic mode

Case 6 (existing)
- Host JDK != Target JDK
- Tool (host JDK) executes non-hermetic
- Target JDK not hermetic packaged

Case 7 (existing)
- Host JDK != Target JDK
- Tool runs on an older JDK version without hermetic support

! src/hotspot/share/classfile/vmSymbols.hpp
! src/hotspot/share/runtime/threads.cpp
! src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java
+ src/java.base/share/classes/jdk/internal/jimage/HermeticImageHelper.java
! src/java.base/share/classes/jdk/internal/jrtfs/SystemImage.java
! src/java.base/share/classes/jdk/internal/misc/JavaHome.java



More information about the leyden-dev mailing list