diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionDataBuilder.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionDataBuilder.java index 4417d017fe2c..5a4428055e52 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionDataBuilder.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionDataBuilder.java @@ -226,6 +226,21 @@ public void registerAllClassesQuery(ConfigurationCondition condition, Class c }); } + void registerClassMetadata(ConfigurationCondition condition, Class clazz) { + registerAllDeclaredFieldsQuery(condition, true, clazz); + registerAllFieldsQuery(condition, true, clazz); + registerAllDeclaredMethodsQuery(condition, true, clazz); + registerAllMethodsQuery(condition, true, clazz); + registerAllDeclaredConstructorsQuery(condition, true, clazz); + registerAllConstructorsQuery(condition, true, clazz); + registerAllDeclaredClassesQuery(condition, clazz); + registerAllClassesQuery(condition, clazz); + registerAllRecordComponentsQuery(condition, clazz); + registerAllPermittedSubclassesQuery(condition, clazz); + registerAllNestMembersQuery(condition, clazz); + registerAllSignersQuery(condition, clazz); + } + /** * Runtime conditions can only be used with type, so they are not valid here. */ @@ -1161,10 +1176,10 @@ public Map, Set>> getReflectionInnerClasses() { public int getEnabledReflectionQueries(Class clazz) { int enabledQueries = enabledQueriesFlags.getOrDefault(clazz, 0); /* - * Primitives, arrays and object are registered by default since they provide reflective - * access to either no members or only Object methods. + * Primitives and arrays are registered by default since they provide reflective access to + * no members. */ - if (clazz == Object.class || clazz.isPrimitive() || clazz.isArray()) { + if (clazz.isPrimitive() || clazz.isArray()) { enabledQueries |= ALL_DECLARED_CLASSES_FLAG | ALL_CLASSES_FLAG | ALL_DECLARED_CONSTRUCTORS_FLAG | ALL_CONSTRUCTORS_FLAG | ALL_DECLARED_METHODS_FLAG | ALL_METHODS_FLAG | ALL_DECLARED_FIELDS_FLAG | ALL_FIELDS_FLAG; } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionFeature.java index 4fb9c890dda4..b8723068267d 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionFeature.java @@ -295,6 +295,12 @@ public void afterRegistration(AfterRegistrationAccess access) { reflectionData = new ReflectionDataBuilder((SubstrateAnnotationExtractor) ImageSingletons.lookup(AnnotationExtractor.class)); ImageSingletons.add(RuntimeReflectionSupport.class, reflectionData); ImageSingletons.add(ReflectionHostedSupport.class, reflectionData); + + /* + * Querying Object members is allowed to enable these accesses on array classes, since those + * don't define any additional members. + */ + reflectionData.registerClassMetadata(ConfigurationCondition.alwaysTrue(), Object.class); } @Override