Skip to content

Commit 7ad8b89

Browse files
committed
[GR-68859] Ignore missing registration errors when querying bundles from JavaUtilResourceBundleAccess
PullRequest: graal/22110
2 parents 8ad5cf7 + 590d5f8 commit 7ad8b89

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/substitutions/Target_java_util_ResourceBundle.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,5 +171,20 @@ private static ResourceBundle getBundleFromModule(Class<?> caller,
171171
private static native ClassLoader getLoader(Module module);
172172

173173
@Alias
174-
private static native ResourceBundle getBundleImpl(Module callerModule, Module module, String baseName, Locale locale, ResourceBundle.Control control);
174+
static native ResourceBundle getBundleImpl(Module callerModule, Module module, String baseName, Locale locale, ResourceBundle.Control control);
175+
176+
@Alias
177+
static native Control getDefaultControl(Module targetModule, String baseName);
178+
}
179+
180+
@TargetClass(className = "java.util.ResourceBundle$1")
181+
final class Target_java_util_ResourceBundle_1 {
182+
@Substitute
183+
@SuppressWarnings("static-method")
184+
public ResourceBundle getBundle(String baseName, Locale locale, Module module) {
185+
// use the given module as the caller to bypass the access check
186+
return MissingRegistrationUtils.runIgnoringMissingRegistrations(() -> Target_java_util_ResourceBundle.getBundleImpl(module, module,
187+
baseName, locale,
188+
Target_java_util_ResourceBundle.getDefaultControl(module, baseName)));
189+
}
175190
}

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/annotation/AnnotationFeature.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@
3838
import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl;
3939
import com.oracle.svm.hosted.reflect.ReflectionDataBuilder;
4040

41+
/**
42+
* For annotations that are materialized at image run time, all necessary methods are registered for
43+
* reflection in {@link ReflectionDataBuilder#registerTypesForAnnotation}. But if an annotation type
44+
* is only used by an annotation that is already in the image heap, then we need to also register
45+
* its methods for reflection. This is done here by registering a callback which notifies us for
46+
* every reachable {@link Annotation} object in the heap and then checking if it is an annotation
47+
* that was materialized by the JDK, i.e., it is a {@link Proxy}.
48+
*/
4149
@AutomaticallyRegisteredFeature
4250
public class AnnotationFeature implements InternalFeature {
4351

@@ -49,14 +57,6 @@ public void duringSetup(DuringSetupAccess a) {
4957
access.registerObjectReachableCallback(Annotation.class, this::registerDeclaredMethods);
5058
}
5159

52-
/**
53-
* For annotations that are materialized at image run time, all necessary methods are registered
54-
* for reflection in {@link ReflectionDataBuilder#registerTypesForAnnotation}. But if an
55-
* annotation type is only used by an annotation that is already in the image heap, then we need
56-
* to also register its methods for reflection. This is done here by registering a callback
57-
* which notifies us for every reachable {@link Annotation} object in the heap and then checking
58-
* if it is an annotation that was materialized by the JDK, i.e., it is a {@link Proxy}.
59-
*/
6060
@SuppressWarnings("unused")
6161
private void registerDeclaredMethods(DuringAnalysisAccess access, Annotation annotation, ObjectScanner.ScanReason reason) {
6262
if (Proxy.isProxyClass(annotation.getClass())) {

0 commit comments

Comments
 (0)