Skip to content

Commit

Permalink
Revert "Fixing Jaxb unmarshalling error with native compilation"
Browse files Browse the repository at this point in the history
This reverts commit 24b321e.

(cherry picked from commit ed722a1)
  • Loading branch information
gsmet committed Jan 18, 2024
1 parent f255c39 commit 36eac3c
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBundleBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageSystemPropertyBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyIgnoreWarningBuildItem;
import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem;
Expand Down Expand Up @@ -187,7 +186,6 @@ void processAnnotationsAndIndexFiles(
BuildProducer<NativeImageProxyDefinitionBuildItem> proxyDefinitions,
CombinedIndexBuildItem combinedIndexBuildItem,
List<JaxbFileRootBuildItem> fileRoots,
BuildProducer<ReflectiveHierarchyBuildItem> reflectiveHierarchies,
BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
BuildProducer<NativeImageResourceBuildItem> resource,
BuildProducer<NativeImageResourceBundleBuildItem> resourceBundle,
Expand All @@ -204,11 +202,10 @@ void processAnnotationsAndIndexFiles(
for (DotName jaxbRootAnnotation : JAXB_ROOT_ANNOTATIONS) {
for (AnnotationInstance jaxbRootAnnotationInstance : index
.getAnnotations(jaxbRootAnnotation)) {
if (jaxbRootAnnotationInstance.target().kind() == Kind.CLASS
&& !JAXB_ANNOTATIONS.contains(jaxbRootAnnotationInstance.target().asClass().getClass())) {
DotName targetClass = jaxbRootAnnotationInstance.target().asClass().name();
addReflectiveHierarchyClass(targetClass, reflectiveHierarchies, index);
classesToBeBound.add(targetClass.toString());
if (jaxbRootAnnotationInstance.target().kind() == Kind.CLASS) {
String className = jaxbRootAnnotationInstance.target().asClass().name().toString();
reflectiveClass.produce(ReflectiveClassBuildItem.builder(className).methods().fields().build());
classesToBeBound.add(className);
jaxbRootAnnotationsDetected = true;
}
}
Expand Down Expand Up @@ -415,17 +412,6 @@ public static Stream<Path> safeWalk(Path p) {
}
}

private void addReflectiveHierarchyClass(DotName className,
BuildProducer<ReflectiveHierarchyBuildItem> reflectiveHierarchy,
IndexView index) {
Type jandexType = Type.create(className, Type.Kind.CLASS);
reflectiveHierarchy.produce(new ReflectiveHierarchyBuildItem.Builder()
.type(jandexType)
.index(index)
.source(getClass().getSimpleName() + " > " + jandexType.name().toString())
.build());
}

private void addReflectiveClass(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, boolean methods, boolean fields,
String... className) {
reflectiveClass.produce(new ReflectiveClassBuildItem(methods, fields, className));
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,4 @@ public io.quarkus.it.jaxb.Response seeAlso() {
return response;
}

//Test for Jaxb with parent class field
@Path("/bookwithparent")
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getBookWithParent(@QueryParam("name") String name, @QueryParam("iban") String iban) throws JAXBException {
BookWithParent bookWithParent = new BookWithParent();
bookWithParent.setTitle(name);
bookWithParent.setIBAN(iban);
JAXBContext context = JAXBContext.newInstance(bookWithParent.getClass());
Marshaller marshaller = context.createMarshaller();
StringWriter sw = new StringWriter();
marshaller.marshal(bookWithParent, sw);
return sw.toString();
}

}
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
package io.quarkus.it.jaxb;

import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.is;

import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.QuarkusIntegrationTest;

@QuarkusIntegrationTest
public class JaxbIT extends JaxbTest {
//We have to test native executable of Jaxb
@Test
public void bookWithParent() {
given().when()
.param("name", "Foundation")
.param("iban", "4242")
.get("/jaxb/bookwithparent")
.then()
.statusCode(200)
.body(is(
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><bookWithParent><IBAN>4242</IBAN><title>Foundation</title></bookWithParent>"));
}

}

0 comments on commit 36eac3c

Please sign in to comment.