@@ -92,6 +92,20 @@ public AtomicWrapper() { }
92
92
public AtomicWrapper (int x ) { value = new ImplX (x ); }
93
93
}
94
94
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
+
95
109
// [databind#1125]
96
110
97
111
static class Issue1125Wrapper {
@@ -124,14 +138,14 @@ public Impl1125(int a0, int b0, int c0) {
124
138
}
125
139
126
140
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
+ }
135
149
}
136
150
137
151
/*
@@ -299,6 +313,20 @@ public void testViaAtomic() throws Exception {
299
313
assertEquals (3 , ((ImplX ) output .value ).x );
300
314
}
301
315
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
+
302
330
// [databind#1125]: properties from base class too
303
331
304
332
public void testIssue1125NonDefault () throws Exception
0 commit comments