From 44b8c151fbaf0214ef6e42a369609c96471fe92f Mon Sep 17 00:00:00 2001 From: Loic Ottet Date: Tue, 1 Oct 2024 00:41:25 +0200 Subject: [PATCH] Register all methods if one is present --- .github/workflows/reachability-metadata.yml | 2 +- .../svm/core/configure/ReflectionConfigurationParser.java | 6 +++--- .../oracle/svm/core/configure/ReflectionMetadataParser.java | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/reachability-metadata.yml b/.github/workflows/reachability-metadata.yml index 8d9cd0ab2285b..ac4044aecd72e 100644 --- a/.github/workflows/reachability-metadata.yml +++ b/.github/workflows/reachability-metadata.yml @@ -71,7 +71,7 @@ jobs: - name: Build GraalVM JDK uses: ./.github/actions/build-graalvm with: - native-images: 'native-image,native-image-configure,lib:native-image-agent' + native-images: 'native-image,native-image-configure' components: 'Native Image,Native Image Configure Tool' java-version: ${{ env.MINIMUM_METADATA_JAVA_VERSION }} - name: Tar GraalVM JDK diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ReflectionConfigurationParser.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ReflectionConfigurationParser.java index b4d9700814404..f9338825dbff3 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ReflectionConfigurationParser.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ReflectionConfigurationParser.java @@ -111,13 +111,13 @@ private void parseField(C condition, EconomicMap data, T clazz) protected void parseMethods(C condition, boolean queriedOnly, List methods, T clazz) { for (Object method : methods) { - parseMethod(condition, queriedOnly, asMap(method, "Elements of 'methods' array must be method descriptor objects"), clazz); + parseMethod(condition, queriedOnly, asMap(method, "Elements of 'methods' array must be method descriptor objects"), clazz, method == methods.getFirst()); } } - private void parseMethod(C condition, boolean queriedOnly, EconomicMap data, T clazz) { + private void parseMethod(C condition, boolean queriedOnly, EconomicMap data, T clazz, boolean first) { checkAttributes(data, "reflection method descriptor object", Collections.singleton("name"), Collections.singleton("parameterTypes")); - RuntimeReflectionSupport.increaseCount(false); + RuntimeReflectionSupport.increaseCount(!first); String methodName = asString(data.get("name"), "name"); List methodParameterTypes = null; Object parameterTypes = data.get("parameterTypes"); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ReflectionMetadataParser.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ReflectionMetadataParser.java index 982588099e973..f43ad2161bf03 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ReflectionMetadataParser.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ReflectionMetadataParser.java @@ -103,8 +103,9 @@ protected void parseClass(EconomicMap data) { registerIfNotDefault(data, false, clazz, "allDeclaredConstructors", () -> delegate.registerDeclaredConstructors(condition, false, clazz)); registerIfNotDefault(data, false, clazz, "allPublicConstructors", () -> delegate.registerPublicConstructors(condition, false, clazz)); - registerIfNotDefault(data, false, clazz, "allDeclaredMethods", () -> delegate.registerDeclaredMethods(condition, false, clazz)); - registerIfNotDefault(data, false, clazz, "allPublicMethods", () -> delegate.registerPublicMethods(condition, false, clazz)); + registerIfNotDefault(data, data.containsKey("methods") && !asList(data.get("methods"), "").isEmpty(), clazz, "allDeclaredMethods", + () -> delegate.registerDeclaredMethods(condition, false, clazz)); + registerIfNotDefault(data, data.containsKey("methods") && !asList(data.get("methods"), "").isEmpty(), clazz, "allPublicMethods", () -> delegate.registerPublicMethods(condition, false, clazz)); registerIfNotDefault(data, false, clazz, "allDeclaredFields", () -> delegate.registerDeclaredFields(condition, false, clazz)); registerIfNotDefault(data, false, clazz, "allPublicFields", () -> delegate.registerPublicFields(condition, false, clazz)); registerIfNotDefault(data, false, clazz, "unsafeAllocated", () -> delegate.registerUnsafeAllocated(condition, clazz));