diff --git a/core/builder/src/main/java/io/quarkus/builder/Json.java b/core/builder/src/main/java/io/quarkus/builder/Json.java index d6bc9ab46465b..1973e3a0411c1 100644 --- a/core/builder/src/main/java/io/quarkus/builder/Json.java +++ b/core/builder/src/main/java/io/quarkus/builder/Json.java @@ -187,7 +187,7 @@ void addInternal(Object value) { } } - boolean isEmpty() { + public boolean isEmpty() { return isValuesEmpty(values); } diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageJNIConfigStep.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageJNIConfigStep.java index b6381bc9b5a5d..70e744f9b3ec7 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageJNIConfigStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageJNIConfigStep.java @@ -40,10 +40,10 @@ void generateJniConfig(BuildProducer jniConfig, json.put("name", entry.getKey()); JniInfo info = entry.getValue(); + JsonArrayBuilder methodsArray = Json.array(); if (info.constructors) { json.put("allDeclaredConstructors", true); } else if (!info.ctorSet.isEmpty()) { - JsonArrayBuilder methodsArray = Json.array(); for (JniRuntimeAccessMethodBuildItem ctor : info.ctorSet) { JsonObjectBuilder methodObject = Json.object(); methodObject.put("name", ctor.getName()); @@ -54,12 +54,10 @@ void generateJniConfig(BuildProducer jniConfig, methodObject.put("parameterTypes", paramsArray); methodsArray.add(methodObject); } - json.put("methods", methodsArray); } if (info.methods) { json.put("allDeclaredMethods", true); } else if (!info.methodSet.isEmpty()) { - JsonArrayBuilder methodsArray = Json.array(); for (JniRuntimeAccessMethodBuildItem method : info.methodSet) { JsonObjectBuilder methodObject = Json.object(); methodObject.put("name", method.getName()); @@ -70,8 +68,11 @@ void generateJniConfig(BuildProducer jniConfig, methodObject.put("parameterTypes", paramsArray); methodsArray.add(methodObject); } + } + if (!methodsArray.isEmpty()) { json.put("methods", methodsArray); } + if (info.fields) { json.put("allDeclaredFields", true); } else if (!info.fieldSet.isEmpty()) { diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageReflectConfigStep.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageReflectConfigStep.java index 69476a4af5fb2..cd04106f20330 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageReflectConfigStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageReflectConfigStep.java @@ -70,13 +70,13 @@ void generateReflectConfig(BuildProducer reflectConf json.put("name", entry.getKey()); ReflectionInfo info = entry.getValue(); + JsonArrayBuilder methodsArray = Json.array(); if (info.typeReachable != null) { json.put("condition", Json.object().put("typeReachable", info.typeReachable)); } if (info.constructors) { json.put("allDeclaredConstructors", true); } else if (!info.ctorSet.isEmpty()) { - JsonArrayBuilder methodsArray = Json.array(); for (ReflectiveMethodBuildItem ctor : info.ctorSet) { JsonObjectBuilder methodObject = Json.object(); methodObject.put("name", ctor.getName()); @@ -87,12 +87,10 @@ void generateReflectConfig(BuildProducer reflectConf methodObject.put("parameterTypes", paramsArray); methodsArray.add(methodObject); } - json.put("methods", methodsArray); } if (info.methods) { json.put("allDeclaredMethods", true); } else if (!info.methodSet.isEmpty()) { - JsonArrayBuilder methodsArray = Json.array(); for (ReflectiveMethodBuildItem method : info.methodSet) { JsonObjectBuilder methodObject = Json.object(); methodObject.put("name", method.getName()); @@ -103,8 +101,11 @@ void generateReflectConfig(BuildProducer reflectConf methodObject.put("parameterTypes", paramsArray); methodsArray.add(methodObject); } + } + if (!methodsArray.isEmpty()) { json.put("methods", methodsArray); } + if (info.fields) { json.put("allDeclaredFields", true); } else if (!info.fieldSet.isEmpty()) {