Skip to content

Commit

Permalink
Merge pull request #14882 from geoand/#14876
Browse files Browse the repository at this point in the history
Fix native-image compilation issue with OpenTracing and RESTEasy Reactive
  • Loading branch information
gsmet authored Feb 8, 2021
2 parents 3af53cc + e74c096 commit 28b3251
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -9,14 +9,32 @@
/**
* 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;

@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;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -9,14 +9,32 @@
/**
* 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;

@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;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -17,15 +19,37 @@
* 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;

@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;
}
}
}
}

0 comments on commit 28b3251

Please sign in to comment.