23
23
* questions.
24
24
*/
25
25
26
- package com .oracle .svm .core .jdk ;
26
+ package com .oracle .svm .core .jdk . buildtimeinit ;
27
27
28
28
import java .nio .file .spi .FileSystemProvider ;
29
29
import java .util .ArrayList ;
45
45
import com .oracle .svm .core .annotate .TargetElement ;
46
46
import com .oracle .svm .core .feature .AutomaticallyRegisteredFeature ;
47
47
import com .oracle .svm .core .feature .InternalFeature ;
48
+ import com .oracle .svm .core .jdk .JDKInitializedAtBuildTime ;
49
+ import com .oracle .svm .core .jdk .JRTSupport ;
50
+ import com .oracle .svm .core .jdk .SystemPropertiesSupport ;
51
+ import com .oracle .svm .core .jdk .UserSystemProperty ;
48
52
import com .oracle .svm .core .option .HostedOptionKey ;
49
53
import com .oracle .svm .core .util .BasedOnJDKFile ;
50
54
import com .oracle .svm .core .util .VMError ;
51
55
52
56
import jdk .graal .compiler .options .Option ;
53
57
import jdk .internal .util .StaticProperty ;
54
58
55
- public final class FileSystemProviderSupport {
59
+ /**
60
+ * This file contains substitutions that are required for initializing {@link FileSystemProvider} at
61
+ * image {@linkplain JDKInitializedAtBuildTime build time}. Other related functionality (general and
62
+ * run-time initialization) can be found in
63
+ * {@link com.oracle.svm.core.jdk.runtimeinit.FileSystemProviderRuntimeInitSupport}.
64
+ *
65
+ * @see JDKInitializedAtBuildTime
66
+ * @see com.oracle.svm.core.jdk.runtimeinit.FileSystemProviderRuntimeInitSupport
67
+ */
68
+ public final class FileSystemProviderBuildTimeInitSupport {
56
69
57
70
public static class Options {
58
71
@ Option (help = "Make all supported providers returned by FileSystemProvider.installedProviders() available at run time." )//
@@ -63,7 +76,7 @@ public static class Options {
63
76
final List <FileSystemProvider > installedProvidersImmutable ;
64
77
65
78
@ Platforms (Platform .HOSTED_ONLY .class )
66
- FileSystemProviderSupport (List <FileSystemProvider > installedProviders ) {
79
+ FileSystemProviderBuildTimeInitSupport (List <FileSystemProvider > installedProviders ) {
67
80
this .installedProvidersMutable = installedProviders ;
68
81
this .installedProvidersImmutable = Collections .unmodifiableList (installedProviders );
69
82
}
@@ -75,7 +88,7 @@ public static class Options {
75
88
*/
76
89
@ Platforms (Platform .HOSTED_ONLY .class )
77
90
public static void register (FileSystemProvider provider ) {
78
- List <FileSystemProvider > installedProviders = ImageSingletons .lookup (FileSystemProviderSupport .class ).installedProvidersMutable ;
91
+ List <FileSystemProvider > installedProviders = ImageSingletons .lookup (FileSystemProviderBuildTimeInitSupport .class ).installedProvidersMutable ;
79
92
80
93
String scheme = provider .getScheme ();
81
94
for (int i = 0 ; i < installedProviders .size (); i ++) {
@@ -98,7 +111,7 @@ public static void register(FileSystemProvider provider) {
98
111
*/
99
112
@ Platforms (Platform .HOSTED_ONLY .class )
100
113
public static void remove (String scheme ) {
101
- List <FileSystemProvider > installedProviders = ImageSingletons .lookup (FileSystemProviderSupport .class ).installedProvidersMutable ;
114
+ List <FileSystemProvider > installedProviders = ImageSingletons .lookup (FileSystemProviderBuildTimeInitSupport .class ).installedProvidersMutable ;
102
115
103
116
for (int i = 0 ; i < installedProviders .size (); i ++) {
104
117
/*
@@ -115,12 +128,12 @@ public static void remove(String scheme) {
115
128
}
116
129
117
130
@ AutomaticallyRegisteredFeature
118
- final class FileSystemProviderFeature implements InternalFeature {
131
+ final class FileSystemProviderBuildTimeInitFeature implements InternalFeature {
119
132
120
133
@ Override
121
134
public void afterRegistration (AfterRegistrationAccess access ) {
122
135
List <FileSystemProvider > installedProviders = new ArrayList <>();
123
- if (FileSystemProviderSupport .Options .AddAllFileSystemProviders .getValue ()) {
136
+ if (FileSystemProviderBuildTimeInitSupport .Options .AddAllFileSystemProviders .getValue ()) {
124
137
/*
125
138
* The first invocation of FileSystemProvider.installedProviders() causes the default
126
139
* provider to be initialized (if not already initialized) and loads any other installed
@@ -133,11 +146,11 @@ public void afterRegistration(AfterRegistrationAccess access) {
133
146
*/
134
147
installedProviders .addAll (FileSystemProvider .installedProviders ());
135
148
}
136
- ImageSingletons .add (FileSystemProviderSupport .class , new FileSystemProviderSupport (installedProviders ));
149
+ ImageSingletons .add (FileSystemProviderBuildTimeInitSupport .class , new FileSystemProviderBuildTimeInitSupport (installedProviders ));
137
150
138
151
/* Access to Java modules (jimage/jrtfs access) in images is experimental. */
139
152
if (!JRTSupport .Options .AllowJRTFileSystem .getValue ()) {
140
- FileSystemProviderSupport .remove ("jrt" );
153
+ FileSystemProviderBuildTimeInitSupport .remove ("jrt" );
141
154
}
142
155
}
143
156
}
@@ -146,7 +159,7 @@ public void afterRegistration(AfterRegistrationAccess access) {
146
159
final class Target_java_nio_file_spi_FileSystemProvider {
147
160
@ Substitute
148
161
public static List <FileSystemProvider > installedProviders () {
149
- return ImageSingletons .lookup (FileSystemProviderSupport .class ).installedProvidersImmutable ;
162
+ return ImageSingletons .lookup (FileSystemProviderBuildTimeInitSupport .class ).installedProvidersImmutable ;
150
163
}
151
164
}
152
165
@@ -160,7 +173,8 @@ public static List<FileSystemProvider> installedProviders() {
160
173
*
161
174
* a) Disallow UnixFileSystem and UnixFileSystemProvider in the image heap, i.e., create all
162
175
* instances at run time. This is undesirable because then all file system providers need to be
163
- * loaded at run time, i.e., the caching in {@link FileSystemProviderSupport} would no longer work.
176
+ * loaded at run time, i.e., the caching in {@link FileSystemProviderBuildTimeInitSupport} would no
177
+ * longer work.
164
178
*
165
179
* b) Disallow UnixFileSystem in the image heap, but have the UnixFileSystemProvider instance in the
166
180
* image heap. This requires a recomputation of the field UnixFileSystemProvider.theFileSystem at
0 commit comments