diff --git a/sdk/src/org.graalvm.nativeimage/snapshot.sigtest b/sdk/src/org.graalvm.nativeimage/snapshot.sigtest index 187f2ad2fd35..ab4d849c3711 100644 --- a/sdk/src/org.graalvm.nativeimage/snapshot.sigtest +++ b/sdk/src/org.graalvm.nativeimage/snapshot.sigtest @@ -1071,6 +1071,10 @@ meth public static void registerLambdaCapturingClass(java.lang.Class) meth public static void registerWithTargetConstructorClass(java.lang.Class,java.lang.Class) supr java.lang.Object +CLSS public final org.graalvm.nativeimage.hosted.RuntimeSystemProperties +meth public static void register(java.lang.String,java.lang.String) +supr java.lang.Object + CLSS public abstract interface org.graalvm.nativeimage.impl.InternalPlatform innr public abstract interface static NATIVE_ONLY innr public abstract interface static PLATFORM_JNI diff --git a/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/hosted/RuntimeSystemProperties.java b/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/hosted/RuntimeSystemProperties.java new file mode 100644 index 000000000000..04857a315e52 --- /dev/null +++ b/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/hosted/RuntimeSystemProperties.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.graalvm.nativeimage.hosted; + +import java.util.Objects; + +import org.graalvm.nativeimage.ImageSingletons; +import org.graalvm.nativeimage.impl.RuntimeSystemPropertiesSupport; + +public final class RuntimeSystemProperties { + + /** + * Define a system property setting for image runtime. This ensures a given key has the given + * value at runtime even if no system property is set via command line of the image execution. + * + * @since 23.0 + */ + public static void register(String key, String value) { + Objects.requireNonNull(key); + Objects.requireNonNull(value); + ImageSingletons.lookup(RuntimeSystemPropertiesSupport.class).initializeProperty(key, value); + } + + private RuntimeSystemProperties() { + } +} diff --git a/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/RuntimeSystemPropertiesSupport.java b/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/RuntimeSystemPropertiesSupport.java new file mode 100644 index 000000000000..79f57cd806bc --- /dev/null +++ b/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/RuntimeSystemPropertiesSupport.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.graalvm.nativeimage.impl; + +public interface RuntimeSystemPropertiesSupport { + void initializeProperty(String key, String value); +} diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSystemPropertiesSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSystemPropertiesSupport.java index c54998031171..bce104e89ba5 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSystemPropertiesSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSystemPropertiesSupport.java @@ -30,6 +30,7 @@ import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.nativeimage.c.type.CTypeConversion.CCharPointerHolder; +import org.graalvm.nativeimage.impl.RuntimeSystemPropertiesSupport; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; @@ -130,6 +131,8 @@ protected String osVersionValue() { class DarwinSystemPropertiesFeature implements InternalFeature { @Override public void duringSetup(DuringSetupAccess access) { - ImageSingletons.add(SystemPropertiesSupport.class, new DarwinSystemPropertiesSupport()); + ImageSingletons.add(RuntimeSystemPropertiesSupport.class, new DarwinSystemPropertiesSupport()); + /* GR-42971 - Remove once SystemPropertiesSupport.class ImageSingletons use is gone. */ + ImageSingletons.add(SystemPropertiesSupport.class, SystemPropertiesSupport.singleton()); } } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSystemPropertiesSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSystemPropertiesSupport.java index 645c4560cee4..0c233219e282 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSystemPropertiesSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSystemPropertiesSupport.java @@ -28,6 +28,7 @@ import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.nativeimage.c.type.CTypeConversion.CCharPointerHolder; +import org.graalvm.nativeimage.impl.RuntimeSystemPropertiesSupport; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; @@ -92,6 +93,8 @@ class LinuxSystemPropertiesFeature implements InternalFeature { @Override public void duringSetup(DuringSetupAccess access) { - ImageSingletons.add(SystemPropertiesSupport.class, new LinuxSystemPropertiesSupport()); + ImageSingletons.add(RuntimeSystemPropertiesSupport.class, new LinuxSystemPropertiesSupport()); + /* GR-42971 - Remove once SystemPropertiesSupport.class ImageSingletons use is gone. */ + ImageSingletons.add(SystemPropertiesSupport.class, SystemPropertiesSupport.singleton()); } } diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSystemPropertiesSupport.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSystemPropertiesSupport.java index 24622e11520a..e0f9fdfaecf7 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSystemPropertiesSupport.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSystemPropertiesSupport.java @@ -37,6 +37,7 @@ import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.nativeimage.c.type.VoidPointer; import org.graalvm.nativeimage.c.type.WordPointer; +import org.graalvm.nativeimage.impl.RuntimeSystemPropertiesSupport; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; @@ -390,6 +391,8 @@ public Pair getOsNameAndVersion() { class WindowsSystemPropertiesFeature implements InternalFeature { @Override public void duringSetup(DuringSetupAccess access) { - ImageSingletons.add(SystemPropertiesSupport.class, new WindowsSystemPropertiesSupport()); + ImageSingletons.add(RuntimeSystemPropertiesSupport.class, new WindowsSystemPropertiesSupport()); + /* GR-42971 - Remove once SystemPropertiesSupport.class ImageSingletons use is gone. */ + ImageSingletons.add(SystemPropertiesSupport.class, SystemPropertiesSupport.singleton()); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/FileSystemProviderSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/FileSystemProviderSupport.java index 2163fc3d2c31..c17f7901f0a6 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/FileSystemProviderSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/FileSystemProviderSupport.java @@ -379,7 +379,7 @@ private static synchronized void reinitialize(Target_sun_nio_fs_WindowsFileSyste return; } that.needsReinitialization = NeedsReinitializationProvider.STATUS_IN_REINITIALIZATION; - that.originalConstructor(that.provider, ImageSingletons.lookup(SystemPropertiesSupport.class).userDir()); + that.originalConstructor(that.provider, SystemPropertiesSupport.singleton().userDir()); that.needsReinitialization = NeedsReinitializationProvider.STATUS_REINITIALIZED; } } @@ -433,7 +433,7 @@ static String getUserDir(Target_java_io_FileSystem that) { */ return Platform.includedIn(Platform.WINDOWS.class) ? that.normalize(System.getProperty("user.dir")) - : ImageSingletons.lookup(SystemPropertiesSupport.class).userDir(); + : SystemPropertiesSupport.singleton().userDir(); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JVMCISubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JVMCISubstitutions.java index 9e0af3e05769..bdd2904b7cc9 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JVMCISubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JVMCISubstitutions.java @@ -27,7 +27,6 @@ import java.util.Map; import java.util.function.BooleanSupplier; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; @@ -54,7 +53,7 @@ public boolean getAsBoolean() { final class Target_jdk_vm_ci_services_Services { @Substitute public static Map getSavedProperties() { - return ImageSingletons.lookup(SystemPropertiesSupport.class).getSavedProperties(); + return SystemPropertiesSupport.singleton().getSavedProperties(); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaLangSubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaLangSubstitutions.java index b2e97720cba2..41cb98d01586 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaLangSubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaLangSubstitutions.java @@ -305,30 +305,30 @@ private static int identityHashCode(Object obj) { @Substitute private static Properties getProperties() { - return ImageSingletons.lookup(SystemPropertiesSupport.class).getProperties(); + return SystemPropertiesSupport.singleton().getProperties(); } @Substitute private static void setProperties(Properties props) { - ImageSingletons.lookup(SystemPropertiesSupport.class).setProperties(props); + SystemPropertiesSupport.singleton().setProperties(props); } @Substitute public static String setProperty(String key, String value) { checkKey(key); - return ImageSingletons.lookup(SystemPropertiesSupport.class).setProperty(key, value); + return SystemPropertiesSupport.singleton().setProperty(key, value); } @Substitute private static String getProperty(String key) { checkKey(key); - return ImageSingletons.lookup(SystemPropertiesSupport.class).getProperty(key); + return SystemPropertiesSupport.singleton().getProperty(key); } @Substitute public static String clearProperty(String key) { checkKey(key); - return ImageSingletons.lookup(SystemPropertiesSupport.class).clearProperty(key); + return SystemPropertiesSupport.singleton().clearProperty(key); } @Substitute diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SystemPropertiesSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SystemPropertiesSupport.java index 6639e21f53bc..79121a4ed4e9 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SystemPropertiesSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SystemPropertiesSupport.java @@ -30,11 +30,13 @@ import java.util.Properties; import java.util.function.Supplier; +import org.graalvm.compiler.api.replacements.Fold; import org.graalvm.compiler.serviceprovider.JavaVersionUtil; import org.graalvm.nativeimage.ImageInfo; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; +import org.graalvm.nativeimage.impl.RuntimeSystemPropertiesSupport; import com.oracle.svm.core.VM; import com.oracle.svm.core.config.ConfigurationValues; @@ -49,7 +51,7 @@ * the current working directory is quite expensive. We initialize such a property either when it is * explicitly accessed, or when all properties are accessed. */ -public abstract class SystemPropertiesSupport { +public abstract class SystemPropertiesSupport implements RuntimeSystemPropertiesSupport { /** System properties that are taken from the VM hosting the image generator. */ private static final String[] HOSTED_PROPERTIES = { @@ -88,6 +90,11 @@ public abstract class SystemPropertiesSupport { private volatile boolean fullyInitialized; + @Fold + public static SystemPropertiesSupport singleton() { + return (SystemPropertiesSupport) ImageSingletons.lookup(RuntimeSystemPropertiesSupport.class); + } + @Platforms(Platform.HOSTED_ONLY.class) protected SystemPropertiesSupport() { properties = new Properties(); @@ -193,8 +200,12 @@ public void setProperties(Properties props) { * Initializes a property at startup from external input (e.g., command line arguments). This * must only be called while the runtime is single threaded. */ + @Override public void initializeProperty(String key, String value) { - savedProperties.put(key, value); + String prevValue = savedProperties.put(key, value); + if (prevValue != null && !prevValue.equals(value)) { + VMError.shouldNotReachHere("System property " + key + " is initialized to " + value + " but was previously initialized to " + prevValue + "."); + } properties.setProperty(key, value); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_misc_VM.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_misc_VM.java index 0b126f8d47d2..f1d6b364ab42 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_misc_VM.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_misc_VM.java @@ -26,19 +26,17 @@ import java.util.Map; -import org.graalvm.nativeimage.ImageSingletons; - +import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.SubstrateOptions; +import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.AnnotateOriginal; import com.oracle.svm.core.annotate.Delete; import com.oracle.svm.core.annotate.InjectAccessors; -import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.snippets.KnownIntrinsics; import jdk.internal.misc.Unsafe; @@ -51,7 +49,7 @@ public final class Target_jdk_internal_misc_VM { @Substitute public static String getSavedProperty(String name) { - return ImageSingletons.lookup(SystemPropertiesSupport.class).getSavedProperties().get(name); + return SystemPropertiesSupport.singleton().getSavedProperties().get(name); } @AnnotateOriginal diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_util_StaticProperty.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_util_StaticProperty.java index a75cb728554b..55d3f14edf79 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_util_StaticProperty.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_jdk_internal_util_StaticProperty.java @@ -27,8 +27,6 @@ import java.nio.charset.Charset; import java.util.function.BooleanSupplier; -import org.graalvm.nativeimage.ImageSingletons; - import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.annotate.TargetElement; @@ -56,47 +54,47 @@ private static String javaHome() { @Substitute private static String userHome() { - return ImageSingletons.lookup(SystemPropertiesSupport.class).userHome(); + return SystemPropertiesSupport.singleton().userHome(); } @Substitute private static String userDir() { - return ImageSingletons.lookup(SystemPropertiesSupport.class).userDir(); + return SystemPropertiesSupport.singleton().userDir(); } @Substitute private static String userName() { - return ImageSingletons.lookup(SystemPropertiesSupport.class).userName(); + return SystemPropertiesSupport.singleton().userName(); } @Substitute @TargetElement(onlyWith = JDK17OrLater.class) private static String javaIoTmpDir() { - return ImageSingletons.lookup(SystemPropertiesSupport.class).javaIoTmpDir(); + return SystemPropertiesSupport.singleton().javaIoTmpDir(); } @Substitute @TargetElement(onlyWith = JDK17OrLater.class) private static String javaLibraryPath() { - return ImageSingletons.lookup(SystemPropertiesSupport.class).javaLibraryPath(); + return SystemPropertiesSupport.singleton().javaLibraryPath(); } @Substitute @TargetElement(onlyWith = JDK17OrLater.class) private static String sunBootLibraryPath() { - String value = ImageSingletons.lookup(SystemPropertiesSupport.class).savedProperties.get("sun.boot.library.path"); + String value = SystemPropertiesSupport.singleton().savedProperties.get("sun.boot.library.path"); return value == null ? "" : value; } @Substitute private static String jdkSerialFilter() { - return ImageSingletons.lookup(SystemPropertiesSupport.class).savedProperties.get("jdk.serialFilter"); + return SystemPropertiesSupport.singleton().savedProperties.get("jdk.serialFilter"); } @Substitute @TargetElement(onlyWith = StaticPropertyJdkSerialFilterFactoryAvailable.class) private static String jdkSerialFilterFactory() { - return ImageSingletons.lookup(SystemPropertiesSupport.class).savedProperties.get("jdk.serialFilterFactory"); + return SystemPropertiesSupport.singleton().savedProperties.get("jdk.serialFilterFactory"); } private abstract static class StaticPropertyMethodAvailable implements BooleanSupplier { @@ -127,31 +125,31 @@ protected StaticPropertyJdkSerialFilterFactoryAvailable() { @Substitute @TargetElement(onlyWith = JDK17OrLater.class) public static String nativeEncoding() { - return ImageSingletons.lookup(SystemPropertiesSupport.class).savedProperties.get("native.encoding"); + return SystemPropertiesSupport.singleton().savedProperties.get("native.encoding"); } @Substitute @TargetElement(onlyWith = JDK19OrLater.class) public static String fileEncoding() { - return ImageSingletons.lookup(SystemPropertiesSupport.class).savedProperties.get("file.encoding"); + return SystemPropertiesSupport.singleton().savedProperties.get("file.encoding"); } @Substitute @TargetElement(onlyWith = JDK19OrLater.class) public static String javaPropertiesDate() { - return ImageSingletons.lookup(SystemPropertiesSupport.class).savedProperties.getOrDefault("java.properties.date", null); + return SystemPropertiesSupport.singleton().savedProperties.getOrDefault("java.properties.date", null); } @Substitute @TargetElement(onlyWith = JDK19OrLater.class) public static String jnuEncoding() { - return ImageSingletons.lookup(SystemPropertiesSupport.class).savedProperties.get("sun.jnu.encoding"); + return SystemPropertiesSupport.singleton().savedProperties.get("sun.jnu.encoding"); } @Substitute @TargetElement(onlyWith = JDK19OrLater.class) public static Charset jnuCharset() { - String jnuEncoding = ImageSingletons.lookup(SystemPropertiesSupport.class).savedProperties.get("sun.jnu.encoding"); + String jnuEncoding = SystemPropertiesSupport.singleton().savedProperties.get("sun.jnu.encoding"); return Target_java_nio_charset_Charset.forName(jnuEncoding, Charset.defaultCharset()); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/properties/RuntimePropertyParser.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/properties/RuntimePropertyParser.java index 88bc67fd9e24..a78bf96ca38d 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/properties/RuntimePropertyParser.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/properties/RuntimePropertyParser.java @@ -26,8 +26,6 @@ import java.util.Arrays; -import org.graalvm.nativeimage.ImageSingletons; - import com.oracle.svm.core.jdk.SystemPropertiesSupport; public final class RuntimePropertyParser { @@ -69,7 +67,7 @@ private static boolean parseProperty(String property) { String key = property.substring(0, splitIndex); String value = property.substring(splitIndex + 1); - ImageSingletons.lookup(SystemPropertiesSupport.class).initializeProperty(key, value); + SystemPropertiesSupport.singleton().initializeProperty(key, value); return true; }