49
49
import com .oracle .svm .core .feature .InternalFeature ;
50
50
import com .oracle .svm .core .option .HostedOptionKey ;
51
51
52
+ import jdk .internal .util .StaticProperty ;
53
+
52
54
public final class FileSystemProviderSupport {
53
55
54
56
public static class Options {
@@ -193,12 +195,12 @@ final class Target_sun_nio_fs_UnixFileSystem {
193
195
private Target_sun_nio_fs_UnixPath rootDirectory ;
194
196
195
197
/**
196
- * Flag to check if re-initialization at run time already happened. The initial value of this
197
- * flag in the image heap is non-zero, and it is set to zero when re-initialization is done.
198
- * This ensures that UnixFileSystem instances allocated at run time are not re-initialized,
199
- * because they are allocated with the field value . Note that UnixFileSystem instances should
200
- * not be allocated at run time, since only the singleton from the image heap should exist.
201
- * However, there were JDK bugs in various JDK versions where unwanted allocations happened.
198
+ * Flag to check if reinitialization at run time is needed. For objects in the image heap, this
199
+ * field is initially non-zero and set to zero after reinitialization. If UnixFileSystem
200
+ * instances are allocated at run time, the field will be set to zero right away (default value)
201
+ * as there is no need for reinitialization . Note that UnixFileSystem instances should not be
202
+ * allocated at run time, as only the singleton from the image heap should exist. However, there
203
+ * were JDK bugs in various JDK versions where unwanted allocations happened.
202
204
*/
203
205
@ Inject //
204
206
@ RecomputeFieldValue (kind = Kind .Custom , declClass = NeedsReinitializationProvider .class )//
@@ -293,6 +295,10 @@ static void setRootDirectory(Target_sun_nio_fs_UnixFileSystem that, Target_sun_n
293
295
that .injectedRootDirectory = value ;
294
296
}
295
297
298
+ // @BasedOnJDKFile("https://github.com/openjdk/jdk21u-dev/blob/jdk-21.0.7-ga/src/java.base/linux/classes/sun/nio/fs/LinuxFileSystem.java#L44-L46")
299
+ // @BasedOnJDKFile("https://github.com/openjdk/jdk21u-dev/blob/jdk-21.0.7-ga/src/java.base/linux/classes/sun/nio/fs/LinuxFileSystemProvider.java#L45-L47")
300
+ // @BasedOnJDKFile("https://github.com/openjdk/jdk21u-dev/blob/jdk-21.0.7-ga/src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java#L77-L79")
301
+ // @BasedOnJDKFile("https://github.com/openjdk/jdk21u-dev/blob/jdk-21.0.7-ga/src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java#L80-L107")
296
302
private static synchronized void reinitialize (Target_sun_nio_fs_UnixFileSystem that ) {
297
303
if (that .needsReinitialization != NeedsReinitializationProvider .STATUS_NEEDS_REINITIALIZATION ) {
298
304
/* Field initialized is volatile, so double-checked locking is OK. */
@@ -309,10 +315,10 @@ private static synchronized void reinitialize(Target_sun_nio_fs_UnixFileSystem t
309
315
* with the same value it is already set to, so this is harmless. All other field writes are
310
316
* redirected to the set-accessors of this class and write the injected fields.
311
317
*
312
- * Note that the `System.getProperty("user.dir" )` value is always used when re-initializing
313
- * a UnixFileSystem, which is not the case with the WindowsFileSystem (JDK-8066709).
318
+ * Note that the `StaticProperty.userDir( )` value is always used when re-initializing a
319
+ * UnixFileSystem, which is not the case with the WindowsFileSystem (JDK-8066709).
314
320
*/
315
- that .originalConstructor (that .provider , System . getProperty ( "user.dir" ));
321
+ that .originalConstructor (that .provider , StaticProperty . userDir ( ));
316
322
317
323
/*
318
324
* Now the object is completely re-initialized and can be used by any thread without
0 commit comments