* Port Junit assert to Truth in `com.google.gson.stream`
* Port Junit assert to Truth in `com.google.gson.regression`
* Port Junit assert to Truth in `om.google.gson.reflect`
* Port Junit assert to Truth in `com.google.gson.metrics`
* Port Junit assert to Truth in `com.google.gson.internal`
* Port Junit assert to Truth in `com.google.gson.internal.sql`
* Port Junit assert to Truth in `com.google.gson.internal.reflect`
* Port Junit assert to Truth in `com.google.gson.internal.bind`
* Port Junit assert to Truth in `com.google.gson.internal.bind.util`
* Port Junit assert to Truth in `com.google.gson.functional`
* Replaces `List.of` with `Arrays.asList` to grant legacy
* Simplify `==` asserts
* Simplify `.contain()` asserts + Minor fixes
* Simplify asserts
* Add the Truth dependency
* Port Junit test to Truth in the package `com.google.gson` of the module `gson`
* Replace the `assertThat(e.getMessage()).isEqualTo(...)"` with `assertThat(e).hasMessageThat().isEqualTo(...)`
* Minor fixes
* Rewrite the `testParsingDatesFormattedWithSystemLocale()`, Fix#2199
* Format the test
* Format the code following Google Java Style Guide
* Revert "Format the code following Google Java Style Guide"
This reverts commit f5e2e16b290a4bed09ed7fcc162d4a2529fe4c38.
* Remove EOFException special casing of JsonStreamParser.next()
The previous behavior violated the Iterator contract where for
`JsonStreamParser("[")` a call to `hasNext()` would return true,
but `next()` would throw a NoSuchElementException.
* Fix incorrect documented thrown exception type for JsonStreamParser
* Fix non-threadsafe creation of adapter for type with cyclic dependency
* Improve handling of broken adapters during Gson.getAdapter(...) call
* Improve test
* Slightly improve implementation and extend tests
* Simplify getAdapter implementation
* Convert GsonTest to JUnit 4 test
* Clarify getAdapter concurrency behavior
* Adjust version numbers and a test to conform to the SemVer spec.
Gson releases since 2.8.0 have been following this spec. We mistakenly released 2.10
without the .0 patch version, and adjusted `GsonVersionDiagnosticsTest` so it would
accept that, as well as the two-digit `10`. Here we make the test no longer accept
versions without a patch number, while still accepting two-digit minor versions of course.
We also change the snapshot version to 2.11.0-SNAPSHOT instead of 2.11-SNAPSHOT.
* Add 2.10 changes to CHANGELOG; minor release follow-ups
* Use GitHub URLs in CHANGELOG
GitHub automatically displays them only as short reference with link and
additionally shows a preview when hovering over them.
* Add `id` to pom.xml developer entry
Otherwise BND plugin shows a warning.
* Run unit tests during release preparation
* Move git option before pathspec
* Automatically replace version references on `release:prepare`
* Specify encoding and improve placeholder replacements
* Add `since $next-version$` for `JsonArray.asList` and `JsonObject.asMap`
* Adjust Record adapter and extend test coverage
* Address review feedback
* Make constructor string more concise
* Add tests for Gson default behavior for static fields
* Improve exception for deserializing static final field
Previously it would report "Unexpected IllegalAccessException occurred..."
due to the uncaught IllegalAccessException.
* Improve handling of exception thrown by accessor
Such an exception is not 'unexpected' (which was claimed by the previous
exception handling) because user code could throw it.
* Improve constructor invocation exception handling and add tests
* Small adjustments to the new record code.
* Replace wildcard imports with single imports.
* Enable `Java17RecordTest` and fix its many previously-hidden problems.
* Use a `Map` to get primitive zero values rather than a potentially-expensive reflective trick.
* Apply some automated code fixes.
* Address review comments.
* Support Java Records when present in JVM.
Fixesgoogle/gson#1794
Added support in the ReflectionHelper to detect if a class is a record
on the JVM (via reflection), and if so, we will create a special
RecordAdapter to deserialize records, using the canoncial constructor.
The ReflectionTypeAdapterFactory had to be refactored a bit to support
this. The Adapter class inside the factory is now abstract, with
concrete implementations for normal field reflection and for Records.
The common code is in the Adapter, with each implementation
deserializing values into an intermediary object.
For the FieldReflectionAdapter, the intermediary is actually the final
result, and field access is used to write to fields as before. For the
RecordAdapter the intermediary is the Object[] to pass to the Record
constructor.
* Fixed comments from @Marcono1234
Also updated so that we now use the record accessor method to read out
values from a record, so that direct field access is not necessary.
Also added some tests, that should only execute on Java versions with
record support, and be ignored for other JVMs
* Fixed additional comments from @Marcono1234
* Made Adapter in ReflectiveTypeAdapterFactory public
Fix comment from @eamonnmcmanus
* Fix TypeAdapterRuntimeTypeWrapper not detecting reflective TreeTypeAdapter
Previously on serialization TypeAdapterRuntimeTypeWrapper preferred a
TreeTypeAdapter without `serializer` which falls back to the reflective
adapter. This behavior was incorrect because it caused the reflective
adapter for a Base class to be used for serialization (indirectly as
TreeTypeAdapter delegate) instead of using the reflective adapter for
a Subclass extending Base.
* Address review feedback
* Convert TypeAdapterRuntimeTypeWrapperTest to JUnit 4 test
* Prefer wrapped reflective adapter for serialization of subclass
* Detect reflective adapter used as delegate for Gson.FutureTypeAdapter
* Tiny style tweak.
Co-authored-by: Éamonn McManus <emcmanus@google.com>