• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.fasterxml.jackson.databind.jsontype;
2 
3 import java.io.Serializable;
4 import java.util.ArrayList;
5 import java.util.List;
6 
7 import com.fasterxml.jackson.databind.*;
8 
9 // [databind#2331]
10 public class GenericNestedType2331Test extends BaseMapTest
11 {
12     static class SuperNode<T> { }
13     static class SuperTestClass { }
14 
15     @SuppressWarnings("serial")
16     static class Node<T extends SuperTestClass & Cloneable> extends SuperNode<Node<T>> implements Serializable {
17 
18         public List<Node<T>> children;
19 
Node()20         public Node() {
21             children = new ArrayList<Node<T>>();
22         }
23 
24         /**
25          * The Wildcard here seems to be the Issue.
26          * If we remove this full getter, everything is working as expected.
27          */
getChildren()28         public List<? extends SuperNode<Node<T>>> getChildren() {
29             return children;
30         }
31     }
32 
33     @SuppressWarnings({ "rawtypes", "unchecked" })
testGeneric2331()34     public void testGeneric2331() throws Exception {
35         Node root = new Node();
36         root.children.add(new Node());
37 
38         String json = newJsonMapper().writeValueAsString(root);
39         assertNotNull(json);
40     }
41 }
42