Skip to content

Commit 2a2ee41

Browse files
committed
Update release notes wrt #3445; improve TypeFactory Javadocs /cc @kostislav
1 parent 7be07c9 commit 2a2ee41

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

release-notes/CREDITS-2.x

+4
Original file line numberDiff line numberDiff line change
@@ -1445,3 +1445,7 @@ Gary Morgan (morganga@github)
14451445
* Contributed #3419: Improve performance of `UnresolvedForwardReference` for
14461446
forward reference resolution
14471447
(2.14.0)
1448+
1449+
Jan Judas (kostislav@github)
1450+
* Contributed #3445: Do not strip generic type from `Class<C>` when resolving `JavaType`
1451+
(2.14.0)

release-notes/VERSION-2.x

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Project: jackson-databind
1414
(contributed by Gary M)
1515
#3421: Implement `JsonNodeFeature.READ_NULL_PROPERTIES` to allow skipping of
1616
JSON `null` values on reading
17+
#3445: Do not strip generic type from `Class<C>` when resolving `JavaType`
18+
(contributed by Jan J)
1719

1820
2.13.3 (not yet released)
1921

src/main/java/com/fasterxml/jackson/databind/type/TypeFactory.java

+27-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,33 @@
3131
*<pre>
3232
* JavaType stringCollection = mapper.getTypeFactory().constructCollectionType(List.class, String.class);
3333
*</pre>
34+
*<p>
35+
* Note on optimizations: generic type parameters are resolved for all types, with following
36+
* exceptions:
37+
*<ul>
38+
* <li>For optimization purposes, type resolution is skipped for following commonly seen
39+
* types that do have type parameters, but ones that are rarely needed:
40+
* <ul>
41+
* <li>{@link java.lang.Enum}: Self-referential type reference is simply dropped and
42+
* Class is exposed as a simple, non-parameterized {@link SimpleType}
43+
* </li>
44+
* <li>{@link java.lang.Comparable}: Type parameter is simply dropped and and
45+
* interface is exposed as a simple, non-parameterized {@link SimpleType}
46+
* </li>
47+
* <li>Up until Jackson 2.13, {@link java.lang.Class} type parameter was dropped; resolution
48+
* was added back in Jackson 2.14.
49+
* </li>
50+
* </ul>
51+
* </li>
52+
* <li>For {@link java.util.Collection} subtypes, resolved type is ALWAYS the parameter for
53+
* {link java.util.Collection} and not that of actually resolved subtype.
54+
* This is usually (but not always) same parameter.
55+
* </li>
56+
* <li>For {@link java.util.Map} subtypes, resolved type is ALWAYS the parameter for
57+
* {link java.util.Map} and not that of actually resolved subtype.
58+
* These are usually (but not always) same parameters.
59+
* </li>
60+
*</ul>
3461
*/
3562
@SuppressWarnings({"rawtypes" })
3663
public class TypeFactory // note: was final in 2.9, removed from 2.10
@@ -63,7 +90,6 @@ public class TypeFactory // note: was final in 2.9, removed from 2.10
6390
private final static Class<?> CLS_OBJECT = Object.class;
6491

6592
private final static Class<?> CLS_COMPARABLE = Comparable.class;
66-
private final static Class<?> CLS_CLASS = Class.class;
6793
private final static Class<?> CLS_ENUM = Enum.class;
6894
private final static Class<?> CLS_JSON_NODE = JsonNode.class; // since 2.10
6995

0 commit comments

Comments
 (0)