Skip to content

Commit f59de5a

Browse files
authored
Merge pull request #38224 from gsmet/revert-jaxb-hierarchy
Revert "Fixing Jaxb unmarshalling error with native compilation"
2 parents c9c90df + ed722a1 commit f59de5a

File tree

5 files changed

+5
-101
lines changed

5 files changed

+5
-101
lines changed

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

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBundleBuildItem;
7171
import io.quarkus.deployment.builditem.nativeimage.NativeImageSystemPropertyBuildItem;
7272
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
73-
import io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyBuildItem;
7473
import io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyIgnoreWarningBuildItem;
7574
import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
7675
import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem;
@@ -187,7 +186,6 @@ void processAnnotationsAndIndexFiles(
187186
BuildProducer<NativeImageProxyDefinitionBuildItem> proxyDefinitions,
188187
CombinedIndexBuildItem combinedIndexBuildItem,
189188
List<JaxbFileRootBuildItem> fileRoots,
190-
BuildProducer<ReflectiveHierarchyBuildItem> reflectiveHierarchies,
191189
BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
192190
BuildProducer<NativeImageResourceBuildItem> resource,
193191
BuildProducer<NativeImageResourceBundleBuildItem> resourceBundle,
@@ -204,11 +202,10 @@ void processAnnotationsAndIndexFiles(
204202
for (DotName jaxbRootAnnotation : JAXB_ROOT_ANNOTATIONS) {
205203
for (AnnotationInstance jaxbRootAnnotationInstance : index
206204
.getAnnotations(jaxbRootAnnotation)) {
207-
if (jaxbRootAnnotationInstance.target().kind() == Kind.CLASS
208-
&& !JAXB_ANNOTATIONS.contains(jaxbRootAnnotationInstance.target().asClass().getClass())) {
209-
DotName targetClass = jaxbRootAnnotationInstance.target().asClass().name();
210-
addReflectiveHierarchyClass(targetClass, reflectiveHierarchies, index);
211-
classesToBeBound.add(targetClass.toString());
205+
if (jaxbRootAnnotationInstance.target().kind() == Kind.CLASS) {
206+
String className = jaxbRootAnnotationInstance.target().asClass().name().toString();
207+
reflectiveClass.produce(ReflectiveClassBuildItem.builder(className).methods().fields().build());
208+
classesToBeBound.add(className);
212209
jaxbRootAnnotationsDetected = true;
213210
}
214211
}
@@ -415,17 +412,6 @@ public static Stream<Path> safeWalk(Path p) {
415412
}
416413
}
417414

418-
private void addReflectiveHierarchyClass(DotName className,
419-
BuildProducer<ReflectiveHierarchyBuildItem> reflectiveHierarchy,
420-
IndexView index) {
421-
Type jandexType = Type.create(className, Type.Kind.CLASS);
422-
reflectiveHierarchy.produce(new ReflectiveHierarchyBuildItem.Builder()
423-
.type(jandexType)
424-
.index(index)
425-
.source(getClass().getSimpleName() + " > " + jandexType.name().toString())
426-
.build());
427-
}
428-
429415
private void addReflectiveClass(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, boolean methods, boolean fields,
430416
String... className) {
431417
reflectiveClass.produce(new ReflectiveClassBuildItem(methods, fields, className));

integration-tests/jaxb/src/main/java/io/quarkus/it/jaxb/BookIBANField.java

Lines changed: 0 additions & 24 deletions
This file was deleted.

integration-tests/jaxb/src/main/java/io/quarkus/it/jaxb/BookWithParent.java

Lines changed: 0 additions & 27 deletions
This file was deleted.

integration-tests/jaxb/src/main/java/io/quarkus/it/jaxb/JaxbResource.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,4 @@ public io.quarkus.it.jaxb.Response seeAlso() {
6565
return response;
6666
}
6767

68-
//Test for Jaxb with parent class field
69-
@Path("/bookwithparent")
70-
@GET
71-
@Produces(MediaType.TEXT_PLAIN)
72-
public String getBookWithParent(@QueryParam("name") String name, @QueryParam("iban") String iban) throws JAXBException {
73-
BookWithParent bookWithParent = new BookWithParent();
74-
bookWithParent.setTitle(name);
75-
bookWithParent.setIBAN(iban);
76-
JAXBContext context = JAXBContext.newInstance(bookWithParent.getClass());
77-
Marshaller marshaller = context.createMarshaller();
78-
StringWriter sw = new StringWriter();
79-
marshaller.marshal(bookWithParent, sw);
80-
return sw.toString();
81-
}
82-
8368
}
Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
11
package io.quarkus.it.jaxb;
22

3-
import static io.restassured.RestAssured.given;
4-
import static org.hamcrest.Matchers.is;
5-
6-
import org.junit.jupiter.api.Test;
7-
83
import io.quarkus.test.junit.QuarkusIntegrationTest;
94

105
@QuarkusIntegrationTest
116
public class JaxbIT extends JaxbTest {
12-
//We have to test native executable of Jaxb
13-
@Test
14-
public void bookWithParent() {
15-
given().when()
16-
.param("name", "Foundation")
17-
.param("iban", "4242")
18-
.get("/jaxb/bookwithparent")
19-
.then()
20-
.statusCode(200)
21-
.body(is(
22-
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><bookWithParent><IBAN>4242</IBAN><title>Foundation</title></bookWithParent>"));
23-
}
7+
248
}

0 commit comments

Comments
 (0)