From c9edbe64520c0c906a5b481017c44b37e267c3b2 Mon Sep 17 00:00:00 2001 From: Foivos Zakkak Date: Tue, 30 Jul 2024 22:39:36 +0300 Subject: [PATCH] Extend reflection configuration for VertX Doesn't seem to fix any functionality issues but prevents `MissingRegistrationErrors` from being thrown when `ThrowMissingRegistrationErrors` is enabled. Related to https://github.com/quarkusio/quarkus/issues/41995 --- .../SmallRyeFaultToleranceProcessor.java | 4 ++++ .../vertx/deployment/VertxProcessor.java | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/extensions/smallrye-fault-tolerance/deployment/src/main/java/io/quarkus/smallrye/faulttolerance/deployment/SmallRyeFaultToleranceProcessor.java b/extensions/smallrye-fault-tolerance/deployment/src/main/java/io/quarkus/smallrye/faulttolerance/deployment/SmallRyeFaultToleranceProcessor.java index f6c4778e6f508..542c11185381c 100644 --- a/extensions/smallrye-fault-tolerance/deployment/src/main/java/io/quarkus/smallrye/faulttolerance/deployment/SmallRyeFaultToleranceProcessor.java +++ b/extensions/smallrye-fault-tolerance/deployment/src/main/java/io/quarkus/smallrye/faulttolerance/deployment/SmallRyeFaultToleranceProcessor.java @@ -318,6 +318,10 @@ void processFaultToleranceAnnotations(SmallRyeFaultToleranceRecorder recorder, if (ftMethod.isLegitimate()) { ftMethods.add(ftMethod); + // io.smallrye.faulttolerance.internal.SecurityActions.findDeclaredMethodNames accesses class' methods + reflectiveClass + .produce(ReflectiveClassBuildItem.builder(beanClass.name().toString()).queryMethods().build()); + if (annotationStore.hasAnnotation(method, DotNames.ASYNCHRONOUS) && annotationStore.hasAnnotation(method, DotNames.ASYNCHRONOUS_NON_BLOCKING)) { exceptions.add(new DefinitionException( diff --git a/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/VertxProcessor.java b/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/VertxProcessor.java index 1c3d7fb2e9915..438add51a2f58 100644 --- a/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/VertxProcessor.java +++ b/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/VertxProcessor.java @@ -54,7 +54,9 @@ import io.quarkus.deployment.builditem.ServiceStartBuildItem; import io.quarkus.deployment.builditem.ShutdownContextBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageConfigBuildItem; +import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveMethodBuildItem; import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; import io.quarkus.deployment.recording.RecorderContext; import io.quarkus.gizmo.ClassOutput; @@ -274,4 +276,20 @@ private Class tryLoad(String name, ClassLoader tccl) { throw new IllegalStateException("Unable to load type: " + name, e); } } + + @BuildStep + void registerNativeImageResources(BuildProducer resources) { + // Accessed by io.vertx.core.impl.VertxBuilder. + resources.produce(new NativeImageResourceBuildItem("META-INF/services/io.vertx.core.spi.VertxServiceProvider")); + // Accessed by io.vertx.core.impl.VertxImpl. + resources.produce(new NativeImageResourceBuildItem("META-INF/services/io.vertx.core.spi.VerticleFactory")); + } + + @BuildStep + void registerReflectivelyAccessedMethods(BuildProducer reflectiveMethods) { + // Accessed by io.vertx.core.impl.VertxImpl. + reflectiveMethods.produce(new ReflectiveMethodBuildItem("java.lang.Thread$Builder$OfVirtual", "name", + String.class, long.class)); + reflectiveMethods.produce(new ReflectiveMethodBuildItem("java.lang.Thread$Builder", "factory", new Class[0])); + } }