Skip to content

Commit daec663

Browse files
committed
Remove the substitution for LocatableAnnotation and register proxies
This implementation is important and used by JAXB. We just need to register proxies for the combinations of JAXB annotations and Locatable.
1 parent a3f3197 commit daec663

File tree

2 files changed

+17
-30
lines changed

2 files changed

+17
-30
lines changed

extensions/jaxb/deployment/src/main/java/io/quarkus/jaxb/deployment/JaxbProcessor.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.io.IOError;
44
import java.io.IOException;
5+
import java.lang.annotation.Annotation;
56
import java.nio.file.Files;
67
import java.nio.file.Path;
78
import java.util.Arrays;
@@ -48,10 +49,13 @@
4849
import org.jboss.jandex.DotName;
4950
import org.jboss.jandex.IndexView;
5051

52+
import com.sun.xml.bind.v2.model.annotation.Locatable;
53+
5154
import io.quarkus.deployment.annotations.BuildProducer;
5255
import io.quarkus.deployment.annotations.BuildStep;
5356
import io.quarkus.deployment.builditem.ApplicationArchivesBuildItem;
5457
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
58+
import io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem;
5559
import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
5660
import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBundleBuildItem;
5761
import io.quarkus.deployment.builditem.nativeimage.NativeImageSystemPropertyBuildItem;
@@ -61,8 +65,7 @@
6165

6266
class JaxbProcessor {
6367

64-
private static final List<Class<?>> JAXB_REFLECTIVE_CLASSES = Arrays.asList(
65-
XmlAccessOrder.class,
68+
private static final List<Class<? extends Annotation>> JAXB_ANNOTATIONS = Arrays.asList(
6669
XmlAccessorType.class,
6770
XmlAnyAttribute.class,
6871
XmlAnyElement.class,
@@ -95,6 +98,9 @@ class JaxbProcessor {
9598
XmlJavaTypeAdapter.class,
9699
XmlJavaTypeAdapters.class);
97100

101+
private static final List<Class<?>> JAXB_REFLECTIVE_CLASSES = Arrays.asList(
102+
XmlAccessOrder.class);
103+
98104
private static final List<String> JAXB_SERIALIZERS = Arrays.asList(
99105
"html",
100106
"text",
@@ -123,6 +129,7 @@ class JaxbProcessor {
123129
@BuildStep
124130
void process(BuildProducer<NativeImageSystemPropertyBuildItem> nativeImageProps,
125131
BuildProducer<ServiceProviderBuildItem> providerItem,
132+
BuildProducer<NativeImageProxyDefinitionBuildItem> proxyDefinitions,
126133
CombinedIndexBuildItem combinedIndexBuildItem,
127134
List<JaxbFileRootBuildItem> fileRoots) {
128135

@@ -176,7 +183,14 @@ void process(BuildProducer<NativeImageSystemPropertyBuildItem> nativeImageProps,
176183

177184
JAXB_REFLECTIVE_CLASSES.stream()
178185
.map(Class::getName)
179-
.forEach(clazz -> addReflectiveClass(true, false, clazz));
186+
.forEach(className -> addReflectiveClass(true, false, className));
187+
188+
JAXB_ANNOTATIONS.stream()
189+
.map(Class::getName)
190+
.forEach(className -> {
191+
proxyDefinitions.produce(new NativeImageProxyDefinitionBuildItem(className, Locatable.class.getName()));
192+
addReflectiveClass(true, false, className);
193+
});
180194

181195
JAXB_SERIALIZERS.stream()
182196
.map(s -> "com/sun/org/apache/xml/internal/serializer/output_" + s + ".properties")

extensions/jaxb/runtime/src/main/java/io/quarkus/jaxb/runtime/graal/JAXBSubstitutions.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,6 @@
88
import com.oracle.svm.core.annotate.Substitute;
99
import com.oracle.svm.core.annotate.TargetClass;
1010

11-
@TargetClass(className = "com.sun.xml.bind.v2.model.annotation.LocatableAnnotation", onlyWith = Target_com_sun_xml_bind_v2_model_annotation_LocatableAnnotation.Selector.class)
12-
final class Target_com_sun_xml_bind_v2_model_annotation_LocatableAnnotation {
13-
14-
@Substitute
15-
public static <A extends Annotation> A create(A annotation, Locatable parentSourcePos) {
16-
return annotation;
17-
}
18-
19-
@TargetClass(className = "com.sun.xml.bind.v2.model.annotation.Locatable", onlyWith = Target_com_sun_xml_bind_v2_model_annotation_LocatableAnnotation.Selector.class)
20-
static final class Locatable {
21-
22-
}
23-
24-
static final class Selector implements BooleanSupplier {
25-
26-
@Override
27-
public boolean getAsBoolean() {
28-
try {
29-
Class.forName("com.sun.xml.bind.v2.model.annotation.LocatableAnnotation");
30-
return true;
31-
} catch (ClassNotFoundException e) {
32-
return false;
33-
}
34-
}
35-
}
36-
}
37-
3811
@TargetClass(className = "com.sun.xml.bind.v2.model.nav.ReflectionNavigator", onlyWith = Target_com_sun_xml_bind_v2_model_nav_ReflectionNavigator.Selector.class)
3912
final class Target_com_sun_xml_bind_v2_model_nav_ReflectionNavigator {
4013

0 commit comments

Comments
 (0)