1
1
package com .fasterxml .jackson .module .mrbean ;
2
2
3
3
import java .lang .reflect .Modifier ;
4
- import java .util .*;
5
4
6
5
import com .fasterxml .jackson .core .Version ;
7
6
import com .fasterxml .jackson .core .Versioned ;
@@ -94,16 +93,15 @@ protected static int collectDefaults() {
94
93
protected String _defaultPackage = DEFAULT_PACKAGE_FOR_GENERATED ;
95
94
96
95
/*
97
- /**********************************************************
96
+ /**********************************************************************
98
97
/* Construction, configuration
99
- /**********************************************************
98
+ /**********************************************************************
100
99
*/
101
100
102
101
public AbstractTypeMaterializer () {
103
102
this (null );
104
103
}
105
104
106
-
107
105
/**
108
106
* @param parentClassLoader Class loader to use for generated classes; if
109
107
* null, will use class loader that loaded materializer itself.
@@ -168,11 +166,11 @@ public void setDefaultPackage(String defPkg)
168
166
}
169
167
_defaultPackage = defPkg ;
170
168
}
171
-
169
+
172
170
/*
173
- /**********************************************************
171
+ /**********************************************************************
174
172
/* Public API
175
- /**********************************************************
173
+ /**********************************************************************
176
174
*/
177
175
178
176
/**
@@ -198,29 +196,6 @@ public JavaType resolveAbstractType(DeserializationConfig config, BeanDescriptio
198
196
}
199
197
return config .constructType (materializedType );
200
198
}
201
-
202
- /**
203
- * Older variant of {@link #resolveAbstractType(DeserializationConfig, BeanDescription)},
204
- * obsoleted in 2.7. Kept around in 2.7 for backwards compatibility.
205
- *<p>
206
- * TODO: remove from 2.9
207
- */
208
- @ Override
209
- @ Deprecated
210
- public JavaType resolveAbstractType (DeserializationConfig config , JavaType type )
211
- {
212
- if (!_suitableType (type )) {
213
- return null ;
214
- }
215
- Class <?> materializedType ;
216
- if (type .hasGenericTypes ()) {
217
- materializedType = materializeGenericType (config , type );
218
- } else {
219
- materializedType = materializeRawType (config ,
220
- AnnotatedClassResolver .resolve (config , type , config ));
221
- }
222
- return config .constructType (materializedType );
223
- }
224
199
225
200
/**
226
201
* @since 2.4
@@ -267,8 +242,27 @@ protected Class<?> _materializeRawType(MapperConfig<?> config, AnnotatedClass ty
267
242
protected Class <?> _loadAndResolve (String className , byte [] bytecode , Class <?> rawType ) {
268
243
return _classLoader .loadAndResolve (className , bytecode , rawType );
269
244
}
270
-
271
- // private until 2.9.9
245
+
246
+ /**
247
+ * Overridable helper method called to check if given non-concrete type
248
+ * should be materialized.
249
+ *<p>
250
+ * Default implementation will blocks all
251
+ *<ul>
252
+ * <li>primitive types</li>
253
+ * <li>{@code Enums}</li>
254
+ * <li>Container types (Collections, Maps; as per Jackson "container type")</li>
255
+ * <li>Reference types (Jackson definition</li>
256
+ *</ul>
257
+ *<p>
258
+ * Jackson 2.12 and earlier enumerated a small set of other types under
259
+ * {@link java.lang} and {@link java.util}: 2.13 and later simply block
260
+ * all types in {@code java.*}.
261
+ *
262
+ * @param type Type that we are asked to materialize
263
+ *
264
+ * @return True if materialization should proceed; {@code false} if not.
265
+ */
272
266
protected boolean _suitableType (JavaType type )
273
267
{
274
268
// Future plans may include calling of this method for all kinds of abstract types.
@@ -278,16 +272,21 @@ protected boolean _suitableType(JavaType type)
278
272
|| type .isEnumType () || type .isPrimitive ()) {
279
273
return false ;
280
274
}
281
- Class <?> cls = type .getRawClass ();
275
+ final Class <?> cls = type .getRawClass ();
276
+
277
+ // In Jackson 2.12 we had:
278
+ /*
282
279
if ((cls == Number.class)
283
280
// 22-Jun-2016, tatu: As per [#12], avoid these too
284
281
|| (cls == Date.class) || (cls == Calendar.class)
285
282
|| (cls == CharSequence.class) || (cls == Iterable.class) || (cls == Iterator.class)
286
283
// 06-Feb-2019, tatu: [modules-base#74] and:
287
284
|| (cls == java.io.Serializable.class)
288
- // 23-Apr-2021, tatu: [modules-base#132] minimal patch
289
- || (cls == java .util .TimeZone .class )
290
- ) {
285
+ || (cls == java.util.TimeZone.class)) {
286
+ ) {
287
+ */
288
+ // 23-Apr-2021, tatu: Jackson 2.13, as per [modules-base#132], do this:
289
+ if (cls .getName ().startsWith ("java." )) {
291
290
return false ;
292
291
}
293
292
@@ -303,9 +302,9 @@ protected boolean _suitableType(JavaType type)
303
302
}
304
303
305
304
/*
306
- /**********************************************************
305
+ /**********************************************************************
307
306
/* Helper classes
308
- /**********************************************************
307
+ /**********************************************************************
309
308
*/
310
309
311
310
/**
@@ -331,7 +330,7 @@ public Class<?> loadAndResolve(String className, byte[] byteCode, Class<?> targe
331
330
if (old != null && targetClass .isAssignableFrom (old )) {
332
331
return old ;
333
332
}
334
-
333
+
335
334
Class <?> impl ;
336
335
try {
337
336
impl = defineClass (className , byteCode , 0 , byteCode .length );
0 commit comments