|
24 | 24 | */ |
25 | 25 | package com.oracle.svm.core.jdk.xml; |
26 | 26 |
|
27 | | -import java.time.Duration; |
28 | 27 | import java.util.Objects; |
29 | 28 |
|
30 | | -import com.oracle.svm.core.util.VMError; |
31 | 29 | import org.graalvm.nativeimage.hosted.FieldValueTransformer; |
32 | 30 |
|
33 | 31 | import com.oracle.svm.core.annotate.Alias; |
34 | 32 | import com.oracle.svm.core.annotate.RecomputeFieldValue; |
35 | 33 | import com.oracle.svm.core.annotate.Substitute; |
36 | 34 | import com.oracle.svm.core.annotate.TargetClass; |
37 | 35 | import com.oracle.svm.core.jdk.JDKLatest; |
38 | | -import com.oracle.svm.util.ReflectionUtil; |
39 | 36 |
|
40 | 37 | /** |
41 | 38 | * Substitution to initialize {@link #catalog} at build time. |
@@ -78,38 +75,13 @@ final class Target_javax_xml_parsers_SAXParser { |
78 | 75 |
|
79 | 76 | final class JdkCatalogSupplier implements FieldValueTransformer { |
80 | 77 |
|
81 | | - private static Object catalog; |
82 | | - |
83 | | - private static synchronized Object getCatalog() { |
84 | | - // Ensure the field is initialized. |
85 | | - Class<?> xmlSecurityManager = ReflectionUtil.lookupClass(false, "jdk.xml.internal.XMLSecurityManager"); |
86 | | - // The constructor call prepareCatalog which will call JdkCatalog#init. |
87 | | - ReflectionUtil.newInstance(xmlSecurityManager); |
88 | | - |
89 | | - try { |
90 | | - /* |
91 | | - * Workaround for race condition in XMLSecurityManager#prepareCatalog (JDK-8350189). |
92 | | - */ |
93 | | - for (int retryCount = 0; catalog == null && retryCount < 3; retryCount++) { |
94 | | - Class<?> jdkCatalogClass = ReflectionUtil.lookupClass(false, "jdk.xml.internal.JdkCatalog"); |
95 | | - Object res = ReflectionUtil.readStaticField(jdkCatalogClass, "catalog"); |
96 | | - if (res == null) { |
97 | | - Thread.sleep(Duration.ofMillis(100)); |
98 | | - continue; |
99 | | - } |
100 | | - catalog = res; |
101 | | - } |
102 | | - } catch (InterruptedException e) { |
103 | | - /* fall-through to the null check */ |
104 | | - } |
105 | | - if (catalog == null) { |
106 | | - throw VMError.shouldNotReachHere("JdkCatalog initialization failed"); |
107 | | - } |
108 | | - return catalog; |
109 | | - } |
110 | | - |
| 78 | + /** |
| 79 | + * Verifies that {@link Target_jdk_xml_internal_JdkCatalog#catalog} is non-null. The |
| 80 | + * initialization is triggered in |
| 81 | + * {@code com.oracle.svm.hosted.xml.JavaxXmlClassAndResourcesLoaderFeature#initializeJdkCatalog()} |
| 82 | + */ |
111 | 83 | @Override |
112 | 84 | public Object transform(Object receiver, Object originalValue) { |
113 | | - return Objects.requireNonNull(getCatalog()); |
| 85 | + return Objects.requireNonNull(originalValue, "JdkCatalog initialization failed"); |
114 | 86 | } |
115 | 87 | } |
0 commit comments