@@ -92,6 +92,20 @@ public AtomicWrapper() { }
9292 public AtomicWrapper (int x ) { value = new ImplX (x ); }
9393 }
9494
95+ // Verifying limits on sub-class ids
96+
97+ static class DateWrapper {
98+ @ JsonTypeInfo (use = JsonTypeInfo .Id .CLASS , include = JsonTypeInfo .As .WRAPPER_ARRAY )
99+ public java .util .Date value ;
100+ }
101+
102+ static class TheBomb {
103+ public int a ;
104+ public TheBomb () {
105+ throw new Error ("Ka-boom!" );
106+ }
107+ }
108+
95109 // [databind#1125]
96110
97111 static class Issue1125Wrapper {
@@ -124,14 +138,14 @@ public Impl1125(int a0, int b0, int c0) {
124138 }
125139
126140 static class Default1125 extends Interm1125 {
127- public int def ;
128-
129- Default1125 () { }
130- public Default1125 (int a0 , int b0 , int def0 ) {
131- a = a0 ;
132- b = b0 ;
133- def = def0 ;
134- }
141+ public int def ;
142+
143+ Default1125 () { }
144+ public Default1125 (int a0 , int b0 , int def0 ) {
145+ a = a0 ;
146+ b = b0 ;
147+ def = def0 ;
148+ }
135149 }
136150
137151 /*
@@ -299,6 +313,20 @@ public void testViaAtomic() throws Exception {
299313 assertEquals (3 , ((ImplX ) output .value ).x );
300314 }
301315
316+ // Test to verify that base/impl restriction is applied to polymorphic handling
317+ // even if class name is used as the id
318+ public void testSubclassLimits () throws Exception
319+ {
320+ try {
321+ MAPPER .readValue (aposToQuotes ("{'value':['"
322+ +TheBomb .class .getName ()+"',{'a':13}] }" ), DateWrapper .class );
323+ fail ("Should not pass" );
324+ } catch (JsonMappingException e ) {
325+ verifyException (e , "not subtype of" );
326+ verifyException (e , TheBomb .class .getName ());
327+ }
328+ }
329+
302330 // [databind#1125]: properties from base class too
303331
304332 public void testIssue1125NonDefault () throws Exception
0 commit comments