Skip to content

Commit 700b52c

Browse files
committed
Comment out one failing test wrt #921: was assuming wrong things about static methods, type variables
1 parent 9ddb776 commit 700b52c

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

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

+8-11
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ final class AnnotatedCreatorCollector
2828

2929
private final TypeResolutionContext _typeContext;
3030

31-
// @since 2.11.3
32-
private final TypeFactory _typeFactory;
33-
3431
/**
3532
* @since 2.11
3633
*/
@@ -40,11 +37,10 @@ final class AnnotatedCreatorCollector
4037

4138
private AnnotatedConstructor _defaultConstructor;
4239

43-
AnnotatedCreatorCollector(AnnotationIntrospector intr, TypeFactory tf,
40+
AnnotatedCreatorCollector(AnnotationIntrospector intr,
4441
TypeResolutionContext tc, boolean collectAnnotations)
4542
{
4643
super(intr);
47-
_typeFactory = tf;
4844
_typeContext = tc;
4945
_collectAnnotations = collectAnnotations;
5046
}
@@ -60,18 +56,18 @@ public static Creators collectCreators(AnnotationIntrospector intr,
6056
&& !ClassUtil.isJDKClass(type.getRawClass());
6157

6258
// Constructor also always members of resolved class, parent == resolution context
63-
return new AnnotatedCreatorCollector(intr, typeFactory, tc, checkClassAnnotations)
64-
.collect(type, primaryMixIn);
59+
return new AnnotatedCreatorCollector(intr, tc, checkClassAnnotations)
60+
.collect(typeFactory, type, primaryMixIn);
6561
}
6662

67-
Creators collect(JavaType type, Class<?> primaryMixIn)
63+
Creators collect(TypeFactory typeFactory, JavaType type, Class<?> primaryMixIn)
6864
{
6965
// 30-Apr-2016, tatu: [databind#1215]: Actually, while true, this does
7066
// NOT apply to context since sub-class may have type bindings
7167
// TypeResolutionContext typeContext = new TypeResolutionContext.Basic(_typeFactory, _type.getBindings());
7268

7369
List<AnnotatedConstructor> constructors = _findPotentialConstructors(type, primaryMixIn);
74-
List<AnnotatedMethod> factories = _findPotentialFactories(type, primaryMixIn);
70+
List<AnnotatedMethod> factories = _findPotentialFactories(typeFactory, type, primaryMixIn);
7571

7672
/* And then... let's remove all constructors that are deemed
7773
* ignorable after all annotations have been properly collapsed.
@@ -191,7 +187,8 @@ private List<AnnotatedConstructor> _findPotentialConstructors(JavaType type,
191187
return result;
192188
}
193189

194-
private List<AnnotatedMethod> _findPotentialFactories(JavaType type, Class<?> primaryMixIn)
190+
private List<AnnotatedMethod> _findPotentialFactories(TypeFactory typeFactory,
191+
JavaType type, Class<?> primaryMixIn)
195192
{
196193
List<Method> candidates = null;
197194

@@ -216,7 +213,7 @@ private List<AnnotatedMethod> _findPotentialFactories(JavaType type, Class<?> pr
216213
// passing that should not break things, it appears to... Regardless,
217214
// it should not be needed or useful as those bindings are only available
218215
// to non-static members
219-
TypeResolutionContext typeResCtxt = new TypeResolutionContext.Empty(_typeFactory);
216+
TypeResolutionContext typeResCtxt = new TypeResolutionContext.Empty(typeFactory);
220217

221218
int factoryCount = candidates.size();
222219
List<AnnotatedMethod> result = new ArrayList<>(factoryCount);

src/test/java/com/fasterxml/jackson/databind/deser/builder/BuilderWithTypeParametersTest.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ public MyGenericPOJO<T> build() {
5757
}
5858
}
5959

60+
// 05-Sep-2020, tatu: This is not correct and cannot be made to work --
61+
// assumption is that static method binding `T` would somehow refer to
62+
// class type parameter `T`: this is not true.
63+
/*
6064
public static class MyGenericPOJOWithCreator<T> {
6165
List<T> data;
6266
@@ -86,6 +90,7 @@ public MyGenericPOJOWithCreator<T> build() {
8690
}
8791
}
8892
}
93+
*/
8994

9095
public void testWithBuilderInferringBindings() throws Exception {
9196
final ObjectMapper mapper = jsonMapperBuilder()
@@ -113,6 +118,8 @@ public void testWithBuilderWithoutInferringBindings() throws Exception {
113118
assertEquals(LinkedHashMap.class, ob.getClass());
114119
}
115120

121+
// 05-Sep-2020, tatu: see above for reason why this can not work
122+
/*
116123
public void testWithCreator() throws Exception {
117124
final ObjectMapper mapper = new ObjectMapper();
118125
final String json = aposToQuotes("{ 'data': [ { 'x': 'x', 'y': 'y' } ] }");
@@ -124,4 +131,5 @@ public void testWithCreator() throws Exception {
124131
assertNotNull(ob);
125132
assertEquals(MyPOJO.class, ob.getClass());
126133
}
127-
}
134+
*/
135+
}

0 commit comments

Comments
 (0)