Commit Graph

2043 Commits

Author SHA1 Message Date
Marcono1234 5253ddbde0
Follow-up for record test build changes (#2207) 2022-09-27 23:02:15 -07:00
Éamonn McManus 441406cc78
Add a currently-failing test for Java records and `@Ignore` it. (#2203)
* Add a currently-failing test for Java records and `@Ignore` it.

Also do the Maven gymastics required to ensure that this test only runs on Java
versions ≥17. (It would also work on Java 16, but 17 is all we have in the CI.)

Fix some compilation problems I saw when running locally, which for some reason
don't show up in the CI.

* Suppress some new lint options that trigger `-Werror`.
We may fix these later. (Every test will need an explicit constructor!)

* Select Java version with maven.compiler.release and maven.compiler.testRelease.

Use `assumeNotNull` rather than an if-statement.

* Specify <release>11</release> for javadoc.

* Restore the @see for AccessibleObject.
2022-09-27 12:32:40 -07:00
Marcono1234 2591ede59b
Fix incorrect HTML headings in Javadoc (#2200) 2022-09-24 17:02:11 -07:00
Éamonn McManus 0864a02e86
Build on JDK 17 as well as 11. (#2198)
* Build on JDK 8 and 17 as well as 11.

* Remove JDK 8 for now.

`DefaultDateTypeAdapterTest` fails.

* Tweak javadoc to avoid warnings.

Mostly these are about using `<h3>` when the previous tag was `<h1>`,
and the like. This previous tag might be implicit (part of what javadoc
itself outputs rather than the HTML in doc comments).

Apparently JDK 11 puts method javadoc inside `<h2>` while JDK 11 puts it
inside `<h3>`. Or something like that. Anyway it doesn't appear to be
possible to use `<h3>` _or_ `<h4>` and please both.
2022-09-23 14:33:28 -07:00
dependabot[bot] 2154e468b4
Bump maven-jar-plugin from 3.2.2 to 3.3.0 (#2195)
Bumps [maven-jar-plugin](https://github.com/apache/maven-jar-plugin) from 3.2.2 to 3.3.0.
- [Release notes](https://github.com/apache/maven-jar-plugin/releases)
- [Commits](https://github.com/apache/maven-jar-plugin/compare/maven-jar-plugin-3.2.2...maven-jar-plugin-3.3.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-jar-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-19 07:07:43 -07:00
Marcono1234 6b9db2e449
Add Gson.fromJson(..., TypeToken) overloads (#1700)
* Add Gson.fromJson(..., TypeToken) overloads

Previously only Gson.fromJson(..., Type) existed which is however not
type-safe since the generic type parameter T used for the return type is
not bound.
Since these methods are often used in the form
  gson.fromJson(..., new TypeToken<...>(){}.getType())
this commit now adds overloads which accept a TypeToken and are therefore
more type-safe.

Additional changes:
- Fixed some grammar mistakes
- Added javadoc @see tags
- Consistently write "JSON" in uppercase
- More precise placement of @SuppressWarnings("unchecked")

* Add to Gson.fromJson javadoc that JSON is fully consumed

The newly added documentation deliberately does not state which exception
is thrown because Gson.assertFullConsumption could throw either a
JsonIOException or a JsonSyntaxException.

* Remove unnecessary wrapping and unwrapping as TypeToken in Gson.fromJson

Since the actual implementation of Gson.fromJson is TypeToken based, the
TypeToken variant overloads are now the "main" implementation and the other
overloads delegate to them.
Previously the Type variant overloads were the "main" implementation which
caused `TypeToken.getType()` followed by `TypeToken.get(...)` when the
TypeToken variant overloads were used.

* Trim source code whitespaces

* Fix Gson.fromJson(JsonReader, Class) not casting read Object

To be consistent with the other Gson.fromJson(..., Class) overloads the
method should cast the result.

* Replace User Guide link in Gson documentation

* Remove more references to fromJson(..., Type)

* Extend documentation for fromJson(JsonReader, ...)

* Replace some TypeToken.getType() usages

* Address feedback; improve documentation

* Remove fromJson(JsonReader, Class) again

As noticed during review adding this method is source incompatible.
2022-09-19 06:47:11 -07:00
Johannes Frohnmeyer f6e2bd0fb0
Fix tests by removing broken ones 2022-09-14 19:55:35 +02:00
Johannes Frohnmeyer ded8d1c79f
No module 2022-09-14 19:44:09 +02:00
Johannes Frohnmeyer 8ec31281a7
Try fixing 2022-09-14 19:41:29 +02:00
Johannes Frohnmeyer e89fbec94a
Just ignore em 2022-09-14 19:37:21 +02:00
Johannes Frohnmeyer 67402b1acf
Attempt to fix pom by replacing it with the current upstream 2022-09-14 19:31:32 +02:00
Johannes Frohnmeyer f47c21fce7
Remove one deprecated method 2022-09-14 19:24:15 +02:00
Johannes Frohnmeyer ce02cb3bc1
Merge remote-tracking branch 'origin/master'
# Conflicts:
#	gson/pom.xml
#	gson/src/main/java/com/google/gson/Gson.java
#	gson/src/main/java/com/google/gson/GsonBuilder.java
#	gson/src/main/java/com/google/gson/internal/bind/ArrayTypeAdapter.java
#	gson/src/main/java/com/google/gson/stream/JsonWriter.java
#	gson/src/test/java/com/google/gson/functional/ArrayTest.java
#	gson/src/test/java/com/google/gson/functional/MapTest.java
#	pom.xml
2022-09-14 19:20:24 +02:00
Deepti M a733150cfa
updated JsonDeserializer example (#2192)
* fixed json deserializer example

* correcting the json

* updated per review

* updated per review

* updated per review
2022-09-12 10:14:05 -07:00
Marcono1234 847d7f6638
Improve documentation (#2193)
* Improve JsonElement subclasses javadoc and add tests

* Slightly improve JsonSerializer and JsonDeserializer javadoc

* Improve ReflectionAccessTest failure message

* Improve documentation regarding field and class exclusion
2022-09-09 07:32:55 -07:00
Marcono1234 2266ccdd67
Remove usage of oss-parent Maven parent and update ReleaseProcess.md (#2159)
The oss-parent configuration has been applied manually to the root pom.xml,
except that now newer plugin versions are used for source and javadoc JAR
creation, and for GPG signing.

This required some reordering of the plugins for the gson module to make
sure they are executed in the correct order. Otherwise this would cause
failures for javadoc:jar.
2022-09-06 16:26:53 -07:00
dependabot[bot] e1b3a0355f
Bump jackson-databind from 2.13.3 to 2.13.4 (#2191)
Bumps [jackson-databind](https://github.com/FasterXML/jackson) from 2.13.3 to 2.13.4.
- [Release notes](https://github.com/FasterXML/jackson/releases)
- [Commits](https://github.com/FasterXML/jackson/commits)

---
updated-dependencies:
- dependency-name: com.fasterxml.jackson.core:jackson-databind
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-05 13:40:30 -07:00
dependabot[bot] ceb24cc033
Bump japicmp-maven-plugin from 0.15.7 to 0.16.0 (#2187)
Bumps [japicmp-maven-plugin](https://github.com/siom79/japicmp) from 0.15.7 to 0.16.0.
- [Release notes](https://github.com/siom79/japicmp/releases)
- [Changelog](https://github.com/siom79/japicmp/blob/master/release.py)
- [Commits](https://github.com/siom79/japicmp/compare/japicmp-base-0.15.7...japicmp-base-0.16.0)

---
updated-dependencies:
- dependency-name: com.github.siom79.japicmp:japicmp-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-31 10:36:39 -07:00
Marcono1234 c2d0cede65
Add GitHub workflow for checking API compatibility (#2182) 2022-08-28 10:51:31 -07:00
Marcono1234 f7a164d98b
Fail Maven build on compiler warnings; remove some warning suppressions (#2183)
* Fail Maven build on compiler warnings; remove some warning suppressions

* Fix compiler warnings causing failure for newer JDK

* Improve placement of "raw" and "unchecked" warning suppressions

* Adjust javac documentation link

* Fix compilation error on newer JDKs
2022-08-26 17:36:18 -07:00
Marcono1234 325f37cd6b
Verify that JsonTreeReader and JsonTreeWriter override all methods (#2181)
* Verify that JsonTreeReader and JsonTreeWriter override all methods

If those classes do not override one of the JsonReader or JsonWriter methods
the user might encounter an AssertionError.

* Address review feedback
2022-08-23 14:19:47 -07:00
Marcono1234 7f77ad4ff6
Replace `$Gson$Preconditions.checkNotNull` with `Objects.requireNonNull` (#2180)
* Replace $Gson$Preconditions.checkNotNull with Objects.requireNonNull

* Add back checkNotNull
2022-08-22 07:22:32 -07:00
Marcono1234 b0b6834157
Mention that GsonBuilder.registerTypeAdapter makes (de-)serializers null-safe (#1704) 2022-08-22 06:55:31 -07:00
Marcono1234 5bebf970d1
Fix changes to GsonBuilder affecting existing Gson instances (#1815)
Previously when a GsonBuilder had created a Gson instance and was afterwards
reused and different type adapters were added, new GsonBuilder instances
obtained from the previous Gson instance through Gson.newBuilder() would have
been affected by the GsonBuilder changes.

This commit fixes this and additionally adds some more unit tests.
2022-08-22 06:49:48 -07:00
dependabot[bot] 517d3b176b
Bump maven-javadoc-plugin from 3.4.0 to 3.4.1 (#2175)
Bumps [maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.4.0 to 3.4.1.
- [Release notes](https://github.com/apache/maven-javadoc-plugin/releases)
- [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.4.0...maven-javadoc-plugin-3.4.1)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-javadoc-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-21 14:02:45 -07:00
Marcono1234 51a72b463b
Make JsonElement conversion methods more consistent and fix javadoc (#2178)
* Make JsonElement conversion methods more consistent and fix javadoc

* Address some review comments
2022-08-21 13:29:40 -07:00
Marcono1234 26be941575
Throw UnsupportedOperationException when JsonWriter.jsonValue is not supported (#1651) 2022-08-21 08:49:32 -07:00
Marcono1234 b84b2218f2
Add null checks for GsonBuilder methods (#2179) 2022-08-20 13:16:35 -07:00
Marcono1234 18b9ba407d
Improve GsonTest.testGetAdapter_Concurrency (#2177)
Makes the test implementation more reliable to prevent flaws in the test
setup causing spurious test success.
2022-08-19 10:25:20 -07:00
Marcono1234 5e1005ea27
Disallow `JsonObject` `Entry.setValue(null)` (#2167)
* Disallow JsonObject Entry.setValue(null)

* Adjust comments in JsonObjectTest
2022-08-18 13:10:43 -07:00
Lorenz Nickel 53234aa351
Add test for JsonArray.isEmpty() (#2173) 2022-08-08 08:38:56 -07:00
Marcono1234 6fc1c8f7f1
Fix `TypeAdapter.toJson` throwing AssertionError for custom IOException (#2172)
* Fix TypeAdapter.toJson throwing AssertionError for custom IOException

* Add throws javadoc tag for TypeAdapter methods
2022-08-08 08:19:44 -07:00
Marcono1234 d53b3ea84a
Clarify doc about non-finite numbers for non-lenient JsonReader (#1723) 2022-08-08 06:40:07 -07:00
Marcono1234 a4bc6c17d7
Fix JsonTreeReader throwing wrong exception type for non-finite doubles (#1782)
Follow-up for #1767
2022-08-08 06:39:29 -07:00
Marcono1234 f7cefcb426
Fix JsonWriter documentation regarding top-level value (#1766)
* Fix JsonReader / JsonWriter documentation regarding top-level value

RFC 7159 allows any top-level value (not only arrays or objects) [0],
however when #773 added this functionality it appears the author forgot
to update the documentation of these classes.

[0] https://tools.ietf.org/html/rfc7159#appendix-A
> Changed the definition of "JSON text" so that it can be any JSON
> value, removing the constraint that it be an object or array.

* Fix missing space
2022-08-07 16:24:37 -07:00
Marcono1234 9eb04414c0
Improve InternationalizationTest (#1705)
* Improve InternationalizationTest

- Remove "raw" tests since after compiling they are the same as the one with
  escape sequences
- Add tests for supplementary code points (> \uFFFF)

* Improve variable names, fix incorrect escape sequences
2022-08-07 16:00:35 -07:00
Marcono1234 76c78f5925
Remove not needed .gitattributes file (#1862)
The .gitattributes file was added to prevent GitHub detecting Gson as HTML
repository due to the included generated javadoc files. However, since
#1654 has removed the javadoc files, the .gitattributes file is no longer
needed.
2022-08-07 15:59:39 -07:00
James 9868957862
Fix typo (#1246) 2022-08-07 15:43:37 -07:00
Marcono1234 390385e382
Clarify that `GsonBuilder.setExclusionStrategies` does not replace existing ones (#2168)
* Clarify that `GsonBuilder.setExclusionStrategies` does not replace existing ones

* Fix punctuation
2022-08-06 10:01:37 -07:00
Marcono1234 246270e02c
Convert null to JsonNull for `JsonArray.set` (#2170)
* Convert null to JsonNull for `JsonArray.set`

All other methods perform the same implicit conversion.

* Mention null handling in JsonObject documentation
2022-08-06 09:57:00 -07:00
bufistov 46b97bf156
Fixed nullSafe usage. (#1555)
The JsonSerializer/Deserializer adapters used to ignore this attribute
which result in inconsistent behaviour for annotated adapters.

Fixes #1553

Signed-off-by: Dmitry Bufistov <dmitry@midokura.com>

Co-authored-by: Dmitry Bufistov <dmitry@midokura.com>
2022-08-05 07:33:05 -07:00
Marcono1234 98f2bbf4c1
Validate `TypeToken.getParameterized` arguments (#2166) 2022-08-05 06:59:38 -07:00
Marcono1234 0b6a7bf7d9
Deprecate JsonElement constructor (#1761)
* Deprecate JsonElement constructor

Creating custom JsonElement subclasses is discouraged.

* Improve test and documentation

* Improve JsonTreeReaderTest, adjust deprecation comments
2022-08-04 10:32:30 -07:00
Marcono1234 a1d2ebc8b5
Fix #1702: Gson.toJson creates CharSequence which does not implement toString (#1703)
* Gson.toJson creates CharSequence which does not implement toString

* Improve Streams.AppendableWriter.CurrentWrite test

* Make setChars package-private
2022-08-03 14:25:12 -07:00
Marcono1234 4552db2630
Prefer existing adapter for concurrent `Gson.getAdapter` calls (#2153)
Additionally fail fast for null as type (previous null support was broken
and would have thrown NullPointerException further below anyways).
2022-08-01 10:59:04 -07:00
Marcono1234 a45c55739f
Improve ArrayTypeAdapter for Object[] (#1716)
* Improve ArrayTypeAdapter for Object[]

* Fix typo in test method names
2022-07-31 14:49:02 -07:00
Marcono1234 5f2513a407
Improve AppendableWriter performance (#1706)
* Improve AppendableWriter performance

Override methods which by default create char arrays or convert
CharSequences to Strings.
This is not necessary for AppendableWriter because it can directly
append these values to the Appendable delegate.

* Add test for Streams.writerForAppendable
2022-07-31 14:46:43 -07:00
Éamonn McManus a4290c52e0 Update CHANGELOG.md with 2.9.1 changes.
Update version numbers in documentation (2.9.0 -> 2.9.1).
2022-07-31 14:43:17 -07:00
Éamonn McManus ca22b68008 [maven-release-plugin] prepare for next development iteration 2022-07-31 14:25:34 -07:00
Éamonn McManus bb9a1f255a [maven-release-plugin] prepare release gson-parent-2.9.1 2022-07-31 14:25:32 -07:00