Skip to content

Commit

Permalink
merge with Gson 2.8.5
Browse files Browse the repository at this point in the history
  • Loading branch information
amogilev committed Feb 4, 2019
2 parents 42c9fc1 + f649e05 commit b7b3fe0
Show file tree
Hide file tree
Showing 50 changed files with 937 additions and 438 deletions.
17 changes: 17 additions & 0 deletions gson/pom.xml
Expand Up @@ -58,6 +58,23 @@
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<id>filtering-java-templates</id>
<goals>
<goal>filter-sources</goal>
</goals>
<configuration>
<sourceDirectory>${basedir}/src/main/java-templates</sourceDirectory>
<outputDirectory>${project.build.directory}/generated-sources/java-templates</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<developers>
Expand Down
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2018 The Gson authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.gson.internal;

/**
* Build configuration for Gson. This file is automatically populated by
* templating-maven-plugin and .java/.class files are generated for use in Gson.
*
* @author Inderjeet Singh
*/
public final class GsonBuildConfig {
// Based on https://stackoverflow.com/questions/2469922/generate-a-version-java-file-in-maven

/** This field is automatically populated by Maven when a build is triggered */
public static final String VERSION = "YaGson ${project.version}";

private GsonBuildConfig() { }
}
13 changes: 11 additions & 2 deletions gson/src/main/java/com/gilecode/yagson/YaGson.java
Expand Up @@ -30,6 +30,7 @@
import java.io.StringWriter;
import java.io.Writer;
import java.lang.reflect.Type;
import java.text.DateFormat;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -95,6 +96,8 @@ public YaGson() {
DEFAULT_JSON_NON_EXECUTABLE,
!TypeInfoPolicy.defaultPolicy().isEnabled(), // disable htmlSafe if types are printed
DEFAULT_PRETTY_PRINT, DEFAULT_LENIENT, DEFAULT_SPECIALIZE_FLOAT_VALUES, LongSerializationPolicy.DEFAULT,
null, DateFormat.DEFAULT, DateFormat.DEFAULT,
Collections.<TypeAdapterFactory>emptyList(), Collections.<TypeAdapterFactory>emptyList(),
Collections.<TypeAdapterFactory>emptyList(),
References.defaultPolicy(), TypeInfoPolicy.defaultPolicy(), NSLambdaPolicy.TO_NULL,
Collections.<ClassLoader>emptyList());
Expand All @@ -104,12 +107,18 @@ protected YaGson(Excluder excluder, FieldNamingStrategy fieldNamingPolicy,
Map<Type, InstanceCreator<?>> instanceCreators, boolean serializeNulls,
boolean complexMapKeySerialization, boolean generateNonExecutableGson, boolean htmlSafe,
boolean prettyPrinting, boolean lenient, boolean serializeSpecialFloatingPointValues,
LongSerializationPolicy longSerializationPolicy, List<TypeAdapterFactory> typeAdapterFactories,
LongSerializationPolicy longSerializationPolicy,
String datePattern, int dateStyle,
int timeStyle, List<TypeAdapterFactory> builderFactories,
List<TypeAdapterFactory> builderHierarchyFactories,
List<TypeAdapterFactory> factoriesToBeAdded,
ReferencesPolicy referencesPolicy, TypeInfoPolicy typeInfoPolicy, NSLambdaPolicy nsLambdaPolicy,
List<ClassLoader> preferredClassLoaders) {
super(excluder, fieldNamingPolicy, instanceCreators, serializeNulls, complexMapKeySerialization,
generateNonExecutableGson, htmlSafe, prettyPrinting, lenient, serializeSpecialFloatingPointValues,
longSerializationPolicy, typeAdapterFactories, referencesPolicy, typeInfoPolicy, nsLambdaPolicy,
longSerializationPolicy, datePattern, dateStyle, timeStyle,
builderFactories, builderHierarchyFactories, factoriesToBeAdded,
referencesPolicy, typeInfoPolicy, nsLambdaPolicy,
preferredClassLoaders);
}

Expand Down
3 changes: 2 additions & 1 deletion gson/src/main/java/com/gilecode/yagson/YaGsonBuilder.java
Expand Up @@ -54,7 +54,8 @@ public YaGson create() {
serializeNulls, complexMapKeySerialization,
generateNonExecutableJson, escapeHtmlChars, prettyPrinting, lenient,
serializeSpecialFloatingPointValues, longSerializationPolicy,
createTypeAdapterFactories(),
datePattern, dateStyle, timeStyle,
createCustomTypeAdapterFactoriesList(), this.hierarchyFactories, factories,
referencesPolicy, typeInfoPolicy, nsLambdaPolicy, preferredClassLoaders);
}

Expand Down
Expand Up @@ -17,7 +17,6 @@

