Skip to content

Commit a28a367

Browse files
committed
Only register RuntimeSystemPropertiesSupport.class in ImageSingletons
1 parent 04ee459 commit a28a367

File tree

10 files changed

+31
-37
lines changed

10 files changed

+31
-37
lines changed

substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSystemPropertiesSupport.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import com.oracle.svm.core.feature.InternalFeature;
3939
import com.oracle.svm.core.graal.stackvalue.UnsafeStackValue;
4040
import com.oracle.svm.core.headers.LibC;
41-
import com.oracle.svm.core.jdk.SystemPropertiesSupport;
4241
import com.oracle.svm.core.posix.PosixSystemPropertiesSupport;
4342
import com.oracle.svm.core.posix.headers.Limits;
4443
import com.oracle.svm.core.posix.headers.Stdlib;
@@ -132,7 +131,6 @@ class DarwinSystemPropertiesFeature implements InternalFeature {
132131
@Override
133132
public void duringSetup(DuringSetupAccess access) {
134133
DarwinSystemPropertiesSupport systemPropertiesSupport = new DarwinSystemPropertiesSupport();
135-
ImageSingletons.add(SystemPropertiesSupport.class, systemPropertiesSupport);
136134
ImageSingletons.add(RuntimeSystemPropertiesSupport.class, systemPropertiesSupport);
137135
}
138136
}

substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSystemPropertiesSupport.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
3434
import com.oracle.svm.core.feature.InternalFeature;
3535
import com.oracle.svm.core.graal.stackvalue.UnsafeStackValue;
36-
import com.oracle.svm.core.jdk.SystemPropertiesSupport;
3736
import com.oracle.svm.core.posix.PosixSystemPropertiesSupport;
3837
import com.oracle.svm.core.posix.headers.Stdlib;
3938
import com.oracle.svm.core.posix.headers.Utsname;
@@ -94,7 +93,6 @@ class LinuxSystemPropertiesFeature implements InternalFeature {
9493
@Override
9594
public void duringSetup(DuringSetupAccess access) {
9695
LinuxSystemPropertiesSupport systemPropertiesSupport = new LinuxSystemPropertiesSupport();
97-
ImageSingletons.add(SystemPropertiesSupport.class, systemPropertiesSupport);
9896
ImageSingletons.add(RuntimeSystemPropertiesSupport.class, systemPropertiesSupport);
9997
}
10098
}

substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSystemPropertiesSupport.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,6 @@ class WindowsSystemPropertiesFeature implements InternalFeature {
392392
@Override
393393
public void duringSetup(DuringSetupAccess access) {
394394
WindowsSystemPropertiesSupport systemPropertiesSupport = new WindowsSystemPropertiesSupport();
395-
ImageSingletons.add(SystemPropertiesSupport.class, systemPropertiesSupport);
396395
ImageSingletons.add(RuntimeSystemPropertiesSupport.class, systemPropertiesSupport);
397396
}
398397
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ private static synchronized void reinitialize(Target_sun_nio_fs_WindowsFileSyste
379379
return;
380380
}
381381
that.needsReinitialization = NeedsReinitializationProvider.STATUS_IN_REINITIALIZATION;
382-
that.originalConstructor(that.provider, ImageSingletons.lookup(SystemPropertiesSupport.class).userDir());
382+
that.originalConstructor(that.provider, SystemPropertiesSupport.singleton().userDir());
383383
that.needsReinitialization = NeedsReinitializationProvider.STATUS_REINITIALIZED;
384384
}
385385
}
@@ -433,7 +433,7 @@ static String getUserDir(Target_java_io_FileSystem that) {
433433
*/
434434
return Platform.includedIn(Platform.WINDOWS.class)
435435
? that.normalize(System.getProperty("user.dir"))
436-
: ImageSingletons.lookup(SystemPropertiesSupport.class).userDir();
436+
: SystemPropertiesSupport.singleton().userDir();
437437
}
438438
}
439439

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.Map;
2828
import java.util.function.BooleanSupplier;
2929

30-
import org.graalvm.nativeimage.ImageSingletons;
3130
import org.graalvm.nativeimage.Platform;
3231
import org.graalvm.nativeimage.Platforms;
3332

