Skip to content

Commit 581de93

Browse files
committed
Fix #1619
1 parent c106f0c commit 581de93

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

release-notes/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ Project: jackson-databind
8585
#1605: Allow serialization of `InetAddress` as simple numeric host address
8686
(requested by Jared J)
8787
#1616: Extraneous type id mapping added for base type itself
88+
#1619: By-pass annotation introspection for array types
8889

8990
2.8.9 (not yet released)
9091

src/main/java/com/fasterxml/jackson/databind/introspect/AnnotatedClassResolver.java

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,48 +63,71 @@ public class AnnotatedClassResolver
6363
public static AnnotatedClass resolve(MapperConfig<?> config, JavaType forType,
6464
MixInResolver r)
6565
{
66+
if (forType.isArrayType() && skippableArray(config, forType.getRawClass())) {
67+
return createArrayType(config, forType.getRawClass());
68+
}
6669
return new AnnotatedClassResolver(config, forType, r).resolveFully();
6770
}
6871

72+
public static AnnotatedClass resolveWithoutSuperTypes(MapperConfig<?> config, Class<?> forType) {
73+
return resolveWithoutSuperTypes(config, forType, config);
74+
}
75+
6976
public static AnnotatedClass resolveWithoutSuperTypes(MapperConfig<?> config, JavaType forType,
7077
MixInResolver r)
7178
{
79+
if (forType.isArrayType() && skippableArray(config, forType.getRawClass())) {
80+
return createArrayType(config, forType.getRawClass());
81+
}
7282
return new AnnotatedClassResolver(config, forType, r).resolveWithoutSuperTypes();
7383
}
7484

75-
public static AnnotatedClass resolveWithoutSuperTypes(MapperConfig<?> config, Class<?> forType) {
76-
return resolveWithoutSuperTypes(config, forType, config);
77-
}
78-
7985
public static AnnotatedClass resolveWithoutSuperTypes(MapperConfig<?> config, Class<?> forType,
8086
MixInResolver r)
8187
{
88+
if (forType.isArray() && skippableArray(config, forType)) {
89+
return createArrayType(config, forType);
90+
}
8291
return new AnnotatedClassResolver(config, forType, r).resolveWithoutSuperTypes();
8392
}
8493

94+
private static boolean skippableArray(MapperConfig<?> config, Class<?> type) {
95+
return (config == null) || (config.findMixInClassFor(type) == null);
96+
97+
}
98+
8599
/**
86-
* Internal helper class used for resolving a small set of "primordial" types for which
100+
* Internal helper method used for resolving a small set of "primordial" types for which
87101
* we do not accept any annotation information or overrides.
88102
*/
89103
static AnnotatedClass createPrimordial(Class<?> raw) {
90-
Annotations noClassAnn = new AnnotationMap();
91104
List<JavaType> superTypes = Collections.emptyList();
92-
return new AnnotatedClass(null, raw, superTypes, null, noClassAnn,
105+
return new AnnotatedClass(null, raw, superTypes, null, NO_ANNOTATIONS,
106+
TypeBindings.emptyBindings(), null, null, null);
107+
}
108+
109+
/**
110+
* Internal helper method used for resolving array types, unless they happen
111+
* to have associated mix-in to apply.
112+
*/
113+
static AnnotatedClass createArrayType(MapperConfig<?> config, Class<?> raw) {
114+
List<JavaType> superTypes = Collections.emptyList();
115+
return new AnnotatedClass(null, raw, superTypes, null, NO_ANNOTATIONS,
93116
TypeBindings.emptyBindings(), null, null, null);
94117
}
95118

96119
AnnotatedClass resolveFully() {
97120
List<JavaType> superTypes = ClassUtil.findSuperTypes(_type, null, false);
98-
Annotations classAnn = resolveClassAnnotations(superTypes);
99-
return new AnnotatedClass(_type, _class, superTypes, _primaryMixin, classAnn, _bindings,
100-
_intr, _mixInResolver, _config.getTypeFactory());
121+
return new AnnotatedClass(_type, _class, superTypes, _primaryMixin,
122+
resolveClassAnnotations(superTypes),
123+
_bindings, _intr, _mixInResolver, _config.getTypeFactory());
101124

102125
}
103126

104127
AnnotatedClass resolveWithoutSuperTypes() {
105128
List<JavaType> superTypes = Collections.<JavaType>emptyList();
106-
Annotations classAnn = resolveClassAnnotations(superTypes);
107-
return new AnnotatedClass(null, _class, superTypes, _primaryMixin, classAnn,
129+
return new AnnotatedClass(null, _class, superTypes, _primaryMixin,
130+
resolveClassAnnotations(superTypes),
108131
_bindings, _intr, _config, _config.getTypeFactory());
109132
}
110133

0 commit comments

Comments
 (0)