From 2d656a1789d28877aae0682a956e16eb368d20c8 Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Mon, 8 Nov 2021 18:20:39 +0100 Subject: [PATCH 1/4] Put module-info.class into Multi-Release JAR folder Uses ModiTect to place module-info.class under Multi-Release JAR folder `META-INF/versions/9`. --- gson/pom.xml | 50 +++++++++-------- .../gson/functional/TreeTypeAdaptersTest.java | 7 +-- .../gson/internal/LinkedTreeMapTest.java | 1 - pom.xml | 55 ++++++++++--------- .../gson/protobuf/ProtoTypeAdapter.java | 9 ++- 5 files changed, 62 insertions(+), 60 deletions(-) diff --git a/gson/pom.xml b/gson/pom.xml index 5357f2c556..4c14d05660 100644 --- a/gson/pom.xml +++ b/gson/pom.xml @@ -37,43 +37,48 @@ default-compile - - - 9 - - 9 - - - - base-compile - - compile - + module-info.java - - - [1.5,9) - - 1.6 - 1.6 - + org.apache.maven.plugins maven-javadoc-plugin com.google.gson.internal:com.google.gson.internal.bind - - https://docs.oracle.com/javase/6/docs/api/ - + + + + org.moditect + moditect-maven-plugin + 1.0.0.RC2 + + + add-module-info + package + + add-module-info + + + 9 + + ${project.build.sourceDirectory}/module-info.java + + + + + biz.aQute.bnd bnd-maven-plugin @@ -91,6 +96,7 @@ maven-jar-plugin + ${project.build.outputDirectory}/META-INF/MANIFEST.MF diff --git a/gson/src/test/java/com/google/gson/functional/TreeTypeAdaptersTest.java b/gson/src/test/java/com/google/gson/functional/TreeTypeAdaptersTest.java index dd412ea131..afcc4bccda 100644 --- a/gson/src/test/java/com/google/gson/functional/TreeTypeAdaptersTest.java +++ b/gson/src/test/java/com/google/gson/functional/TreeTypeAdaptersTest.java @@ -57,7 +57,7 @@ protected void setUp() { .registerTypeAdapter(Id.class, new IdTreeTypeAdapter()) .create(); course = new Course(COURSE_ID, 4, - new Assignment(null, null), createList(STUDENT1, STUDENT2)); + new Assignment(null, null), Arrays.asList(STUDENT1, STUDENT2)); } public void testSerializeId() { @@ -171,9 +171,4 @@ public Assignment(Id> id, T data) { private static class HistoryCourse { int numClasses; } - - @SafeVarargs - private static List createList(T ...items) { - return Arrays.asList(items); - } } diff --git a/gson/src/test/java/com/google/gson/internal/LinkedTreeMapTest.java b/gson/src/test/java/com/google/gson/internal/LinkedTreeMapTest.java index 68220cf631..d9a1191511 100644 --- a/gson/src/test/java/com/google/gson/internal/LinkedTreeMapTest.java +++ b/gson/src/test/java/com/google/gson/internal/LinkedTreeMapTest.java @@ -160,7 +160,6 @@ public void testJavaSerialization() throws IOException, ClassNotFoundException { assertEquals(Collections.singletonMap("a", 1), deserialized); } - @SafeVarargs private void assertIterationOrder(Iterable actual, T... expected) { ArrayList actualList = new ArrayList(); for (T t : actual) { diff --git a/pom.xml b/pom.xml index 5b2a3e1ff3..e4ceb2d65c 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ UTF-8 - 1.6 + 6 @@ -68,23 +68,45 @@ org.apache.maven.plugins maven-compiler-plugin 3.8.1 + + ${javaVersion} + + + + [9,11] + + org.apache.maven.plugins maven-javadoc-plugin 3.3.1 + + + [11,) + + none + + false + + https://docs.oracle.com/en/java/javase/11/docs/api/ + + + false + org.apache.maven.plugins maven-jar-plugin 3.2.0 - - org.apache.felix - maven-bundle-plugin - 5.1.2 - true - @@ -110,23 +132,4 @@ - - - doclint-java8-disable - - [1.8,) - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - -Xdoclint:none - - - - - - diff --git a/proto/src/main/java/com/google/gson/protobuf/ProtoTypeAdapter.java b/proto/src/main/java/com/google/gson/protobuf/ProtoTypeAdapter.java index c378685c8f..ac4e0191fe 100644 --- a/proto/src/main/java/com/google/gson/protobuf/ProtoTypeAdapter.java +++ b/proto/src/main/java/com/google/gson/protobuf/ProtoTypeAdapter.java @@ -37,7 +37,6 @@ import com.google.protobuf.DynamicMessage; import com.google.protobuf.Extension; import com.google.protobuf.Message; - import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -192,7 +191,7 @@ public static Builder newBuilder() { private static final com.google.protobuf.Descriptors.FieldDescriptor.Type ENUM_TYPE = com.google.protobuf.Descriptors.FieldDescriptor.Type.ENUM; - private static final ConcurrentMap, Method>> mapOfMapOfMethods = + private static final ConcurrentMap, Method>> mapOfMapOfMethods = new MapMaker().makeMap(); private final EnumSerialization enumSerialization; @@ -309,7 +308,7 @@ public Message deserialize(JsonElement json, Type typeOfT, } } } - return (Message) protoBuilder.build(); + return protoBuilder.build(); } catch (SecurityException e) { throw new JsonParseException(e); } catch (NoSuchMethodException e) { @@ -397,10 +396,10 @@ private EnumValueDescriptor findValueByNameAndExtension(EnumDescriptor desc, private static Method getCachedMethod(Class clazz, String methodName, Class... methodParamTypes) throws NoSuchMethodException { - Map, Method> mapOfMethods = mapOfMapOfMethods.get(methodName); + ConcurrentMap, Method> mapOfMethods = mapOfMapOfMethods.get(methodName); if (mapOfMethods == null) { mapOfMethods = new MapMaker().makeMap(); - Map, Method> previous = + ConcurrentMap, Method> previous = mapOfMapOfMethods.putIfAbsent(methodName, mapOfMethods); mapOfMethods = previous == null ? mapOfMethods : previous; } From 14972e0c1df7e3abb2f596fa4a33de07a583fa3f Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Sat, 1 Jan 2022 19:05:56 +0100 Subject: [PATCH 2/4] Adjust pom.xml to drop support for Java 6 --- pom.xml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 3881e57a09..5c0626ccdb 100644 --- a/pom.xml +++ b/pom.xml @@ -71,11 +71,7 @@ ${javaVersion} - - - [9,11] + [11,) From fc73dd526ba5c9ec48187f60fb9b0e9d06ba94da Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Sat, 1 Jan 2022 19:30:36 +0100 Subject: [PATCH 3/4] Change doclint setting All Javadoc errors have been solved previously; doclint can now be enabled without causing build failures. --- pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5c0626ccdb..0e888b64f2 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,8 @@ [11,) - none + + all,-missing false From c2b2aa8978216bf8570c459dc09df289cc694da2 Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Sat, 1 Jan 2022 19:31:24 +0100 Subject: [PATCH 4/4] Improve README Java requirements --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 351fed1bf8..a9ec0423f8 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Maven: ![Build Status](https://github.com/google/gson/actions/workflows/build.yml/badge.svg) ### Requirements -#### Java version +#### Minimum Java version - Gson 2.9.0 and newer: Java 7 - Gson 2.8.9 and older: Java 6