* Enable additional Error Prone checks & fix violations
Some of them also enforce additional Google Java Format requirements which
are not handled by google-java-format, such as disallowing wildcard imports.
Not all experimental checks have been listed because some are not applicable,
such as Dependency Injection framework checks, or checks related to Guava's
immutable collections (since Gson's main code does not have a dependency on
Guava).
Other checks have been omitted because they are probably not relevant
(this was a subjective choice), or would require larger refactoring or
would flag issues with the public API, which cannot be changed easily.
* Address review feedback
---------
Co-authored-by: Éamonn McManus <emcmanus@google.com>
* Add CI build using JDK 21
This is mainly to make sure that besides the known JDK 21 build
incompatibilities Gson can be built and run using JDK 21.
* Update ProGuard
* Update Protobuf
3.25.1 is actually newer than 4.0.0-rc-2
However, it might still be necessary to use the same OS and JDK version
to actually be able to create identical artifacts.
This commit also formats the `pom.xml` files in the way the Maven Release
Plugin would.
* Add shrinker-test examples with never-referenced constructors
R8 can do some optimizations that assume values of types whose
constructors are never referenced are `null`. (A bit confused why
the rules here are sufficient to avoid that optimization in the
case of a class whose sole constructor has arguments and is
unreferenced, since the keep rule only refers to `<init>()` instead
of `<init>(...)`. Does R8 have special behavior for `<init>()` where
attempting to keep that makes it assume a class is constructable even
if it doesn't have a no-args constructor?)
Also rename some test classes/names to refer to `NoArgs` instead of
`Default` constructors. The examples here care about whether a
no-argument constructor is present. While a no-argument
constructor (explicitly defined or not) is used by default in some
circumstances, the Java documentation consistently uses "default
constructor" to refer only to constructors whose implementation is
implicitly provided by the complier (all default constructors are
no-argument constructors, but not vice versa).
* Update shrinker-test/src/main/java/com/example/ClassWithNoArgsConstructor.java
Accept review suggestion
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
* Update shrinker-test/src/main/java/com/example/NoSerializedNameMain.java
Accept review suggestion
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
* Further adjust test class/method names for consistency
* Update shrinker-test/src/main/java/com/example/NoSerializedNameMain.java
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
---------
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
* Prevent `TypeToken` from capturing type variables
* Use hyphen for term "type-safe"
Not completely sure if that is grammatically correct, but it might make the
text a bit easier to understand.
* Update Troubleshooting Guide URLs in tests from 'master' to 'main'
* Rename system property
* Simplify system property check
* Adjust ProGuard default rules and shrinking tests
* Adjust comment
* Add shrinking test for class without no-args constructor; improve docs
* Improve Unsafe mention in Troubleshooting Guide
* Improve comment for `-if class *`
* Add code shrinking tools integration test
* Keep no-args constructor of classes usable with JsonAdapter
* Add library ProGuard rules for Gson
They are automatically applied for all users of Gson, see
https://developer.android.com/build/shrink-code#configuration-files
* Skip japicmp-maven-plugin for shrinker-test
* Add more tests for JsonAdapter, add tests for generic classes
* Extend default constructor test
* Add Troubleshooting Guide entry for TypeToken