Change target Java version to 7 (#2043)
* Change target Java version to 7 * Document Gson requirements * Add package-info.java for `stream` package
This commit is contained in:
parent
bc8858a3d9
commit
dc28951fa7
19
README.md
19
README.md
|
@ -34,6 +34,25 @@ Maven:
|
||||||
|
|
||||||
![Build Status](https://github.com/google/gson/actions/workflows/build.yml/badge.svg)
|
![Build Status](https://github.com/google/gson/actions/workflows/build.yml/badge.svg)
|
||||||
|
|
||||||
|
### Requirements
|
||||||
|
#### Java version
|
||||||
|
- Gson 2.9.0 and newer: Java 7
|
||||||
|
- Gson 2.8.9 and older: Java 6
|
||||||
|
|
||||||
|
Despite supporting older Java versions, Gson also provides a JPMS module descriptor (module name `com.google.gson`) for users of Java 9 or newer.
|
||||||
|
|
||||||
|
#### JPMS dependencies (Java 9+)
|
||||||
|
These are the optional Java Platform Module System (JPMS) JDK modules which Gson depends on.
|
||||||
|
This only applies when running Java 9 or newer.
|
||||||
|
|
||||||
|
- `java.sql` (optional since Gson 2.8.9)
|
||||||
|
When this module is present, Gson provides default adapters for some SQL date and time classes.
|
||||||
|
|
||||||
|
- `jdk.unsupported`, respectively class `sun.misc.Unsafe` (optional)
|
||||||
|
When this module is present, Gson can use the `Unsafe` class to create instances of classes without no-args constructor.
|
||||||
|
However, care should be taken when relying on this. `Unsafe` is not available in all environments and its usage has some pitfalls,
|
||||||
|
see [`GsonBuilder.disableJdkUnsafe()`](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/GsonBuilder.html#disableJdkUnsafe()).
|
||||||
|
|
||||||
### Documentation
|
### Documentation
|
||||||
* [API Javadoc](https://www.javadoc.io/doc/com.google.code.gson/gson): Documentation for the current release
|
* [API Javadoc](https://www.javadoc.io/doc/com.google.code.gson/gson): Documentation for the current release
|
||||||
* [User guide](https://github.com/google/gson/blob/master/UserGuide.md): This guide contains examples on how to use Gson in your code.
|
* [User guide](https://github.com/google/gson/blob/master/UserGuide.md): This guide contains examples on how to use Gson in your code.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# gson-codegen
|
# codegen
|
||||||
|
|
||||||
This Maven module contains the source code for automatically generating Gson type adapters.
|
This Maven module contains the source code for automatically generating Gson type adapters.
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ Bundle-Name: ${project.name}
|
||||||
Bundle-Description: ${project.description}
|
Bundle-Description: ${project.description}
|
||||||
Bundle-Vendor: Google Gson Project
|
Bundle-Vendor: Google Gson Project
|
||||||
Bundle-ContactAddress: ${project.parent.url}
|
Bundle-ContactAddress: ${project.parent.url}
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6, JavaSE-1.7, JavaSE-1.8
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.7, JavaSE-1.8
|
||||||
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.6))"
|
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.7))"
|
||||||
|
|
||||||
# Optional dependency for JDK's sun.misc.Unsafe
|
# Optional dependency for JDK's sun.misc.Unsafe
|
||||||
# https://bnd.bndtools.org/chapters/920-faq.html#remove-unwanted-imports-
|
# https://bnd.bndtools.org/chapters/920-faq.html#remove-unwanted-imports-
|
||||||
|
|
|
@ -4,8 +4,8 @@ apply plugin: 'maven'
|
||||||
group = 'com.google.code.gson'
|
group = 'com.google.code.gson'
|
||||||
version = '2.8.6-SNAPSHOT'
|
version = '2.8.6-SNAPSHOT'
|
||||||
|
|
||||||
sourceCompatibility = 1.6
|
sourceCompatibility = 1.7
|
||||||
targetCompatibility = 1.6
|
targetCompatibility = 1.7
|
||||||
|
|
||||||
sourceSets.main.java.exclude("**/module-info.java")
|
sourceSets.main.java.exclude("**/module-info.java")
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
|
@ -58,8 +58,8 @@
|
||||||
<jdkToolchain>
|
<jdkToolchain>
|
||||||
<version>[1.5,9)</version>
|
<version>[1.5,9)</version>
|
||||||
</jdkToolchain>
|
</jdkToolchain>
|
||||||
<source>1.6</source>
|
<source>1.7</source>
|
||||||
<target>1.6</target>
|
<target>1.7</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -83,7 +83,7 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<excludePackageNames>com.google.gson.internal:com.google.gson.internal.bind</excludePackageNames>
|
<excludePackageNames>com.google.gson.internal:com.google.gson.internal.bind</excludePackageNames>
|
||||||
<links>
|
<links>
|
||||||
<link>https://docs.oracle.com/javase/6/docs/api/</link>
|
<link>https://docs.oracle.com/javase/7/docs/api/</link>
|
||||||
</links>
|
</links>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -574,8 +574,9 @@ public final class $Gson$Types {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The WildcardType interface supports multiple upper bounds and multiple
|
* The WildcardType interface supports multiple upper bounds and multiple
|
||||||
* lower bounds. We only support what the Java 6 language needs - at most one
|
* lower bounds. We only support what the target Java version supports - at most one
|
||||||
* bound. If a lower bound is set, the upper bound must be Object.class.
|
* bound, see also https://bugs.openjdk.java.net/browse/JDK-8250660. If a lower bound
|
||||||
|
* is set, the upper bound must be Object.class.
|
||||||
*/
|
*/
|
||||||
private static final class WildcardTypeImpl implements WildcardType, Serializable {
|
private static final class WildcardTypeImpl implements WildcardType, Serializable {
|
||||||
private final Type upperBound;
|
private final Type upperBound;
|
||||||
|
|
|
@ -30,15 +30,10 @@ public final class MalformedJsonException extends IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MalformedJsonException(String msg, Throwable throwable) {
|
public MalformedJsonException(String msg, Throwable throwable) {
|
||||||
super(msg);
|
super(msg, throwable);
|
||||||
// Using initCause() instead of calling super() because Java 1.5 didn't retrofit IOException
|
|
||||||
// with a constructor with Throwable. This was done in Java 1.6
|
|
||||||
initCause(throwable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MalformedJsonException(Throwable throwable) {
|
public MalformedJsonException(Throwable throwable) {
|
||||||
// Using initCause() instead of calling super() because Java 1.5 didn't retrofit IOException
|
super(throwable);
|
||||||
// with a constructor with Throwable. This was done in Java 1.6
|
|
||||||
initCause(throwable);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
/**
|
||||||
|
* This package provides classes for processing JSON in an efficient streaming way.
|
||||||
|
*/
|
||||||
|
package com.google.gson.stream;
|
|
@ -161,7 +161,7 @@ public final class LinkedTreeMapTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
private <T> void assertIterationOrder(Iterable<T> actual, T... expected) {
|
private final <T> void assertIterationOrder(Iterable<T> actual, T... expected) {
|
||||||
ArrayList<T> actualList = new ArrayList<T>();
|
ArrayList<T> actualList = new ArrayList<T>();
|
||||||
for (T t : actual) {
|
for (T t : actual) {
|
||||||
actualList.add(t);
|
actualList.add(t);
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<java.version>1.6</java.version>
|
<java.version>1.7</java.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
|
|
Loading…
Reference in New Issue