Skip to content

Commit 5e9a968

Browse files
committed
Completely remove JdkVersion check from Jaxb2Marshaller
Issue: SPR-13312
1 parent acb44f9 commit 5e9a968

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -576,29 +576,22 @@ public boolean supports(Class<?> clazz) {
576576
}
577577

578578
@Override
579-
@SuppressWarnings("deprecation")
580579
public boolean supports(Type genericType) {
581580
if (genericType instanceof ParameterizedType) {
582581
ParameterizedType parameterizedType = (ParameterizedType) genericType;
583582
if (JAXBElement.class == parameterizedType.getRawType() &&
584583
parameterizedType.getActualTypeArguments().length == 1) {
585-
boolean isJdk6 = (org.springframework.core.JdkVersion.getMajorJavaVersion() <= org.springframework.core.JdkVersion.JAVA_16);
586-
boolean isJdk7 = (org.springframework.core.JdkVersion.getMajorJavaVersion() >= org.springframework.core.JdkVersion.JAVA_17);
587584
Type typeArgument = parameterizedType.getActualTypeArguments()[0];
588585
if (typeArgument instanceof Class) {
589586
Class<?> classArgument = (Class<?>) typeArgument;
590-
if (isJdk7 && classArgument.isArray()) {
591-
return (classArgument.getComponentType() == Byte.TYPE);
592-
}
593-
else {
594-
return (isPrimitiveWrapper(classArgument) || isStandardClass(classArgument) ||
595-
supportsInternal(classArgument, false));
596-
}
587+
return (((classArgument.isArray() && Byte.TYPE == classArgument.getComponentType())) ||
588+
isPrimitiveWrapper(classArgument) || isStandardClass(classArgument) ||
589+
supportsInternal(classArgument, false));
597590
}
598-
else if (isJdk6 && typeArgument instanceof GenericArrayType) {
599-
// see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5041784
591+
else if (typeArgument instanceof GenericArrayType) {
592+
// Only on JDK 6 - see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5041784
600593
GenericArrayType arrayType = (GenericArrayType) typeArgument;
601-
return (arrayType.getGenericComponentType() == Byte.TYPE);
594+
return (Byte.TYPE == arrayType.getGenericComponentType());
602595
}
603596
}
604597
}
@@ -634,21 +627,21 @@ else if (!ObjectUtils.isEmpty(this.classesToBeBound)) {
634627
* Compare section 8.5.1 of the JAXB2 spec.
635628
*/
636629
private boolean isPrimitiveWrapper(Class<?> clazz) {
637-
return Boolean.class == clazz ||
630+
return (Boolean.class == clazz ||
638631
Byte.class == clazz ||
639632
Short.class == clazz ||
640633
Integer.class == clazz ||
641634
Long.class == clazz ||
642635
Float.class == clazz ||
643-
Double.class == clazz;
636+
Double.class == clazz);
644637
}
645638

646639
/**
647640
* Checks whether the given type is a standard class.
648641
* Compare section 8.5.2 of the JAXB2 spec.
649642
*/
650643
private boolean isStandardClass(Class<?> clazz) {
651-
return String.class == clazz ||
644+
return (String.class == clazz ||
652645
BigInteger.class.isAssignableFrom(clazz) ||
653646
BigDecimal.class.isAssignableFrom(clazz) ||
654647
Calendar.class.isAssignableFrom(clazz) ||
@@ -661,10 +654,11 @@ private boolean isStandardClass(Class<?> clazz) {
661654
DataHandler.class == clazz ||
662655
// Source and subclasses should be supported according to the JAXB2 spec, but aren't in the RI
663656
// Source.class.isAssignableFrom(clazz) ||
664-
UUID.class == clazz;
657+
UUID.class == clazz);
665658

666659
}
667660

661+
668662
// Marshalling
669663

670664
@Override

0 commit comments

Comments
 (0)