@@ -54,7 +53,7 @@ public boolean getAsBoolean() {
5453
final class Target_jdk_vm_ci_services_Services {
5554
@Substitute
5655
public static Map<String, String> getSavedProperties() {
57-
return ImageSingletons.lookup(SystemPropertiesSupport.class).getSavedProperties();
56+
return SystemPropertiesSupport.singleton().getSavedProperties();
5857
}
5958
}
6059

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,30 +305,30 @@ private static int identityHashCode(Object obj) {
305305

306306
@Substitute
307307
private static Properties getProperties() {
308-
return ImageSingletons.lookup(SystemPropertiesSupport.class).getProperties();
308+
return SystemPropertiesSupport.singleton().getProperties();
309309
}
310310

311311
@Substitute
312312
private static void setProperties(Properties props) {
313-
ImageSingletons.lookup(SystemPropertiesSupport.class).setProperties(props);
313+
SystemPropertiesSupport.singleton().setProperties(props);
314314
}
315315

316316
@Substitute
317317
public static String setProperty(String key, String value) {
318318
checkKey(key);
319-
return ImageSingletons.lookup(SystemPropertiesSupport.class).setProperty(key, value);
319+
return SystemPropertiesSupport.singleton().setProperty(key, value);
320320
}
321321

322322
@Substitute
323323
private static String getProperty(String key) {
324324
checkKey(key);
325-
return ImageSingletons.lookup(SystemPropertiesSupport.class).getProperty(key);
325+
return SystemPropertiesSupport.singleton().getProperty(key);
326326
}
327327

328328
@Substitute
329329
public static String clearProperty(String key) {
330330
checkKey(key);
331-
return ImageSingletons.lookup(SystemPropertiesSupport.class).clearProperty(key);
331+
return SystemPropertiesSupport.singleton().clearProperty(key);
332332
}
333333

334334
@Substitute

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.Properties;
3131
import java.util.function.Supplier;
3232

33+
import org.graalvm.compiler.api.replacements.Fold;
3334
import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
3435
import org.graalvm.nativeimage.ImageInfo;
3536
import org.graalvm.nativeimage.ImageSingletons;
@@ -89,6 +90,11 @@ public abstract class SystemPropertiesSupport implements RuntimeSystemProperties
8990

9091
private volatile boolean fullyInitialized;
9192

93+
@Fold
94+
public static SystemPropertiesSupport singleton() {
95+
return (SystemPropertiesSupport) ImageSingletons.lookup(RuntimeSystemPropertiesSupport.class);
96+
}
97+
9298
@Platforms(Platform.HOSTED_ONLY.class)
9399
protected SystemPropertiesSupport() {
94100
properties = new Properties();

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,17 @@
2626

2727
import java.util.Map;
2828

29-
import org.graalvm.nativeimage.ImageSingletons;
30-
29+
import com.oracle.svm.core.NeverInline;
3130
import com.oracle.svm.core.SubstrateOptions;
31+
import com.oracle.svm.core.Uninterruptible;
3232
import com.oracle.svm.core.annotate.Alias;
3333
import com.oracle.svm.core.annotate.AnnotateOriginal;
3434
import com.oracle.svm.core.annotate.Delete;
3535
import com.oracle.svm.core.annotate.InjectAccessors;
36-
import com.oracle.svm.core.NeverInline;
3736
import com.oracle.svm.core.annotate.RecomputeFieldValue;
3837
import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind;
3938
import com.oracle.svm.core.annotate.Substitute;
4039
import com.oracle.svm.core.annotate.TargetClass;
41-
import com.oracle.svm.core.Uninterruptible;
4240
import com.oracle.svm.core.snippets.KnownIntrinsics;
4341

4442
import jdk.internal.misc.Unsafe;
@@ -51,7 +49,7 @@ public final class Target_jdk_internal_misc_VM {
5149

5250
@Substitute
5351
public static String getSavedProperty(String name) {
54-
return ImageSingletons.lookup(SystemPropertiesSupport.class).getSavedProperties().get(name);
52+
return SystemPropertiesSupport.singleton().getSavedProperties().get(name);
5553
}
5654

5755
@AnnotateOriginal

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

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
import java.nio.charset.Charset;
2828
import java.util.function.BooleanSupplier;
2929

30-
import org.graalvm.nativeimage.ImageSingletons;
31-
3230
import com.oracle.svm.core.annotate.Substitute;
3331
import com.oracle.svm.core.annotate.TargetClass;
3432
import com.oracle.svm.core.annotate.TargetElement;
@@ -56,47 +54,47 @@ private static String javaHome() {
5654

5755
@Substitute
5856
private static String userHome() {
59-
return ImageSingletons.lookup(SystemPropertiesSupport.class).userHome();
57+
return SystemPropertiesSupport.singleton().userHome();
6058
}
6159

6260
@Substitute
6361
private static String userDir() {
64-
return ImageSingletons.lookup(SystemPropertiesSupport.class).userDir();
62+
return SystemPropertiesSupport.singleton().userDir();
6563
}
6664

6765
@Substitute
6866
private static String userName() {
69-
return ImageSingletons.lookup(SystemPropertiesSupport.class).userName();
67+
return SystemPropertiesSupport.singleton().userName();
7068
}
7169

7270
@Substitute
7371
@TargetElement(onlyWith = JDK17OrLater.class)
7472
private static String javaIoTmpDir() {
75-
return ImageSingletons.lookup(SystemPropertiesSupport.class).javaIoTmpDir();
73+
return SystemPropertiesSupport.singleton().javaIoTmpDir();
7674
}
7775

7876
@Substitute
7977
@TargetElement(onlyWith = JDK17OrLater.class)
8078
private static String javaLibraryPath() {
81-
return ImageSingletons.lookup(SystemPropertiesSupport.class).javaLibraryPath();
79+
return SystemPropertiesSupport.singleton().javaLibraryPath();
8280
}
8381

8482
@Substitute
8583
@TargetElement(onlyWith = JDK17OrLater.class)
8684
private static String sunBootLibraryPath() {
87-
String value = ImageSingletons.lookup(SystemPropertiesSupport.class).savedProperties.get("sun.boot.library.path");
85+
String value = SystemPropertiesSupport.singleton().savedProperties.get("sun.boot.library.path");
8886
return value == null ? "" : value;
8987
}
9088

9189
@Substitute
9290
private static String jdkSerialFilter() {
93-
return ImageSingletons.lookup(SystemPropertiesSupport.class).savedProperties.get("jdk.serialFilter");
91+
return SystemPropertiesSupport.singleton().savedProperties.get("jdk.serialFilter");
9492
}
9593

9694
@Substitute
9795
@TargetElement(onlyWith = StaticPropertyJdkSerialFilterFactoryAvailable.class)
9896
private static String jdkSerialFilterFactory() {
99-
return ImageSingletons.lookup(SystemPropertiesSupport.class).savedProperties.get("jdk.serialFilterFactory");
97+
return SystemPropertiesSupport.singleton().savedProperties.get("jdk.serialFilterFactory");
10098
}
10199

102100
private abstract static class StaticPropertyMethodAvailable implements BooleanSupplier {
@@ -127,31 +125,31 @@ protected StaticPropertyJdkSerialFilterFactoryAvailable() {
127125
@Substitute
128126
@TargetElement(onlyWith = JDK17OrLater.class)
129127
public static String nativeEncoding() {
130-
return ImageSingletons.lookup(SystemPropertiesSupport.class).savedProperties.get("native.encoding");
128+
return SystemPropertiesSupport.singleton().savedProperties.get("native.encoding");
131129
}
132130

133131
@Substitute
134132
@TargetElement(onlyWith = JDK19OrLater.class)
135133
public static String fileEncoding() {
136-
return ImageSingletons.lookup(SystemPropertiesSupport.class).savedProperties.get("file.encoding");
134+
return SystemPropertiesSupport.singleton().savedProperties.get("file.encoding");
137135
}
138136

139137
@Substitute
140138
@TargetElement(onlyWith = JDK19OrLater.class)
141139
public static String javaPropertiesDate() {
142-
return ImageSingletons.lookup(SystemPropertiesSupport.class).savedProperties.getOrDefault("java.properties.date", null);
140+
return SystemPropertiesSupport.singleton().savedProperties.getOrDefault("java.properties.date", null);
143141
}
144142

145143
@Substitute
146144
@TargetElement(onlyWith = JDK19OrLater.class)
147145
public static String jnuEncoding() {
148-
return ImageSingletons.lookup(SystemPropertiesSupport.class).savedProperties.get("sun.jnu.encoding");
146+
return SystemPropertiesSupport.singleton().savedProperties.get("sun.jnu.encoding");
149147
}
150148

151149
@Substitute
152150
@TargetElement(onlyWith = JDK19OrLater.class)
153151
public static Charset jnuCharset() {
154-
String jnuEncoding = ImageSingletons.lookup(SystemPropertiesSupport.class).savedProperties.get("sun.jnu.encoding");
152+
String jnuEncoding = SystemPropertiesSupport.singleton().savedProperties.get("sun.jnu.encoding");
155153
return Target_java_nio_charset_Charset.forName(jnuEncoding, Charset.defaultCharset());
156154
}
157155
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/properties/RuntimePropertyParser.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626

2727
import java.util.Arrays;
2828

29-
import org.graalvm.nativeimage.ImageSingletons;
30-
3129
import com.oracle.svm.core.jdk.SystemPropertiesSupport;
3230

3331
public final class RuntimePropertyParser {
@@ -69,7 +67,7 @@ private static boolean parseProperty(String property) {
6967
String key = property.substring(0, splitIndex);
7068
String value = property.substring(splitIndex + 1);
7169

72-
ImageSingletons.lookup(SystemPropertiesSupport.class).initializeProperty(key, value);
70+
SystemPropertiesSupport.singleton().initializeProperty(key, value);
7371

7472
return true;
7573
}

0 commit comments

Comments
 (0)