Skip to content

Commit

Permalink
fix: Adapt JAXBRuntimeHints to the behavior change in Spring 6.0.13 (a…
Browse files Browse the repository at this point in the history
…pache#984)

## Motivation

Since Spring 6.0.13 and the fix for spring-projects/spring-framework#31224, the member category `INVOKE_DECLARED_METHODS` no longer includes public methods so the code needs to be adapted to this behavior change.

## Modifications:

* Register also the member category `INVOKE_PUBLIC_METHODS` when `INVOKE_DECLARED_METHODS` is registered
  • Loading branch information
essobedo committed Oct 23, 2023
1 parent 9285f06 commit ba22da8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,11 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
}
applyIfMatch(c, XmlJavaTypeAdapter.class, XmlJavaTypeAdapter::value,
type -> hints.reflection().registerType(type, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS,
MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS));
MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.INVOKE_PUBLIC_METHODS,
MemberCategory.DECLARED_FIELDS));
hints.reflection().registerType(c, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS,
MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS);
MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.INVOKE_PUBLIC_METHODS,
MemberCategory.DECLARED_FIELDS);
}
boolean classDetected = false;
for (String className : getClassesFromIndexes(classLoader)) {
Expand All @@ -217,15 +219,16 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS);
for (Class<?> c : JAXB_ANNOTATIONS) {
hints.reflection().registerType(c, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS,
MemberCategory.INVOKE_DECLARED_METHODS);
MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.INVOKE_PUBLIC_METHODS);
}
hints.proxies().registerJdkProxy(TypeReference.of(XmlSeeAlso.class), TypeReference.of("org.glassfish.jaxb.core.v2.model.annotation.Locatable"));
for (String className : NATIVE_PROXY_DEFINITIONS) {
hints.proxies().registerJdkProxy(TypeReference.of(className));
}
for (String className : JAXB_RUNTIME_CLASSES) {
hints.reflection().registerTypeIfPresent(classLoader, className,
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS,
MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.INVOKE_PUBLIC_METHODS);
}
// Register the JAXB resource bundles
hints.reflection().registerTypeIfPresent(classLoader, "jakarta.xml.bind.Messages");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.camel.xml.jaxb.springboot;

import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlTransient;
Expand Down

0 comments on commit ba22da8

Please sign in to comment.