Skip to content

Commit 852a5c1

Browse files
committed
Fix jaxb substitutions
* Unconditionally substitute jaxb methods to detect changes in libraries through failures, as done for other libraries * Remove substitutions for com.sun.xml.internal.* Classes, they don't exist in the org.glassfish.jaxb:jaxb-runtime jaxb implementation The above two were not done previously in order to support Java 8 which Quarkus no longer supports.
1 parent 8b379af commit 852a5c1

File tree

1 file changed

+5
-105
lines changed

1 file changed

+5
-105
lines changed

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

Lines changed: 5 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
import java.lang.annotation.Annotation;
44
import java.lang.reflect.Field;
55
import java.lang.reflect.Method;
6-
import java.util.function.BooleanSupplier;
76

87
import com.oracle.svm.core.annotate.Substitute;
98
import com.oracle.svm.core.annotate.TargetClass;
109

11-
@TargetClass(className = "com.sun.xml.bind.v2.model.nav.ReflectionNavigator", onlyWith = Target_com_sun_xml_bind_v2_model_nav_ReflectionNavigator.Selector.class)
10+
@TargetClass(className = "com.sun.xml.bind.v2.model.nav.ReflectionNavigator")
1211
final class Target_com_sun_xml_bind_v2_model_nav_ReflectionNavigator {
1312

1413
@Substitute
@@ -26,21 +25,9 @@ public Field[] getEnumConstants(Class clazz) {
2625
}
2726
}
2827

29-
static final class Selector implements BooleanSupplier {
30-
31-
@Override
32-
public boolean getAsBoolean() {
33-
try {
34-
Class.forName("com.sun.xml.bind.v2.model.nav.ReflectionNavigator");
35-
return true;
36-
} catch (Exception e) {
37-
return false;
38-
}
39-
}
40-
}
4128
}
4229

43-
@TargetClass(className = "com.sun.xml.bind.v2.runtime.reflect.opt.AccessorInjector", onlyWith = Target_com_sun_xml_bind_v2_runtime_reflect_opt_AccessorInjector.Selector.class)
30+
@TargetClass(className = "com.sun.xml.bind.v2.runtime.reflect.opt.AccessorInjector")
4431
@Substitute
4532
final class Target_com_sun_xml_bind_v2_runtime_reflect_opt_AccessorInjector {
4633

@@ -56,23 +43,10 @@ public static Class<?> prepare(
5643
return null;
5744
}
5845

59-
static final class Selector implements BooleanSupplier {
60-
61-
@Override
62-
public boolean getAsBoolean() {
63-
try {
64-
Class<?> c = Class.forName("com.sun.xml.bind.v2.runtime.reflect.opt.AccessorInjector");
65-
c.getDeclaredMethod("prepare", Class.class, Class.class, String.class, String.class, String[].class);
66-
return true;
67-
} catch (Exception e) {
68-
return false;
69-
}
70-
}
71-
}
7246
}
7347

74-
@TargetClass(className = "com.sun.xml.internal.bind.v2.model.annotation.LocatableAnnotation", onlyWith = Target_com_sun_xml_internal_bind_v2_model_annotation_LocatableAnnotation.Selector.class)
75-
final class Target_com_sun_xml_internal_bind_v2_model_annotation_LocatableAnnotation {
48+
@TargetClass(className = "com.sun.xml.bind.v2.model.annotation.LocatableAnnotation")
49+
final class Target_com_sun_xml_bind_v2_model_annotation_LocatableAnnotation {
7650

7751
@Substitute
7852
public static <A extends Annotation> A create(A annotation, Locatable parentSourcePos) {
@@ -84,85 +58,11 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
8458
throw new RuntimeException("Not implemented");
8559
}
8660

87-
@TargetClass(className = "com.sun.xml.internal.bind.v2.model.annotation.Locatable", onlyWith = Target_com_sun_xml_internal_bind_v2_model_annotation_LocatableAnnotation.Selector.class)
61+
@TargetClass(className = "com.sun.xml.bind.v2.model.annotation.Locatable")
8862
static final class Locatable {
8963

9064
}
9165

92-
static final class Selector implements BooleanSupplier {
93-
94-
@Override
95-
public boolean getAsBoolean() {
96-
try {
97-
Class.forName("com.sun.xml.internal.bind.v2.model.annotation.LocatableAnnotation");
98-
return true;
99-
} catch (ClassNotFoundException e) {
100-
return false;
101-
}
102-
}
103-
}
104-
}
105-
106-
@TargetClass(className = "com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator", onlyWith = Target_com_sun_xml_internal_bind_v2_model_nav_ReflectionNavigator.Selector.class)
107-
final class Target_com_sun_xml_internal_bind_v2_model_nav_ReflectionNavigator {
108-
109-
@Substitute
110-
public Field[] getEnumConstants(Class clazz) {
111-
try {
112-
Object[] values = clazz.getEnumConstants();
113-
Field[] fields = new Field[values.length];
114-
for (int i = 0; i < values.length; i++) {
115-
fields[i] = clazz.getField(((Enum) values[i]).name());
116-
}
117-
return fields;
118-
} catch (NoSuchFieldException e) {
119-
// impossible
120-
throw new NoSuchFieldError(clazz.getName() + ": " + e.getMessage());
121-
}
122-
}
123-
124-
static final class Selector implements BooleanSupplier {
125-
126-
@Override
127-
public boolean getAsBoolean() {
128-
try {
129-
Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
130-
return true;
131-
} catch (Exception e) {
132-
return false;
133-
}
134-
}
135-
}
136-
}
137-
138-
@TargetClass(className = "com.sun.xml.internal.bind.v2.runtime.reflect.opt.AccessorInjector", onlyWith = Target_com_sun_xml_internal_bind_v2_runtime_reflect_opt_AccessorInjector.Selector.class)
139-
@Substitute
140-
final class Target_com_sun_xml_internal_bind_v2_runtime_reflect_opt_AccessorInjector {
141-
142-
/**
143-
* Loads the optimized class and returns it.
144-
*
145-
* @return null
146-
* if it fails for some reason.
147-
*/
148-
@Substitute
149-
public static Class<?> prepare(
150-
Class beanClass, String templateClassName, String newClassName, String... replacements) {
151-
return null;
152-
}
153-
154-
static final class Selector implements BooleanSupplier {
155-
156-
@Override
157-
public boolean getAsBoolean() {
158-
try {
159-
Class.forName("com.sun.xml.internal.bind.v2.runtime.reflect.opt.AccessorInjector");
160-
return true;
161-
} catch (Exception e) {
162-
return false;
163-
}
164-
}
165-
}
16666
}
16767

16868
class JAXBSubstitutions {

0 commit comments

Comments
 (0)