@@ -110,6 +110,7 @@ public final class Gson {
110
110
static final boolean DEFAULT_SERIALIZE_NULLS = false ;
111
111
static final boolean DEFAULT_COMPLEX_MAP_KEYS = false ;
112
112
static final boolean DEFAULT_SPECIALIZE_FLOAT_VALUES = false ;
113
+ static final boolean DEFAULT_USE_JDK_UNSAFE = true ;
113
114
114
115
private static final TypeToken <?> NULL_KEY_SURROGATE = TypeToken .get (Object .class );
115
116
private static final String JSON_NON_EXECUTABLE_PREFIX = ")]}'\n " ;
@@ -187,6 +188,7 @@ public Gson() {
187
188
Collections .<Type , InstanceCreator <?>>emptyMap (), DEFAULT_SERIALIZE_NULLS ,
188
189
DEFAULT_COMPLEX_MAP_KEYS , DEFAULT_JSON_NON_EXECUTABLE , DEFAULT_ESCAPE_HTML ,
189
190
DEFAULT_PRETTY_PRINT , DEFAULT_LENIENT , DEFAULT_SPECIALIZE_FLOAT_VALUES ,
191
+ DEFAULT_USE_JDK_UNSAFE ,
190
192
LongSerializationPolicy .DEFAULT , null , DateFormat .DEFAULT , DateFormat .DEFAULT ,
191
193
Collections .<TypeAdapterFactory >emptyList (), Collections .<TypeAdapterFactory >emptyList (),
192
194
Collections .<TypeAdapterFactory >emptyList ());
@@ -196,14 +198,15 @@ public Gson() {
196
198
Map <Type , InstanceCreator <?>> instanceCreators , boolean serializeNulls ,
197
199
boolean complexMapKeySerialization , boolean generateNonExecutableGson , boolean htmlSafe ,
198
200
boolean prettyPrinting , boolean lenient , boolean serializeSpecialFloatingPointValues ,
201
+ boolean useJdkUnsafe ,
199
202
LongSerializationPolicy longSerializationPolicy , String datePattern , int dateStyle ,
200
203
int timeStyle , List <TypeAdapterFactory > builderFactories ,
201
204
List <TypeAdapterFactory > builderHierarchyFactories ,
202
205
List <TypeAdapterFactory > factoriesToBeAdded ) {
203
206
this .excluder = excluder ;
204
207
this .fieldNamingStrategy = fieldNamingStrategy ;
205
208
this .instanceCreators = instanceCreators ;
206
- this .constructorConstructor = new ConstructorConstructor (instanceCreators );
209
+ this .constructorConstructor = new ConstructorConstructor (instanceCreators , useJdkUnsafe );
207
210
this .serializeNulls = serializeNulls ;
208
211
this .complexMapKeySerialization = complexMapKeySerialization ;
209
212
this .generateNonExecutableJson = generateNonExecutableGson ;
0 commit comments