Skip to content

Commit 75a1b8e

Browse files
committed
Ensure jimage static jdk library get statically linked
1 parent 8ce7298 commit 75a1b8e

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JRTSupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
*/
6262
public final class JRTSupport {
6363

64-
static class Options {
64+
public static class Options {
6565
@Option(help = "Enable support for reading Java modules (jimage format) and the jrt:// file system. Requires java.home to be set at runtime.", type = OptionType.Expert) //
6666
public static final HostedOptionKey<Boolean> AllowJRTFileSystem = new HostedOptionKey<>(false);
6767
}

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JRTFeature.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,30 @@
2828

2929
import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
3030
import com.oracle.svm.core.feature.InternalFeature;
31+
import com.oracle.svm.core.jdk.JRTSupport;
32+
import com.oracle.svm.core.jdk.NativeLibrarySupport;
3133
import com.oracle.svm.hosted.FeatureImpl;
3234

3335
@AutomaticallyRegisteredFeature
3436
public class JRTFeature implements InternalFeature {
3537

38+
private static final String JIMAGE_LIBRARY_NAME = "jimage";
39+
40+
@Override
41+
public boolean isInConfiguration(IsInConfigurationAccess access) {
42+
return JRTSupport.Options.AllowJRTFileSystem.getValue();
43+
}
44+
45+
@Override
46+
public void duringSetup(DuringSetupAccess access) {
47+
NativeLibrarySupport.singleton().preregisterUninitializedBuiltinLibrary(JIMAGE_LIBRARY_NAME);
48+
}
49+
3650
@Override
3751
public void beforeAnalysis(BeforeAnalysisAccess access) {
3852
access.registerReachabilityHandler(duringAnalysisAccess -> {
3953
FeatureImpl.BeforeAnalysisAccessImpl beforeAnalysisAccess = (FeatureImpl.BeforeAnalysisAccessImpl) access;
40-
beforeAnalysisAccess.getNativeLibraries().addStaticJniLibrary("jimage");
54+
beforeAnalysisAccess.getNativeLibraries().addStaticJniLibrary(JIMAGE_LIBRARY_NAME);
4155
if (!Platform.includedIn(Platform.WINDOWS.class)) {
4256
beforeAnalysisAccess.getNativeLibraries().addDynamicNonJniLibrary("stdc++");
4357
}

0 commit comments

Comments
 (0)