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 d5e0059bf32b3..33e61b28bb40f 100644 --- a/core/builder/src/main/java/io/quarkus/builder/Json.java +++ b/core/builder/src/main/java/io/quarkus/builder/Json.java @@ -14,7 +14,7 @@ /** * A simple JSON string generator. */ -final class Json { +public final class Json { private static final String OBJECT_START = "{"; private static final String OBJECT_END = "}"; @@ -47,7 +47,7 @@ private Json() { /** * @return the new JSON array builder, empty builders are not ignored */ - static JsonArrayBuilder array() { + public static JsonArrayBuilder array() { return new JsonArrayBuilder(false); } @@ -65,7 +65,7 @@ static JsonArrayBuilder array(boolean ignoreEmptyBuilders) { * * @return the new JSON object builder, empty builders are not ignored */ - static JsonObjectBuilder object() { + public static JsonObjectBuilder object() { return new JsonObjectBuilder(false); } @@ -142,7 +142,7 @@ protected boolean isValuesEmpty(Collection values) { /** * JSON array builder. */ - static class JsonArrayBuilder extends JsonBuilder { + public static class JsonArrayBuilder extends JsonBuilder { private final List values; @@ -156,12 +156,12 @@ JsonArrayBuilder add(JsonArrayBuilder value) { return this; } - JsonArrayBuilder add(JsonObjectBuilder value) { + public JsonArrayBuilder add(JsonObjectBuilder value) { addInternal(value); return this; } - JsonArrayBuilder add(String value) { + public JsonArrayBuilder add(String value) { addInternal(value); return this; } @@ -205,7 +205,7 @@ String build() throws IOException { } @Override - void appendTo(Appendable appendable) throws IOException { + public void appendTo(Appendable appendable) throws IOException { appendable.append(ARRAY_START); int idx = 0; for (ListIterator iterator = values.listIterator(); iterator.hasNext();) { @@ -231,7 +231,7 @@ protected JsonArrayBuilder self() { /** * JSON object builder. */ - static class JsonObjectBuilder extends JsonBuilder { + public static class JsonObjectBuilder extends JsonBuilder { private final Map properties; @@ -240,22 +240,22 @@ private JsonObjectBuilder(boolean ignoreEmptyBuilders) { this.properties = new HashMap(); } - JsonObjectBuilder put(String name, String value) { + public JsonObjectBuilder put(String name, String value) { putInternal(name, value); return this; } - JsonObjectBuilder put(String name, JsonObjectBuilder value) { + public JsonObjectBuilder put(String name, JsonObjectBuilder value) { putInternal(name, value); return this; } - JsonObjectBuilder put(String name, JsonArrayBuilder value) { + public JsonObjectBuilder put(String name, JsonArrayBuilder value) { putInternal(name, value); return this; } - JsonObjectBuilder put(String name, boolean value) { + public JsonObjectBuilder put(String name, boolean value) { putInternal(name, value); return this; } @@ -295,7 +295,7 @@ String build() throws IOException { } @Override - void appendTo(Appendable appendable) throws IOException { + public void appendTo(Appendable appendable) throws IOException { appendable.append(OBJECT_START); int idx = 0; for (Iterator> iterator = properties.entrySet().iterator(); iterator.hasNext();) { diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/ReflectiveClassBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/ReflectiveClassBuildItem.java index c2b771af2141a..a1a3725c781ee 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/ReflectiveClassBuildItem.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/ReflectiveClassBuildItem.java @@ -17,7 +17,6 @@ public final class ReflectiveClassBuildItem extends MultiBuildItem { private final boolean methods; private final boolean fields; private final boolean constructors; - private final boolean finalFieldsWritable; private final boolean weak; private final boolean serialization; @@ -29,13 +28,8 @@ public ReflectiveClassBuildItem(boolean constructors, boolean methods, boolean f this(constructors, methods, fields, false, false, className); } - private ReflectiveClassBuildItem(boolean constructors, boolean methods, boolean fields, boolean finalFieldsWritable, - boolean weak, Class... className) { - this(constructors, methods, fields, finalFieldsWritable, weak, false, className); - } - - private ReflectiveClassBuildItem(boolean constructors, boolean methods, boolean fields, boolean finalFieldsWritable, - boolean weak, boolean serialization, Class... className) { + private ReflectiveClassBuildItem(boolean constructors, boolean methods, boolean fields, boolean weak, boolean serialization, + Class... className) { List names = new ArrayList<>(); for (Class i : className) { if (i == null) { @@ -47,16 +41,10 @@ private ReflectiveClassBuildItem(boolean constructors, boolean methods, boolean this.methods = methods; this.fields = fields; this.constructors = constructors; - this.finalFieldsWritable = finalFieldsWritable; this.weak = weak; this.serialization = serialization; - if (weak) { - if (serialization) { - throw new RuntimeException("Weak reflection not supported with serialization"); - } - if (finalFieldsWritable) { - throw new RuntimeException("Weak reflection not supported with finalFieldsWritable"); - } + if (weak && serialization) { + throw new RuntimeException("Weak reflection not supported with serialization"); } } @@ -70,7 +58,7 @@ public ReflectiveClassBuildItem(boolean constructors, boolean methods, boolean f public ReflectiveClassBuildItem(boolean constructors, boolean methods, boolean fields, boolean serialization, String... className) { - this(constructors, methods, fields, false, false, serialization, className); + this(constructors, methods, fields, false, serialization, className); } public static ReflectiveClassBuildItem weakClass(String... className) { @@ -79,20 +67,15 @@ public static ReflectiveClassBuildItem weakClass(String... className) { public static ReflectiveClassBuildItem weakClass(boolean constructors, boolean methods, boolean fields, String... className) { - return new ReflectiveClassBuildItem(constructors, methods, fields, false, true, className); + return new ReflectiveClassBuildItem(constructors, methods, fields, true, false, className); } public static ReflectiveClassBuildItem serializationClass(String... className) { - return new ReflectiveClassBuildItem(false, false, false, false, false, true, className); + return new ReflectiveClassBuildItem(false, false, false, false, true, className); } - private ReflectiveClassBuildItem(boolean constructors, boolean methods, boolean fields, boolean finalFieldsWritable, - boolean weak, String... className) { - this(constructors, methods, fields, finalFieldsWritable, weak, false, className); - } - - private ReflectiveClassBuildItem(boolean constructors, boolean methods, boolean fields, boolean finalFieldsWritable, - boolean weak, boolean serialization, String... className) { + private ReflectiveClassBuildItem(boolean constructors, boolean methods, boolean fields, boolean weak, boolean serialization, + String... className) { for (String i : className) { if (i == null) { throw new NullPointerException(); @@ -102,7 +85,6 @@ private ReflectiveClassBuildItem(boolean constructors, boolean methods, boolean this.methods = methods; this.fields = fields; this.constructors = constructors; - this.finalFieldsWritable = finalFieldsWritable; this.weak = weak; this.serialization = serialization; } @@ -123,8 +105,13 @@ public boolean isConstructors() { return constructors; } + /** + * @deprecated As of GraalVM 21.2 finalFieldsWritable is no longer needed when registering fields for reflection. This will + * be removed in a future verion of Quarkus. + */ + @Deprecated public boolean areFinalFieldsWritable() { - return finalFieldsWritable; + return false; } public boolean isWeak() { @@ -159,7 +146,6 @@ public static class Builder { private boolean constructors = true; private boolean methods; private boolean fields; - private boolean finalFieldsWritable; private boolean weak; private boolean serialization; @@ -186,8 +172,12 @@ public Builder fields(boolean fields) { return this; } + /** + * @deprecated As of GraalVM 21.2 finalFieldsWritable is no longer needed when registering fields for reflection. This + * will be removed in a future verion of Quarkus. + */ + @Deprecated public Builder finalFieldsWritable(boolean finalFieldsWritable) { - this.finalFieldsWritable = finalFieldsWritable; return this; } @@ -202,8 +192,7 @@ public Builder serialization(boolean serialize) { } public ReflectiveClassBuildItem build() { - return new ReflectiveClassBuildItem(constructors, methods, fields, finalFieldsWritable, weak, serialization, - className); + return new ReflectiveClassBuildItem(constructors, methods, fields, weak, serialization, className); } } } diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/ReflectiveClassConditionBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/ReflectiveClassConditionBuildItem.java new file mode 100644 index 0000000000000..f9a84929ee471 --- /dev/null +++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/nativeimage/ReflectiveClassConditionBuildItem.java @@ -0,0 +1,29 @@ +package io.quarkus.deployment.builditem.nativeimage; + +import io.quarkus.builder.item.MultiBuildItem; + +/** + * Used to define a condition to register a class for reflection in native mode only when a specific type is reachable + */ +public final class ReflectiveClassConditionBuildItem extends MultiBuildItem { + + private final String className; + private final String typeReachable; + + public ReflectiveClassConditionBuildItem(Class className, String typeReachable) { + this(className.getName(), typeReachable); + } + + public ReflectiveClassConditionBuildItem(String className, String typeReachable) { + this.className = className; + this.typeReachable = typeReachable; + } + + public String getClassName() { + return className; + } + + public String getTypeReachable() { + return typeReachable; + } +} diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java index 3e4e24105d90c..63d0a21cc3c57 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java @@ -8,33 +8,23 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.nio.charset.StandardCharsets; -import java.util.HashSet; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; -import java.util.Set; import org.graalvm.home.Version; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.hosted.RuntimeClassInitialization; -import org.graalvm.nativeimage.hosted.RuntimeReflection; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.builditem.GeneratedNativeImageClassBuildItem; import io.quarkus.deployment.builditem.GeneratedResourceBuildItem; -import io.quarkus.deployment.builditem.nativeimage.ForceNonWeakReflectiveClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.JPMSExportBuildItem; import io.quarkus.deployment.builditem.nativeimage.JniRuntimeAccessBuildItem; -import io.quarkus.deployment.builditem.nativeimage.LambdaCapturingTypeBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBundleBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageResourcePatternsBuildItem; -import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; -import io.quarkus.deployment.builditem.nativeimage.ReflectiveFieldBuildItem; -import io.quarkus.deployment.builditem.nativeimage.ReflectiveMethodBuildItem; import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedPackageBuildItem; import io.quarkus.deployment.builditem.nativeimage.RuntimeReinitializedClassBuildItem; @@ -54,7 +44,6 @@ import io.quarkus.runtime.NativeImageFeatureUtils; import io.quarkus.runtime.ResourceHelper; import io.quarkus.runtime.graal.ResourcesFeature; -import io.quarkus.runtime.graal.WeakReflection; public class NativeImageFeatureStep { @@ -80,12 +69,6 @@ public class NativeImageFeatureStep { CONFIGURATION_CONDITION, "alwaysTrue", CONFIGURATION_CONDITION); - private static final MethodDescriptor REGISTER_LAMBDA_CAPTURING_CLASS = ofMethod( - "org.graalvm.nativeimage.impl.RuntimeSerializationSupport", - "registerLambdaCapturingClass", void.class, - CONFIGURATION_CONDITION, - String.class); - private static final MethodDescriptor LOOKUP_METHOD = ofMethod( NativeImageFeatureUtils.class, "lookupMethod", Method.class, Class.class, String.class, Class[].class); @@ -95,18 +78,12 @@ public class NativeImageFeatureStep { "findModule", Module.class, String.class); private static final MethodDescriptor INVOKE = ofMethod( Method.class, "invoke", Object.class, Object.class, Object[].class); - static final String RUNTIME_REFLECTION = RuntimeReflection.class.getName(); static final String LEGACY_JNI_RUNTIME_ACCESS = "com.oracle.svm.core.jni.JNIRuntimeAccess"; static final String JNI_RUNTIME_ACCESS = "org.graalvm.nativeimage.hosted.RuntimeJNIAccess"; static final String BEFORE_ANALYSIS_ACCESS = Feature.BeforeAnalysisAccess.class.getName(); - static final String DURING_SETUP_ACCESS = Feature.DuringSetupAccess.class.getName(); static final String DYNAMIC_PROXY_REGISTRY = "com.oracle.svm.core.jdk.proxy.DynamicProxyRegistry"; static final String LOCALIZATION_FEATURE = "com.oracle.svm.core.jdk.localization.LocalizationFeature"; static final String RUNTIME_RESOURCE_SUPPORT = "org.graalvm.nativeimage.impl.RuntimeResourceSupport"; - public static final MethodDescriptor WEAK_REFLECTION_REGISTRATION = MethodDescriptor.ofMethod(WeakReflection.class, - "register", void.class, Feature.BeforeAnalysisAccess.class, Class.class, boolean.class, boolean.class, - boolean.class); - public static final String RUNTIME_SERIALIZATION = "org.graalvm.nativeimage.hosted.RuntimeSerialization"; @BuildStep GeneratedResourceBuildItem generateNativeResourcesList(List resources, @@ -127,9 +104,7 @@ GeneratedResourceBuildItem generateNativeResourcesList(List features, - List jniRuntimeAccessibleClasses, - List lambdaCapturingTypeBuildItems, - List resourcePatterns) { + List jniRuntimeAccessibleClasses) { // required in order to access org.graalvm.nativeimage.impl.RuntimeSerializationSupport and org.graalvm.nativeimage.impl.ConfigurationCondition features.produce(new JPMSExportBuildItem("org.graalvm.sdk", "org.graalvm.nativeimage.impl")); // required in order to access com.oracle.svm.core.jni.JNIRuntimeAccess in GraalVM 22.2.x @@ -148,14 +123,9 @@ void generateFeature(BuildProducer nativeIma List proxies, List resourcePatterns, List resourceBundles, - List reflectiveMethods, - List reflectiveFields, - List reflectiveClassBuildItems, - List nonWeakReflectiveClassBuildItems, List serviceProviderBuildItems, List unsafeAccessedFields, - List jniRuntimeAccessibleClasses, - List lambdaCapturingTypeBuildItems) { + List jniRuntimeAccessibleClasses) { ClassCreator file = new ClassCreator(new ClassOutput() { @Override public void write(String s, byte[] bytes) { @@ -168,50 +138,6 @@ public void write(String s, byte[] bytes) { MethodCreator getDescription = file.getMethodCreator("getDescription", String.class); getDescription.returnValue(getDescription.load("Auto-generated class by Quarkus from the existing extensions")); - MethodCreator duringSetup = file.getMethodCreator("duringSetup", "V", DURING_SETUP_ACCESS); - // Register Lambda Capturing Types - if (!lambdaCapturingTypeBuildItems.isEmpty()) { - - BranchResult graalVm22_3Test = duringSetup - .ifGreaterEqualZero(duringSetup.invokeVirtualMethod(VERSION_COMPARE_TO, - duringSetup.invokeStaticMethod(VERSION_CURRENT), - duringSetup.marshalAsArray(int.class, duringSetup.load(22), duringSetup.load(3)))); - /* GraalVM >= 22.3 */ - try (BytecodeCreator greaterThan22_2 = graalVm22_3Test.trueBranch()) { - MethodDescriptor registerLambdaCapturingClass = ofMethod(RUNTIME_SERIALIZATION, "registerLambdaCapturingClass", - void.class, Class.class); - for (LambdaCapturingTypeBuildItem i : lambdaCapturingTypeBuildItems) { - TryBlock tryBlock = greaterThan22_2.tryBlock(); - - tryBlock.invokeStaticMethod(registerLambdaCapturingClass, - tryBlock.loadClassFromTCCL(i.getClassName())); - - CatchBlockCreator catchBlock = tryBlock.addCatch(Throwable.class); - catchBlock.invokeVirtualMethod(ofMethod(Throwable.class, "printStackTrace", void.class), - catchBlock.getCaughtException()); - } - } - /* GraalVM < 22.3 */ - try (BytecodeCreator smallerThan22_3 = graalVm22_3Test.falseBranch()) { - ResultHandle runtimeSerializationSupportSingleton = smallerThan22_3.invokeStaticMethod(IMAGE_SINGLETONS_LOOKUP, - smallerThan22_3.loadClassFromTCCL("org.graalvm.nativeimage.impl.RuntimeSerializationSupport")); - ResultHandle configAlwaysTrue = smallerThan22_3.invokeStaticMethod(CONFIGURATION_ALWAYS_TRUE); - - for (LambdaCapturingTypeBuildItem i : lambdaCapturingTypeBuildItems) { - TryBlock tryBlock = smallerThan22_3.tryBlock(); - - tryBlock.invokeInterfaceMethod(REGISTER_LAMBDA_CAPTURING_CLASS, runtimeSerializationSupportSingleton, - configAlwaysTrue, - tryBlock.load(i.getClassName())); - - CatchBlockCreator catchBlock = tryBlock.addCatch(Throwable.class); - catchBlock.invokeVirtualMethod(ofMethod(Throwable.class, "printStackTrace", void.class), - catchBlock.getCaughtException()); - } - } - } - duringSetup.returnValue(null); - MethodCreator beforeAn = file.getMethodCreator("beforeAnalysis", "V", BEFORE_ANALYSIS_ACCESS); TryBlock overallCatch = beforeAn.tryBlock(); @@ -513,137 +439,6 @@ public void write(String s, byte[] bytes) { } int count = 0; - final Map reflectiveClasses = new LinkedHashMap<>(); - final Set forcedNonWeakClasses = new HashSet<>(); - for (ForceNonWeakReflectiveClassBuildItem nonWeakReflectiveClassBuildItem : nonWeakReflectiveClassBuildItems) { - forcedNonWeakClasses.add(nonWeakReflectiveClassBuildItem.getClassName()); - } - for (ReflectiveClassBuildItem i : reflectiveClassBuildItems) { - addReflectiveClass(reflectiveClasses, forcedNonWeakClasses, i.isConstructors(), i.isMethods(), i.isFields(), - i.areFinalFieldsWritable(), - i.isWeak(), - i.isSerialization(), - i.getClassNames().toArray(new String[0])); - } - for (ReflectiveFieldBuildItem i : reflectiveFields) { - addReflectiveField(reflectiveClasses, i); - } - for (ReflectiveMethodBuildItem i : reflectiveMethods) { - addReflectiveMethod(reflectiveClasses, i); - } - - for (ServiceProviderBuildItem i : serviceProviderBuildItems) { - addReflectiveClass(reflectiveClasses, forcedNonWeakClasses, true, false, false, false, false, false, - i.providers().toArray(new String[] {})); - } - - MethodDescriptor registerSerializationMethod = null; - - MethodCreator registerForReflection = file - .getMethodCreator("registerForReflection", void.class, Feature.BeforeAnalysisAccess.class) - .setModifiers(Modifier.PRIVATE | Modifier.STATIC); - - for (Map.Entry entry : reflectiveClasses.entrySet()) { - MethodCreator mv = file.getMethodCreator("registerClass" + count++, void.class, Feature.BeforeAnalysisAccess.class); - mv.setModifiers(Modifier.PRIVATE | Modifier.STATIC); - registerForReflection.invokeStaticMethod(mv.getMethodDescriptor(), registerForReflection.getMethodParam(0)); - - TryBlock tc = mv.tryBlock(); - - ResultHandle clazz = tc.loadClassFromTCCL(entry.getKey()); - //we call these methods first, so if they are going to throw an exception it happens before anything has been registered - ResultHandle constructors = tc - .invokeVirtualMethod(ofMethod(Class.class, "getDeclaredConstructors", Constructor[].class), clazz); - ResultHandle methods = tc.invokeVirtualMethod(ofMethod(Class.class, "getDeclaredMethods", Method[].class), clazz); - ResultHandle fields = tc.invokeVirtualMethod(ofMethod(Class.class, "getDeclaredFields", Field[].class), clazz); - - if (!entry.getValue().weak) { - ResultHandle carray = tc.newArray(Class.class, tc.load(1)); - tc.writeArrayValue(carray, 0, clazz); - tc.invokeStaticMethod(ofMethod(RUNTIME_REFLECTION, "register", void.class, Class[].class), - carray); - - if (entry.getValue().constructors) { - tc.invokeStaticMethod( - ofMethod(RUNTIME_REFLECTION, "register", void.class, Executable[].class), - constructors); - } else if (!entry.getValue().ctorSet.isEmpty()) { - ResultHandle farray = tc.newArray(Constructor.class, tc.load(1)); - for (ReflectiveMethodBuildItem ctor : entry.getValue().ctorSet) { - ResultHandle paramArray = tc.newArray(Class.class, tc.load(ctor.getParams().length)); - for (int i = 0; i < ctor.getParams().length; ++i) { - String type = ctor.getParams()[i]; - tc.writeArrayValue(paramArray, i, tc.loadClassFromTCCL(type)); - } - ResultHandle fhandle = tc.invokeVirtualMethod( - ofMethod(Class.class, "getDeclaredConstructor", Constructor.class, Class[].class), clazz, - paramArray); - tc.writeArrayValue(farray, 0, fhandle); - tc.invokeStaticMethod( - ofMethod(RUNTIME_REFLECTION, "register", void.class, Executable[].class), - farray); - } - } - if (entry.getValue().methods) { - tc.invokeStaticMethod( - ofMethod(RUNTIME_REFLECTION, "register", void.class, Executable[].class), - methods); - } else if (!entry.getValue().methodSet.isEmpty()) { - ResultHandle farray = tc.newArray(Method.class, tc.load(1)); - for (ReflectiveMethodBuildItem method : entry.getValue().methodSet) { - ResultHandle paramArray = tc.newArray(Class.class, tc.load(method.getParams().length)); - for (int i = 0; i < method.getParams().length; ++i) { - String type = method.getParams()[i]; - tc.writeArrayValue(paramArray, i, tc.loadClassFromTCCL(type)); - } - ResultHandle fhandle = tc.invokeVirtualMethod( - ofMethod(Class.class, "getDeclaredMethod", Method.class, String.class, Class[].class), clazz, - tc.load(method.getName()), paramArray); - tc.writeArrayValue(farray, 0, fhandle); - tc.invokeStaticMethod( - ofMethod(RUNTIME_REFLECTION, "register", void.class, Executable[].class), - farray); - } - } - if (entry.getValue().fields) { - tc.invokeStaticMethod( - ofMethod(RUNTIME_REFLECTION, "register", void.class, - boolean.class, boolean.class, Field[].class), - tc.load(entry.getValue().finalFieldsWritable), tc.load(entry.getValue().serialization), fields); - } else if (!entry.getValue().fieldSet.isEmpty()) { - ResultHandle farray = tc.newArray(Field.class, tc.load(1)); - for (String field : entry.getValue().fieldSet) { - ResultHandle fhandle = tc.invokeVirtualMethod( - ofMethod(Class.class, "getDeclaredField", Field.class, String.class), clazz, tc.load(field)); - tc.writeArrayValue(farray, 0, fhandle); - tc.invokeStaticMethod( - ofMethod(RUNTIME_REFLECTION, "register", void.class, Field[].class), - farray); - } - } - } else { - tc.invokeStaticMethod(WEAK_REFLECTION_REGISTRATION, tc.getMethodParam(0), clazz, - tc.load(entry.getValue().constructors), tc.load(entry.getValue().methods), - tc.load(entry.getValue().fields)); - } - - if (entry.getValue().serialization) { - if (registerSerializationMethod == null) { - registerSerializationMethod = createRegisterSerializationForClassMethod(file); - } - - tc.invokeStaticMethod(registerSerializationMethod, clazz); - } - - CatchBlockCreator cc = tc.addCatch(Throwable.class); - //cc.invokeVirtualMethod(ofMethod(Throwable.class, "printStackTrace", void.class), cc.getCaughtException()); - mv.returnValue(null); - } - registerForReflection.returnVoid(); - overallCatch.invokeStaticMethod(registerForReflection.getMethodDescriptor(), beforeAnalysisParam); - - count = 0; - for (JniRuntimeAccessBuildItem jniAccessible : jniRuntimeAccessibleClasses) { for (String className : jniAccessible.getClassNames()) { MethodCreator mv = file.getMethodCreator("registerJniAccessibleClass" + count++, "V"); @@ -728,100 +523,4 @@ public void write(String s, byte[] bytes) { file.close(); } - private MethodDescriptor createRegisterSerializationForClassMethod(ClassCreator file) { - // method to register class for registration - MethodCreator addSerializationForClass = file.getMethodCreator("registerSerializationForClass", "V", Class.class); - addSerializationForClass.setModifiers(Modifier.PRIVATE | Modifier.STATIC); - ResultHandle clazz = addSerializationForClass.getMethodParam(0); - - TryBlock tc = addSerializationForClass.tryBlock(); - - ResultHandle runtimeSerializationClass = tc.loadClassFromTCCL(RUNTIME_SERIALIZATION); - ResultHandle registerArgTypes = tc.newArray(Class.class, tc.load(1)); - tc.writeArrayValue(registerArgTypes, 0, tc.loadClassFromTCCL(Class[].class)); - ResultHandle registerLookupMethod = tc.invokeStaticMethod(LOOKUP_METHOD, runtimeSerializationClass, - tc.load("register"), registerArgTypes); - ResultHandle registerArgs = tc.newArray(Object.class, tc.load(1)); - ResultHandle classesToRegister = tc.newArray(Class.class, tc.load(1)); - tc.writeArrayValue(classesToRegister, 0, clazz); - tc.writeArrayValue(registerArgs, 0, classesToRegister); - tc.invokeVirtualMethod(INVOKE, registerLookupMethod, - tc.loadNull(), registerArgs); - tc.returnValue(null); - - addSerializationForClass.returnValue(null); - - return addSerializationForClass.getMethodDescriptor(); - } - - public void addReflectiveMethod(Map reflectiveClasses, ReflectiveMethodBuildItem methodInfo) { - String cl = methodInfo.getDeclaringClass(); - ReflectionInfo existing = reflectiveClasses.get(cl); - if (existing == null) { - reflectiveClasses.put(cl, existing = new ReflectionInfo(false, false, false, false, false, false)); - } - if (methodInfo.getName().equals("")) { - existing.ctorSet.add(methodInfo); - } else { - existing.methodSet.add(methodInfo); - } - } - - public void addReflectiveClass(Map reflectiveClasses, Set forcedNonWeakClasses, - boolean constructors, boolean method, - boolean fields, boolean finalFieldsWritable, boolean weak, boolean serialization, - String... className) { - for (String cl : className) { - ReflectionInfo existing = reflectiveClasses.get(cl); - if (existing == null) { - reflectiveClasses.put(cl, new ReflectionInfo(constructors, method, fields, finalFieldsWritable, - !forcedNonWeakClasses.contains(cl) && weak, serialization)); - } else { - if (constructors) { - existing.constructors = true; - } - if (method) { - existing.methods = true; - } - if (fields) { - existing.fields = true; - } - if (serialization) { - existing.serialization = true; - } - } - } - } - - public void addReflectiveField(Map reflectiveClasses, ReflectiveFieldBuildItem fieldInfo) { - String cl = fieldInfo.getDeclaringClass(); - ReflectionInfo existing = reflectiveClasses.get(cl); - if (existing == null) { - reflectiveClasses.put(cl, existing = new ReflectionInfo(false, false, false, false, false, false)); - } - existing.fieldSet.add(fieldInfo.getName()); - } - - static final class ReflectionInfo { - boolean constructors; - boolean methods; - boolean fields; - boolean finalFieldsWritable; - boolean weak; - boolean serialization; - Set fieldSet = new HashSet<>(); - Set methodSet = new HashSet<>(); - Set ctorSet = new HashSet<>(); - - private ReflectionInfo(boolean constructors, boolean methods, boolean fields, boolean finalFieldsWritable, - boolean weak, boolean serialization) { - this.methods = methods; - this.fields = fields; - this.constructors = constructors; - this.finalFieldsWritable = finalFieldsWritable; - this.weak = weak; - this.serialization = serialization; - } - } - } 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 new file mode 100644 index 0000000000000..85fb853d4b62c --- /dev/null +++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageReflectConfigStep.java @@ -0,0 +1,203 @@ +package io.quarkus.deployment.steps; + +import java.io.IOException; +import java.io.StringWriter; +import java.nio.charset.StandardCharsets; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import io.quarkus.builder.Json; +import io.quarkus.builder.Json.JsonArrayBuilder; +import io.quarkus.builder.Json.JsonObjectBuilder; +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.GeneratedResourceBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ForceNonWeakReflectiveClassBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassConditionBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveFieldBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveMethodBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; +import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; + +public class NativeImageReflectConfigStep { + + @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class) + void generateReflectConfig(BuildProducer reflectConfig, + List reflectiveMethods, + List reflectiveFields, + List reflectiveClassBuildItems, + List nonWeakReflectiveClassBuildItems, + List serviceProviderBuildItems, + List reflectiveClassConditionBuildItems) { + + final Map reflectiveClasses = new LinkedHashMap<>(); + final Set forcedNonWeakClasses = new HashSet<>(); + for (ForceNonWeakReflectiveClassBuildItem nonWeakReflectiveClassBuildItem : nonWeakReflectiveClassBuildItems) { + forcedNonWeakClasses.add(nonWeakReflectiveClassBuildItem.getClassName()); + } + for (ReflectiveClassBuildItem i : reflectiveClassBuildItems) { + addReflectiveClass(reflectiveClasses, forcedNonWeakClasses, i.isConstructors(), i.isMethods(), i.isFields(), + i.isWeak(), i.isSerialization(), i.getClassNames().toArray(new String[0])); + } + for (ReflectiveFieldBuildItem i : reflectiveFields) { + addReflectiveField(reflectiveClasses, i); + } + for (ReflectiveMethodBuildItem i : reflectiveMethods) { + addReflectiveMethod(reflectiveClasses, i); + } + + for (ServiceProviderBuildItem i : serviceProviderBuildItems) { + addReflectiveClass(reflectiveClasses, forcedNonWeakClasses, true, false, false, false, false, + i.providers().toArray(new String[] {})); + } + + // Perform this as last step, since it augments the already added reflective classes + for (ReflectiveClassConditionBuildItem i : reflectiveClassConditionBuildItems) { + reflectiveClasses.computeIfPresent(i.getClassName(), (key, value) -> { + value.typeReachable = i.getTypeReachable(); + return value; + }); + } + + JsonArrayBuilder root = Json.array(); + for (Map.Entry entry : reflectiveClasses.entrySet()) { + JsonObjectBuilder json = Json.object(); + + json.put("name", entry.getKey()); + + ReflectionInfo info = entry.getValue(); + 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()); + JsonArrayBuilder paramsArray = Json.array(); + for (int i = 0; i < ctor.getParams().length; ++i) { + paramsArray.add(ctor.getParams()[i]); + } + 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()); + JsonArrayBuilder paramsArray = Json.array(); + for (int i = 0; i < method.getParams().length; ++i) { + paramsArray.add(method.getParams()[i]); + } + methodObject.put("parameterTypes", paramsArray); + methodsArray.add(methodObject); + } + json.put("methods", methodsArray); + } + if (info.fields) { + json.put("allDeclaredFields", true); + } else if (!info.fieldSet.isEmpty()) { + JsonArrayBuilder fieldsArray = Json.array(); + for (String fieldName : info.fieldSet) { + fieldsArray.add(Json.object().put("name", fieldName)); + } + json.put("fields", fieldsArray); + } + + root.add(json); + } + + try (StringWriter writer = new StringWriter()) { + root.appendTo(writer); + reflectConfig.produce(new GeneratedResourceBuildItem("META-INF/native-image/reflect-config.json", + writer.toString().getBytes(StandardCharsets.UTF_8))); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public void addReflectiveMethod(Map reflectiveClasses, ReflectiveMethodBuildItem methodInfo) { + String cl = methodInfo.getDeclaringClass(); + ReflectionInfo existing = reflectiveClasses.get(cl); + if (existing == null) { + reflectiveClasses.put(cl, existing = new ReflectionInfo()); + } + if (methodInfo.getName().equals("")) { + existing.ctorSet.add(methodInfo); + } else { + existing.methodSet.add(methodInfo); + } + } + + public void addReflectiveClass(Map reflectiveClasses, Set forcedNonWeakClasses, + boolean constructors, boolean method, + boolean fields, boolean weak, boolean serialization, + String... className) { + for (String cl : className) { + ReflectionInfo existing = reflectiveClasses.get(cl); + if (existing == null) { + String typeReachable = (!forcedNonWeakClasses.contains(cl) && weak) ? cl : null; + reflectiveClasses.put(cl, new ReflectionInfo(constructors, method, fields, + typeReachable, serialization)); + } else { + if (constructors) { + existing.constructors = true; + } + if (method) { + existing.methods = true; + } + if (fields) { + existing.fields = true; + } + if (serialization) { + existing.serialization = true; + } + } + } + } + + public void addReflectiveField(Map reflectiveClasses, ReflectiveFieldBuildItem fieldInfo) { + String cl = fieldInfo.getDeclaringClass(); + ReflectionInfo existing = reflectiveClasses.get(cl); + if (existing == null) { + reflectiveClasses.put(cl, existing = new ReflectionInfo()); + } + existing.fieldSet.add(fieldInfo.getName()); + } + + static final class ReflectionInfo { + boolean constructors; + boolean methods; + boolean fields; + boolean serialization; + String typeReachable; + Set fieldSet = new HashSet<>(); + Set methodSet = new HashSet<>(); + Set ctorSet = new HashSet<>(); + + private ReflectionInfo() { + this(false, false, false, null, false); + } + + private ReflectionInfo(boolean constructors, boolean methods, boolean fields, String typeReachable, + boolean serialization) { + this.methods = methods; + this.fields = fields; + this.typeReachable = typeReachable; + this.constructors = constructors; + this.serialization = serialization; + } + } + +} diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageSerializationConfigStep.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageSerializationConfigStep.java new file mode 100644 index 0000000000000..da7fd099fff3d --- /dev/null +++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageSerializationConfigStep.java @@ -0,0 +1,60 @@ +package io.quarkus.deployment.steps; + +import java.io.IOException; +import java.io.StringWriter; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import io.quarkus.builder.Json; +import io.quarkus.builder.Json.JsonArrayBuilder; +import io.quarkus.builder.Json.JsonObjectBuilder; +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.GeneratedResourceBuildItem; +import io.quarkus.deployment.builditem.nativeimage.LambdaCapturingTypeBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; + +public class NativeImageSerializationConfigStep { + + @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class) + void generateSerializationConfig(BuildProducer serializationConfig, + List reflectiveClassBuildItems, + List lambdaCapturingTypeBuildItems) { + + final Set serializableClasses = new HashSet<>(); + for (ReflectiveClassBuildItem i : reflectiveClassBuildItems) { + if (i.isSerialization()) { + String[] classNames = i.getClassNames().toArray(new String[0]); + Collections.addAll(serializableClasses, classNames); + } + } + + JsonObjectBuilder root = Json.object(); + JsonArrayBuilder types = Json.array(); + for (String serializableClass : serializableClasses) { + types.add(Json.object().put("name", serializableClass)); + } + root.put("types", types); + + JsonArrayBuilder lambdaCapturingTypes = Json.array(); + if (!lambdaCapturingTypeBuildItems.isEmpty()) { + for (LambdaCapturingTypeBuildItem i : lambdaCapturingTypeBuildItems) { + lambdaCapturingTypes.add(Json.object().put("name", i.getClassName())); + } + } + root.put("lambdaCapturingTypes", lambdaCapturingTypes); + + try (StringWriter writer = new StringWriter()) { + root.appendTo(writer); + serializationConfig.produce(new GeneratedResourceBuildItem("META-INF/native-image/serialization-config.json", + writer.toString().getBytes(StandardCharsets.UTF_8))); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + +} diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/ReflectiveHierarchyStep.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/ReflectiveHierarchyStep.java index ebcb59cdd0290..9bbc4518ac531 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/steps/ReflectiveHierarchyStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/ReflectiveHierarchyStep.java @@ -214,7 +214,6 @@ private void addClassTypeHierarchy(CombinedIndexBuildItem combinedIndexBuildItem .builder(name.toString()) .methods(true) .fields(true) - .finalFieldsWritable(doFinalFieldsNeedToBeWritable(info, finalFieldsWritable)) .serialization(reflectiveHierarchyBuildItem.isSerialization()) .build()); @@ -279,10 +278,4 @@ private static Type getFieldType(CombinedIndexBuildItem combinedIndexBuildItem, return fieldType; } - private static boolean doFinalFieldsNeedToBeWritable(ClassInfo classInfo, Predicate finalFieldsWritable) { - if (classInfo == null) { - return false; - } - return finalFieldsWritable.test(classInfo); - } } diff --git a/core/runtime/src/main/java/io/quarkus/runtime/graal/WeakReflection.java b/core/runtime/src/main/java/io/quarkus/runtime/graal/WeakReflection.java deleted file mode 100644 index f4314777935ed..0000000000000 --- a/core/runtime/src/main/java/io/quarkus/runtime/graal/WeakReflection.java +++ /dev/null @@ -1,55 +0,0 @@ -package io.quarkus.runtime.graal; - -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Consumer; - -import org.graalvm.nativeimage.hosted.Feature; -import org.graalvm.nativeimage.hosted.RuntimeReflection; -import org.jboss.logging.Logger; - -/** - * Weak reflection implementation called from generated bytecode - */ -public class WeakReflection { - - static final Logger log = Logger.getLogger(WeakReflection.class); - - public static void register(Feature.BeforeAnalysisAccess analysisAccess, Class clazz, boolean constructors, - boolean methods, boolean fields) { - analysisAccess.registerReachabilityHandler(new Callback(clazz, constructors, methods, fields), clazz); - } - - public static class Callback implements Consumer { - final AtomicBoolean onlyOnce = new AtomicBoolean(false); - final Class clazz; - final boolean constructors; - final boolean methods; - final boolean fields; - - public Callback(Class clazz, boolean constructors, boolean methods, boolean fields) { - this.clazz = clazz; - this.constructors = constructors; - this.methods = methods; - this.fields = fields; - } - - @Override - public void accept(Feature.DuringAnalysisAccess duringAnalysisAccess) { - if (!onlyOnce.compareAndSet(false, true)) { - return; - } - log.debugf("Registering %s for reflection as it is reachable", clazz); - RuntimeReflection.register(clazz); - if (fields) { - RuntimeReflection.register(clazz.getDeclaredFields()); - } - if (constructors) { - RuntimeReflection.register(clazz.getDeclaredConstructors()); - } - if (methods) { - RuntimeReflection.register(clazz.getDeclaredMethods()); - } - } - } - -} diff --git a/extensions/jaeger/deployment/src/main/java/io/quarkus/jaeger/deployment/JaegerProcessor.java b/extensions/jaeger/deployment/src/main/java/io/quarkus/jaeger/deployment/JaegerProcessor.java index 6d5d3d6f9550a..e0d624d2d8f53 100644 --- a/extensions/jaeger/deployment/src/main/java/io/quarkus/jaeger/deployment/JaegerProcessor.java +++ b/extensions/jaeger/deployment/src/main/java/io/quarkus/jaeger/deployment/JaegerProcessor.java @@ -57,7 +57,6 @@ public ReflectiveClassBuildItem reflectiveClasses() { "io.jaegertracing.internal.samplers.http.RateLimitingSamplingStrategy", "io.jaegertracing.internal.samplers.http.SamplingStrategyResponse") .fields(true) - .finalFieldsWritable(true) .build(); } } diff --git a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaProcessor.java b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaProcessor.java index 6e760ce85a1c7..fa3ae509b1181 100644 --- a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaProcessor.java +++ b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaProcessor.java @@ -80,6 +80,7 @@ import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageSecurityProviderBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassConditionBuildItem; import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; import io.quarkus.deployment.logging.LogCleanupFilterBuildItem; @@ -418,6 +419,7 @@ public AdditionalBeanBuildItem runtimeConfig() { @BuildStep public void withSasl(CombinedIndexBuildItem index, BuildProducer reflectiveClass, + BuildProducer reflectiveClassCondition, BuildProducer sslNativeSupport) { reflectiveClass @@ -441,6 +443,10 @@ public void withSasl(CombinedIndexBuildItem index, for (ClassInfo authenticateCallbackHandler : index.getIndex().getAllKnownImplementors(AUTHENTICATE_CALLBACK_HANDLER)) { reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, authenticateCallbackHandler.name().toString())); } + // Add a condition for the optional authenticate callback handler + reflectiveClassCondition.produce(new ReflectiveClassConditionBuildItem( + "org.apache.kafka.common.security.oauthbearer.secured.OAuthBearerValidatorCallbackHandler", + "org.jose4j.keys.resolvers.VerificationKeyResolver")); } private void registerJDKLoginModules(BuildProducer reflectiveClass) { diff --git a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java b/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java index 3e8ae58571990..d44185c471cf4 100644 --- a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java +++ b/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java @@ -49,6 +49,7 @@ import io.quarkus.deployment.builditem.TransformedClassesBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBundleBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassConditionBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyBuildItem; import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; import io.quarkus.deployment.metrics.MetricsCapabilityBuildItem; @@ -80,6 +81,8 @@ import io.smallrye.graphql.cdi.config.ConfigKey; import io.smallrye.graphql.cdi.config.MicroProfileConfig; import io.smallrye.graphql.cdi.producer.GraphQLProducer; +import io.smallrye.graphql.cdi.tracing.TracingService; +import io.smallrye.graphql.cdi.validation.ValidationService; import io.smallrye.graphql.schema.Annotations; import io.smallrye.graphql.schema.SchemaBuilder; import io.smallrye.graphql.schema.model.Argument; @@ -187,13 +190,19 @@ void addDependencies(BuildProducer indexDependency) { } @BuildStep - void registerNativeImageResources(BuildProducer serviceProvider) throws IOException { + void registerNativeImageResources(BuildProducer serviceProvider, + BuildProducer reflectiveClassCondition) throws IOException { // Lookup Service (We use the one from the CDI Module) serviceProvider.produce(ServiceProviderBuildItem.allProvidersFromClassPath(LookupService.class.getName())); // Eventing Service (We use the one from the CDI Module) serviceProvider.produce(ServiceProviderBuildItem.allProvidersFromClassPath(EventingService.class.getName())); + // Add a condition for the optional eventing services + reflectiveClassCondition.produce(new ReflectiveClassConditionBuildItem(TracingService.class, "io.opentracing.Tracer")); + reflectiveClassCondition + .produce(new ReflectiveClassConditionBuildItem(ValidationService.class, "javax.validation.ValidatorFactory")); + // Use MicroProfile Config (We use the one from the CDI Module) serviceProvider.produce(ServiceProviderBuildItem.allProvidersFromClassPath(MicroProfileConfig.class.getName())); diff --git a/extensions/smallrye-reactive-messaging-kafka/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/SmallRyeReactiveMessagingKafkaProcessor.java b/extensions/smallrye-reactive-messaging-kafka/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/SmallRyeReactiveMessagingKafkaProcessor.java index f3844c2e911ee..d383c31393626 100644 --- a/extensions/smallrye-reactive-messaging-kafka/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/SmallRyeReactiveMessagingKafkaProcessor.java +++ b/extensions/smallrye-reactive-messaging-kafka/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/SmallRyeReactiveMessagingKafkaProcessor.java @@ -70,7 +70,6 @@ public void build(BuildProducer reflectiveClass) { .fields(true) .methods(true) .constructors(true) - .finalFieldsWritable(true) .build()); reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, ProcessingState.class)); } diff --git a/integration-tests/test-extension/extension/deployment/src/main/java/io/quarkus/extest/deployment/TestProcessor.java b/integration-tests/test-extension/extension/deployment/src/main/java/io/quarkus/extest/deployment/TestProcessor.java index 01b27cd7d4002..e0c6766c64cef 100644 --- a/integration-tests/test-extension/extension/deployment/src/main/java/io/quarkus/extest/deployment/TestProcessor.java +++ b/integration-tests/test-extension/extension/deployment/src/main/java/io/quarkus/extest/deployment/TestProcessor.java @@ -447,7 +447,6 @@ void registerFinalFieldReflectionObject(BuildProducer .builder(FinalFieldReflectionObject.class.getName()) .methods(true) .fields(true) - .finalFieldsWritable(true) .build(); classes.produce(finalField); }