|
24 | 24 | */
|
25 | 25 | package com.oracle.svm.core.jdk;
|
26 | 26 |
|
| 27 | +import java.util.Objects; |
| 28 | + |
27 | 29 | import com.oracle.svm.core.SubstrateUtil;
|
28 | 30 | import com.oracle.svm.core.annotate.Alias;
|
29 | 31 | import com.oracle.svm.core.annotate.Delete;
|
30 |
| -import com.oracle.svm.core.annotate.KeepOriginal; |
31 | 32 | import com.oracle.svm.core.annotate.RecomputeFieldValue;
|
32 | 33 | import com.oracle.svm.core.annotate.Substitute;
|
33 | 34 | import com.oracle.svm.core.annotate.TargetClass;
|
|
42 | 43 | * corresponding system properties.
|
43 | 44 | * <p>
|
44 | 45 | * We {@link Substitute substitute} the whole class so that it is possible to use a custom static
|
45 |
| - * constructor at run-time. |
| 46 | + * constructor at run-time. If this class is used before the system properties are fully parsed and |
| 47 | + * initialized, it can happen that we return or cache invalid values (see GR-64572). |
46 | 48 | * <p>
|
47 | 49 | * Note for updating: use {@link Delete} for static fields that should be unreachable (e.g, because
|
48 | 50 | * we substituted an accessor and the field is therefore unused). Use {@link Alias} for static
|
49 | 51 | * fields that can be initialized in our custom static constructor. Use {@link Substitute} for
|
50 | 52 | * methods that access expensive lazily initialized system properties (see
|
51 |
| - * {@link SystemPropertiesSupport} for a list of all lazily initialized properties). Use |
52 |
| - * {@link KeepOriginal} for methods that we don't want to substitute. |
| 53 | + * {@link SystemPropertiesSupport} for a list of all lazily initialized properties). |
53 | 54 | */
|
54 | 55 | @Substitute
|
55 | 56 | @TargetClass(jdk.internal.util.StaticProperty.class)
|
@@ -284,39 +285,66 @@ private static String javaIoTmpDir() {
|
284 | 285 | return SystemPropertiesSupport.singleton().getInitialProperty("java.io.tmpdir");
|
285 | 286 | }
|
286 | 287 |
|
287 |
| - @KeepOriginal |
288 |
| - public static native String sunBootLibraryPath(); |
| 288 | + @Substitute |
| 289 | + public static String sunBootLibraryPath() { |
| 290 | + assert Objects.equals(SUN_BOOT_LIBRARY_PATH, SystemPropertiesSupport.singleton().getInitialProperty("sun.boot.library.path", "")); |
| 291 | + return SUN_BOOT_LIBRARY_PATH; |
| 292 | + } |
289 | 293 |
|
290 |
| - @KeepOriginal |
291 |
| - public static native String jdkSerialFilter(); |
| 294 | + @Substitute |
| 295 | + public static String jdkSerialFilter() { |
| 296 | + assert Objects.equals(JDK_SERIAL_FILTER, SystemPropertiesSupport.singleton().getInitialProperty("jdk.serialFilter")); |
| 297 | + return JDK_SERIAL_FILTER; |
| 298 | + } |
292 | 299 |
|
293 |
| - @KeepOriginal |
294 |
| - public static native String jdkSerialFilterFactory(); |
| 300 | + @Substitute |
| 301 | + public static String jdkSerialFilterFactory() { |
| 302 | + assert Objects.equals(JDK_SERIAL_FILTER_FACTORY, SystemPropertiesSupport.singleton().getInitialProperty("jdk.serialFilterFactory")); |
| 303 | + return JDK_SERIAL_FILTER_FACTORY; |
| 304 | + } |
295 | 305 |
|
296 |
| - @KeepOriginal |
297 |
| - public static native String nativeEncoding(); |
| 306 | + @Substitute |
| 307 | + public static String nativeEncoding() { |
| 308 | + assert Objects.equals(NATIVE_ENCODING, SystemPropertiesSupport.singleton().getInitialProperty("native.encoding")); |
| 309 | + return NATIVE_ENCODING; |
| 310 | + } |
298 | 311 |
|
299 |
| - @KeepOriginal |
300 |
| - public static native String fileEncoding(); |
| 312 | + @Substitute |
| 313 | + public static String fileEncoding() { |
| 314 | + assert Objects.equals(FILE_ENCODING, SystemPropertiesSupport.singleton().getInitialProperty("file.encoding")); |
| 315 | + return FILE_ENCODING; |
| 316 | + } |
301 | 317 |
|
302 |
| - @KeepOriginal |
303 |
| - public static native String javaPropertiesDate(); |
| 318 | + @Substitute |
| 319 | + public static String javaPropertiesDate() { |
| 320 | + assert Objects.equals(JAVA_PROPERTIES_DATE, SystemPropertiesSupport.singleton().getInitialProperty("java.properties.date")); |
| 321 | + return JAVA_PROPERTIES_DATE; |
| 322 | + } |
304 | 323 |
|
305 |
| - @KeepOriginal |
306 |
| - public static native String jnuEncoding(); |
| 324 | + @Substitute |
| 325 | + public static String jnuEncoding() { |
| 326 | + assert Objects.equals(SUN_JNU_ENCODING, SystemPropertiesSupport.singleton().getInitialProperty("sun.jnu.encoding")); |
| 327 | + return SUN_JNU_ENCODING; |
| 328 | + } |
307 | 329 |
|
308 |
| - @KeepOriginal |
309 |
| - public static native String javaLocaleUseOldISOCodes(); |
| 330 | + @Substitute |
| 331 | + public static String javaLocaleUseOldISOCodes() { |
| 332 | + assert Objects.equals(JAVA_LOCALE_USE_OLD_ISO_CODES, SystemPropertiesSupport.singleton().getInitialProperty("java.locale.useOldISOCodes", "")); |
| 333 | + return JAVA_LOCALE_USE_OLD_ISO_CODES; |
| 334 | + } |
310 | 335 |
|
311 | 336 | @Substitute
|
312 | 337 | @TargetElement(onlyWith = JDKLatest.class)//
|
313 | 338 | public static String osName() {
|
314 | 339 | return SystemPropertiesSupport.singleton().getInitialProperty("os.name");
|
315 | 340 | }
|
316 | 341 |
|
317 |
| - @KeepOriginal |
| 342 | + @Substitute |
318 | 343 | @TargetElement(onlyWith = JDKLatest.class)//
|
319 |
| - public static native String osArch(); |
| 344 | + public static String osArch() { |
| 345 | + assert Objects.equals(OS_ARCH, SystemPropertiesSupport.singleton().getInitialProperty("os.arch")); |
| 346 | + return OS_ARCH; |
| 347 | + } |
320 | 348 |
|
321 | 349 | @Substitute
|
322 | 350 | @TargetElement(onlyWith = JDKLatest.class)//
|
|
0 commit comments