avoid NPE for classes in default package
@@ -266,7 +266,9 @@ final class Utils {
adapter = f.getType().getAnnotation(XmlJavaTypeAdapter.class);
}
if (adapter == null) {
- XmlJavaTypeAdapters adapters = f.getDeclaringClass().getPackage().getAnnotation(XmlJavaTypeAdapters.class);
+ Package packageDeclaration = f.getDeclaringClass().getPackage();
+ if (packageDeclaration != null) {
+ XmlJavaTypeAdapters adapters = packageDeclaration.getAnnotation(XmlJavaTypeAdapters.class);
if (adapters != null) {
for (XmlJavaTypeAdapter candidate : adapters.value()) {
if (candidate != null && candidate.type().equals(f.getType())) {
@@ -276,6 +278,7 @@ final class Utils {
}
}
}
+ }
return adapter;
}
