Skip to content

Workaround for #543, test bounds when doing dodgy generic type inferencing #544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ protected void _resolveBindings(Type t)
}
_addPlaceholder(name); // to prevent infinite loops

if (typeParams != null) {
if (typeParams != null && typeParams.length > i) {
// NB: due to JACKSON-543 typeParams might be totally unrelated;
// but for now we assume they are the same, with just a check to avoid NPE
_bindings.put(name, typeParams[i]);
} else {
_bindings.put(name, _typeFactory._constructType(varType, this));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ static class ContainerWithField<T extends Animal> {
public ContainerWithField(T a) { animal = a; }
}

static class ContainerWithTwoAnimals<U extends Animal,V extends Animal> extends ContainerWithField<U> {
public V otherAnimal;

public ContainerWithTwoAnimals(U a1, V a2) {
super(a1);
otherAnimal = a2;
}
}

static class WrappedContainerWithField {
public ContainerWithField<?> animalContainer;
}

// Beans for [JACKSON-387], [JACKSON-430]

@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@classAttr1")
Expand Down Expand Up @@ -201,4 +214,13 @@ public void testJackson430() throws Exception
assertNotNull(mc2.params);
assertEquals(1, mc2.params.size());
}

public void testValueWithMoreGenericParameters() throws Exception
{
WrappedContainerWithField wrappedContainerWithField = new WrappedContainerWithField();
wrappedContainerWithField.animalContainer = new ContainerWithTwoAnimals<Dog,Dog>(new Dog("d1",1), new Dog("d2",2));
new ObjectMapper().writeValueAsString(wrappedContainerWithField);
// line above throws exception due to JACKSON-543
}

}