import com.gilecode.yagson.ReadContext;
import com.gilecode.yagson.WriteContext;
import com.gilecode.yagson.reflection.ReflectionAccessUtils;
import com.gilecode.yagson.refs.PathElementProducer;
import com.gilecode.yagson.types.*;
import com.google.gson.Gson;
Expand All @@ -28,6 +27,7 @@
import com.google.gson.internal.Streams;
import com.google.gson.internal.bind.ReflectiveTypeAdapterFactory;
import com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper;
import com.google.gson.internal.reflect.ReflectionAccessor;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
Expand Down Expand Up @@ -94,7 +94,7 @@ public static <T> Map<String, FieldInfo> buildReflectiveFieldsInfo(Gson gson, Cl
// skip duplicate names, get/set only 'latest' versions (closest to the actual class)
continue;
}
ReflectionAccessUtils.getReflectionAccessor().makeAccessible(f);
ReflectionAccessor.getInstance().makeAccessible(f);

Object defaultValue;
try {
Expand Down
Expand Up @@ -17,14 +17,13 @@

import com.gilecode.yagson.ReadContext;
import com.gilecode.yagson.WriteContext;
import com.gilecode.yagson.reflection.ReflectionAccessUtils;
import com.gilecode.yagson.reflection.ReflectionAccessor;
import com.gilecode.yagson.types.NonSerializableLambdaException;
import com.gilecode.yagson.types.TypeUtils;
import com.google.gson.Gson;
import com.google.gson.JsonIOException;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.internal.reflect.ReflectionAccessor;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
Expand All @@ -43,7 +42,7 @@ public class LambdaAdapterFactory implements TypeAdapterFactory {
private static final String SERIALIZED_LAMBDA_CLASS_NAME = "java.lang.invoke.SerializedLambda";
private final Class<?> serializedLambdaClass;
private final boolean enabled;
private final ReflectionAccessor accessor = ReflectionAccessUtils.getReflectionAccessor();
private final ReflectionAccessor accessor = ReflectionAccessor.getInstance();

private class AdaptersHolder {
final TypeAdapter serializedLambdaAdapter;
Expand Down
Expand Up @@ -16,15 +16,14 @@
package com.gilecode.yagson.adapters;

import com.gilecode.yagson.WriteContext;
import com.gilecode.yagson.reflection.ReflectionAccessUtils;
import com.gilecode.yagson.reflection.ReflectionAccessor;
import com.gilecode.yagson.refs.PlaceholderUse;
import com.gilecode.yagson.refs.ReferencePlaceholder;
import com.google.gson.*;
import com.google.gson.internal.$Gson$Types;
import com.google.gson.internal.ConstructorConstructor;
import com.google.gson.internal.bind.JsonAdapterAnnotationTypeAdapterFactory;
import com.google.gson.internal.bind.ReflectiveTypeAdapterFactory;
import com.google.gson.internal.reflect.ReflectionAccessor;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
Expand Down Expand Up @@ -69,7 +68,7 @@ private static class ReflectiveInfoHolder {
static Field threadLocalEntryValueField;

static {
ReflectionAccessor accessor = ReflectionAccessUtils.getReflectionAccessor();
ReflectionAccessor accessor = ReflectionAccessor.getInstance();

try {
threadLocalGetMapMethod = ThreadLocal.class.getDeclaredMethod("getMap", Thread.class);
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Expand Up @@ -15,8 +15,7 @@
*/
package com.gilecode.yagson.types;

import com.gilecode.yagson.reflection.ReflectionAccessUtils;
import com.gilecode.yagson.reflection.ReflectionAccessor;
import com.google.gson.internal.reflect.ReflectionAccessor;

import java.io.IOException;
import java.io.ObjectInputStream;
Expand All @@ -33,7 +32,7 @@
*/
public class SetFromMapPostReadProcessor implements PostReadProcessor {

private static final ReflectionAccessor accessor = ReflectionAccessUtils.getReflectionAccessor();
private static final ReflectionAccessor accessor = ReflectionAccessor.getInstance();

@SuppressWarnings("unchecked")
public void apply(Object instance) {
Expand Down
5 changes: 2 additions & 3 deletions gson/src/main/java/com/gilecode/yagson/types/TypeUtils.java
Expand Up @@ -17,14 +17,13 @@

import com.gilecode.yagson.ReadContext;
import com.gilecode.yagson.WriteContext;
import com.gilecode.yagson.reflection.ReflectionAccessUtils;
import com.gilecode.yagson.reflection.ReflectionAccessor;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.$Gson$Types;
import com.gilecode.yagson.adapters.AdapterUtils;
import com.google.gson.internal.bind.MapTypeAdapterFactory;
import com.google.gson.internal.reflect.ReflectionAccessor;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
Expand Down Expand Up @@ -55,7 +54,7 @@ public class TypeUtils {
primitiveWrappers.put(double.class.getName(), Double.class);
}

private static final ReflectionAccessor accessor = ReflectionAccessUtils.getReflectionAccessor();
private static final ReflectionAccessor accessor = ReflectionAccessor.getInstance();

public static boolean typesDiffer(Type type, Class<?> actualClass) {
if (type instanceof GenericArrayType && actualClass.isArray()) {
Expand Down

0 comments on commit b7b3fe0

Please sign in to comment.