Skip to content

Commit c0c6676

Browse files
Initialize jdk.internal.jrtfs.SystemImage at runtime if JRTFS is enabled
1 parent ba1a090 commit c0c6676

File tree

1 file changed

+10
-11
lines changed
  • substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk

1 file changed

+10
-11
lines changed

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@
3131
import java.nio.ByteBuffer;
3232
import java.nio.file.FileSystem;
3333
import java.nio.file.Path;
34-
import java.util.Arrays;
3534
import java.util.HashMap;
36-
import java.util.HashSet;
3735
import java.util.Map;
36+
import java.util.Set;
3837
import java.util.concurrent.ConcurrentHashMap;
3938
import java.util.function.BooleanSupplier;
4039

40+
import org.graalvm.nativeimage.hosted.RuntimeClassInitialization;
41+
4142
import com.oracle.svm.core.annotate.Alias;
4243
import com.oracle.svm.core.annotate.Delete;
4344
import com.oracle.svm.core.annotate.RecomputeFieldValue;
@@ -49,6 +50,7 @@
4950
import com.oracle.svm.core.jdk.JRTSupport.JRTEnabled;
5051
import com.oracle.svm.core.option.HostedOptionKey;
5152
import com.oracle.svm.core.util.VMError;
53+
import com.oracle.svm.util.ReflectionUtil;
5254

5355
import jdk.graal.compiler.options.Option;
5456
import jdk.graal.compiler.options.OptionType;
@@ -84,17 +86,14 @@ public boolean getAsBoolean() {
8486
}
8587

8688
@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 {
9590
@Override
9691
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+
}
9897
}
9998
}
10099

0 commit comments

Comments
 (0)