diff --git a/extensions/smallrye-opentracing/runtime/src/main/java/io/quarkus/smallrye/opentracing/runtime/graal/Target_org_jboss_resteasy_microprofile_config_FilterConfigSource.java b/extensions/smallrye-opentracing/runtime/src/main/java/io/quarkus/smallrye/opentracing/runtime/graal/Target_org_jboss_resteasy_microprofile_config_FilterConfigSource.java index e1c6fb2877a35..573b4d6f43276 100644 --- a/extensions/smallrye-opentracing/runtime/src/main/java/io/quarkus/smallrye/opentracing/runtime/graal/Target_org_jboss_resteasy_microprofile_config_FilterConfigSource.java +++ b/extensions/smallrye-opentracing/runtime/src/main/java/io/quarkus/smallrye/opentracing/runtime/graal/Target_org_jboss_resteasy_microprofile_config_FilterConfigSource.java @@ -1,6 +1,6 @@ package io.quarkus.smallrye.opentracing.runtime.graal; -import org.jboss.resteasy.microprofile.config.FilterConfigSource; +import java.util.function.BooleanSupplier; import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.RecomputeFieldValue; @@ -9,9 +9,14 @@ /** * see {@link Target_org_jboss_resteasy_microprofile_config_ServletContextConfigSource} */ -@TargetClass(value = FilterConfigSource.class, onlyWith = UndertowMissing.class) +@TargetClass(className = Target_org_jboss_resteasy_microprofile_config_FilterConfigSource.FILTER_CONFIG_SOURCE_NAME, onlyWith = { + UndertowMissing.class, + Target_org_jboss_resteasy_microprofile_config_FilterConfigSource.FilterConfigSourceIsLoaded.class +}) final class Target_org_jboss_resteasy_microprofile_config_FilterConfigSource { + static final String FILTER_CONFIG_SOURCE_NAME = "org.jboss.resteasy.microprofile.config.FilterConfigSource"; + @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias) private static boolean SERVLET_AVAILABLE = false; @@ -19,4 +24,17 @@ final class Target_org_jboss_resteasy_microprofile_config_FilterConfigSource { @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) private static Class clazz; + + static class FilterConfigSourceIsLoaded implements BooleanSupplier { + + @Override + public boolean getAsBoolean() { + try { + Class.forName(FILTER_CONFIG_SOURCE_NAME); + return true; + } catch (ClassNotFoundException e) { + return false; + } + } + } } diff --git a/extensions/smallrye-opentracing/runtime/src/main/java/io/quarkus/smallrye/opentracing/runtime/graal/Target_org_jboss_resteasy_microprofile_config_ServletConfigSource.java b/extensions/smallrye-opentracing/runtime/src/main/java/io/quarkus/smallrye/opentracing/runtime/graal/Target_org_jboss_resteasy_microprofile_config_ServletConfigSource.java index 31031035b53bb..510b17559809d 100644 --- a/extensions/smallrye-opentracing/runtime/src/main/java/io/quarkus/smallrye/opentracing/runtime/graal/Target_org_jboss_resteasy_microprofile_config_ServletConfigSource.java +++ b/extensions/smallrye-opentracing/runtime/src/main/java/io/quarkus/smallrye/opentracing/runtime/graal/Target_org_jboss_resteasy_microprofile_config_ServletConfigSource.java @@ -1,6 +1,6 @@ package io.quarkus.smallrye.opentracing.runtime.graal; -import org.jboss.resteasy.microprofile.config.ServletConfigSource; +import java.util.function.BooleanSupplier; import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.RecomputeFieldValue; @@ -9,9 +9,14 @@ /** * see {@link Target_org_jboss_resteasy_microprofile_config_ServletContextConfigSource} */ -@TargetClass(value = ServletConfigSource.class, onlyWith = UndertowMissing.class) +@TargetClass(className = Target_org_jboss_resteasy_microprofile_config_ServletConfigSource.SERVLET_CONFIG_SOURCE_NAME, onlyWith = { + UndertowMissing.class, + Target_org_jboss_resteasy_microprofile_config_ServletConfigSource.ServletConfigSourceIsLoaded.class, +}) final class Target_org_jboss_resteasy_microprofile_config_ServletConfigSource { + static final String SERVLET_CONFIG_SOURCE_NAME = "org.jboss.resteasy.microprofile.config.ServletConfigSource"; + @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias) private static boolean SERVLET_AVAILABLE = false; @@ -19,4 +24,17 @@ final class Target_org_jboss_resteasy_microprofile_config_ServletConfigSource { @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) private static Class clazz; + + static class ServletConfigSourceIsLoaded implements BooleanSupplier { + + @Override + public boolean getAsBoolean() { + try { + Class.forName(SERVLET_CONFIG_SOURCE_NAME); + return true; + } catch (ClassNotFoundException e) { + return false; + } + } + } } diff --git a/extensions/smallrye-opentracing/runtime/src/main/java/io/quarkus/smallrye/opentracing/runtime/graal/Target_org_jboss_resteasy_microprofile_config_ServletContextConfigSource.java b/extensions/smallrye-opentracing/runtime/src/main/java/io/quarkus/smallrye/opentracing/runtime/graal/Target_org_jboss_resteasy_microprofile_config_ServletContextConfigSource.java index 34f9c4d82c402..ce6fa2809313d 100644 --- a/extensions/smallrye-opentracing/runtime/src/main/java/io/quarkus/smallrye/opentracing/runtime/graal/Target_org_jboss_resteasy_microprofile_config_ServletContextConfigSource.java +++ b/extensions/smallrye-opentracing/runtime/src/main/java/io/quarkus/smallrye/opentracing/runtime/graal/Target_org_jboss_resteasy_microprofile_config_ServletContextConfigSource.java @@ -1,5 +1,7 @@ package io.quarkus.smallrye.opentracing.runtime.graal; +import java.util.function.BooleanSupplier; + import org.jboss.resteasy.microprofile.config.ServletContextConfigSource; import org.jboss.resteasy.microprofile.config.ServletContextConfigSourceImpl; @@ -17,10 +19,20 @@ * GraalVM failing because the class cannot be instantiated. * * See https://github.com/quarkusio/quarkus/issues/9086 + * + * Furthermore, we only reference the class by its name as not avoid having GraalVM fail if the class is not on classpath + * at all. + * + * See https://github.com/quarkusio/quarkus/issues/14876 */ -@TargetClass(value = ServletContextConfigSource.class, onlyWith = UndertowMissing.class) +@TargetClass(className = Target_org_jboss_resteasy_microprofile_config_ServletContextConfigSource.SERVLET_CONTEXT_CONFIG_SOURCE_NAME, onlyWith = { + UndertowMissing.class, + Target_org_jboss_resteasy_microprofile_config_ServletContextConfigSource.ServletContextConfigSourceIsLoaded.class +}) final class Target_org_jboss_resteasy_microprofile_config_ServletContextConfigSource { + static final String SERVLET_CONTEXT_CONFIG_SOURCE_NAME = "org.jboss.resteasy.microprofile.config.ServletContextConfigSource"; + @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias) private static boolean SERVLET_AVAILABLE = false; @@ -28,4 +40,16 @@ final class Target_org_jboss_resteasy_microprofile_config_ServletContextConfigSo @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) private static Class clazz; + + static class ServletContextConfigSourceIsLoaded implements BooleanSupplier { + @Override + public boolean getAsBoolean() { + try { + Class.forName(SERVLET_CONTEXT_CONFIG_SOURCE_NAME); + return true; + } catch (ClassNotFoundException e) { + return false; + } + } + } }