|
30 | 30 |
|
31 | 31 | import org.graalvm.nativeimage.Platform;
|
32 | 32 | import org.graalvm.nativeimage.Platforms;
|
| 33 | +import org.graalvm.nativeimage.hosted.RuntimeReflection; |
33 | 34 |
|
| 35 | +import com.oracle.svm.core.FutureDefaultsOptions; |
34 | 36 | import com.oracle.svm.core.SubstrateUtil;
|
35 | 37 | import com.oracle.svm.core.annotate.Alias;
|
36 | 38 | import com.oracle.svm.core.annotate.InjectAccessors;
|
37 | 39 | import com.oracle.svm.core.annotate.TargetClass;
|
| 40 | +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; |
| 41 | +import com.oracle.svm.core.feature.InternalFeature; |
38 | 42 | import com.oracle.svm.core.jdk.JDKInitializedAtRunTime;
|
| 43 | +import com.oracle.svm.core.jdk.resources.NativeImageResourceFileSystemProvider; |
39 | 44 | import com.oracle.svm.core.util.BasedOnJDKFile;
|
40 | 45 | import com.oracle.svm.core.util.VMError;
|
41 | 46 | import com.oracle.svm.util.ReflectionUtil;
|
|
51 | 56 | final class FileSystemProviderRuntimeInitSupport {
|
52 | 57 | }
|
53 | 58 |
|
| 59 | +@AutomaticallyRegisteredFeature |
| 60 | +final class FileSystemProviderRunTimeInitFeature implements InternalFeature { |
| 61 | + |
| 62 | + @Override |
| 63 | + public boolean isInConfiguration(IsInConfigurationAccess access) { |
| 64 | + return FutureDefaultsOptions.isJDKInitializedAtRunTime(); |
| 65 | + } |
| 66 | + |
| 67 | + @Override |
| 68 | + public void beforeAnalysis(BeforeAnalysisAccess access) { |
| 69 | + if (FutureDefaultsOptions.isJDKInitializedAtRunTime()) { |
| 70 | + /* |
| 71 | + * Explicitly register NativeImageResourceFileSystemProvider for reflective |
| 72 | + * instantiation. Normally, the ServiceLoaderFeature does this as well, but in case it |
| 73 | + * is turned off (-H:-UseServiceLoaderFeature), we should still at least register our |
| 74 | + * own provider. |
| 75 | + */ |
| 76 | + RuntimeReflection.register(NativeImageResourceFileSystemProvider.class); |
| 77 | + RuntimeReflection.registerForReflectiveInstantiation(NativeImageResourceFileSystemProvider.class); |
| 78 | + } |
| 79 | + } |
| 80 | +} |
| 81 | + |
54 | 82 | // java.io
|
55 | 83 |
|
56 | 84 | @TargetClass(className = "java.io.FileSystem", onlyWith = JDKInitializedAtRunTime.class)
|
|
0 commit comments