|
31 | 31 | import java.nio.ByteBuffer; |
32 | 32 | import java.nio.file.FileSystem; |
33 | 33 | import java.nio.file.Path; |
34 | | -import java.util.Arrays; |
35 | 34 | import java.util.HashMap; |
36 | | -import java.util.HashSet; |
37 | 35 | import java.util.Map; |
| 36 | +import java.util.Set; |
38 | 37 | import java.util.concurrent.ConcurrentHashMap; |
39 | 38 | import java.util.function.BooleanSupplier; |
40 | 39 |
|
| 40 | +import org.graalvm.nativeimage.hosted.RuntimeClassInitialization; |
| 41 | + |
41 | 42 | import com.oracle.svm.core.annotate.Alias; |
42 | 43 | import com.oracle.svm.core.annotate.Delete; |
43 | 44 | import com.oracle.svm.core.annotate.RecomputeFieldValue; |
|
49 | 50 | import com.oracle.svm.core.jdk.JRTSupport.JRTEnabled; |
50 | 51 | import com.oracle.svm.core.option.HostedOptionKey; |
51 | 52 | import com.oracle.svm.core.util.VMError; |
| 53 | +import com.oracle.svm.util.ReflectionUtil; |
52 | 54 |
|
53 | 55 | import jdk.graal.compiler.options.Option; |
54 | 56 | import jdk.graal.compiler.options.OptionType; |
@@ -84,17 +86,14 @@ public boolean getAsBoolean() { |
84 | 86 | } |
85 | 87 |
|
86 | 88 | @AutomaticallyRegisteredFeature |
87 | | -class JRTDisableFeature implements InternalFeature { |
88 | | - |
89 | | - @Override |
90 | | - public boolean isInConfiguration(IsInConfigurationAccess access) { |
91 | | - return !JRTSupport.Options.AllowJRTFileSystem.getValue(); |
92 | | - } |
93 | | - |
94 | | - @SuppressWarnings("unchecked") |
| 89 | +class JRTFeature implements InternalFeature { |
95 | 90 | @Override |
96 | 91 | public void beforeAnalysis(BeforeAnalysisAccess access) { |
97 | | - ServiceCatalogSupport.singleton().removeServicesFromServicesCatalog("java.nio.file.spi.FileSystemProvider", new HashSet<>(Arrays.asList("jdk.internal.jrtfs.JrtFileSystemProvider"))); |
| 92 | + if (JRTSupport.Options.AllowJRTFileSystem.getValue()) { |
| 93 | + RuntimeClassInitialization.initializeAtRunTime(ReflectionUtil.lookupClass("jdk.internal.jrtfs.SystemImage")); |
| 94 | + } else { |
| 95 | + ServiceCatalogSupport.singleton().removeServicesFromServicesCatalog("java.nio.file.spi.FileSystemProvider", Set.of("jdk.internal.jrtfs.JrtFileSystemProvider")); |
| 96 | + } |
98 | 97 | } |
99 | 98 | } |
100 | 99 |
|
|
0 commit comments