Skip to content

Commit

Permalink
Comment out one failing test wrt #921: was assuming wrong things abou…
Browse files Browse the repository at this point in the history
…t static methods, type variables
  • Loading branch information
cowtowncoder committed Sep 6, 2020
1 parent 9ddb776 commit 700b52c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ final class AnnotatedCreatorCollector

private final TypeResolutionContext _typeContext;

// @since 2.11.3
private final TypeFactory _typeFactory;

/**
* @since 2.11
*/
Expand All @@ -40,11 +37,10 @@ final class AnnotatedCreatorCollector

private AnnotatedConstructor _defaultConstructor;

AnnotatedCreatorCollector(AnnotationIntrospector intr, TypeFactory tf,
AnnotatedCreatorCollector(AnnotationIntrospector intr,
TypeResolutionContext tc, boolean collectAnnotations)
{
super(intr);
_typeFactory = tf;
_typeContext = tc;
_collectAnnotations = collectAnnotations;
}
Expand All @@ -60,18 +56,18 @@ public static Creators collectCreators(AnnotationIntrospector intr,
&& !ClassUtil.isJDKClass(type.getRawClass());

// Constructor also always members of resolved class, parent == resolution context
return new AnnotatedCreatorCollector(intr, typeFactory, tc, checkClassAnnotations)
.collect(type, primaryMixIn);
return new AnnotatedCreatorCollector(intr, tc, checkClassAnnotations)
.collect(typeFactory, type, primaryMixIn);
}

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

List<AnnotatedConstructor> constructors = _findPotentialConstructors(type, primaryMixIn);
List<AnnotatedMethod> factories = _findPotentialFactories(type, primaryMixIn);
List<AnnotatedMethod> factories = _findPotentialFactories(typeFactory, type, primaryMixIn);

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

private List<AnnotatedMethod> _findPotentialFactories(JavaType type, Class<?> primaryMixIn)
private List<AnnotatedMethod> _findPotentialFactories(TypeFactory typeFactory,
JavaType type, Class<?> primaryMixIn)
{
List<Method> candidates = null;

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

int factoryCount = candidates.size();
List<AnnotatedMethod> result = new ArrayList<>(factoryCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public MyGenericPOJO<T> build() {
}
}

// 05-Sep-2020, tatu: This is not correct and cannot be made to work --
// assumption is that static method binding `T` would somehow refer to
// class type parameter `T`: this is not true.
/*
public static class MyGenericPOJOWithCreator<T> {
List<T> data;
Expand Down Expand Up @@ -86,6 +90,7 @@ public MyGenericPOJOWithCreator<T> build() {
}
}
}
*/

public void testWithBuilderInferringBindings() throws Exception {
final ObjectMapper mapper = jsonMapperBuilder()
Expand Down Expand Up @@ -113,6 +118,8 @@ public void testWithBuilderWithoutInferringBindings() throws Exception {
assertEquals(LinkedHashMap.class, ob.getClass());
}

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

0 comments on commit 700b52c

Please sign in to comment.