Commit Graph

6 Commits

Author SHA1 Message Date
Maicol 9f26679e7a
Adds Error Prone to the `maven-compiler-plugin` (#2308)
* Adds Error Prone to the `pom.xml`

* Adds Error Prone annotations to avoid compiling errors

* Adds profile to run Error Prone in JDK8

* Revert "Adds profile to run Error Prone in JDK8"

This reverts commit 61771d0da55003ea5bc8c6f086d925aec583c9a2.

* Fix Error Prone warn

* Add comment to `pom.xml`

* Fix the `@SuppressWarnings("GetClassOnClass")`

* Replace the Error Prone link in the `pom.xml`

* Disable Error Prone with jdk-15`

* Remove a new-line in `pom.xml`
2023-02-06 06:13:28 -08:00
Éamonn McManus 0d22e5d205
Add copyright notices to files that were missing them. (#2307)
In each case the copyright year is the year in which the file was first added.
2023-01-31 14:05:12 -08:00
Maicol 49b00d1a86
Port all Junit assert to Truth asserts (#2304)
* 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
2023-01-31 11:20:54 -08:00
Marcono1234 66d9621ce8
Adjust Record adapter and extend test coverage (#2224)
* 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
2022-10-22 09:01:56 -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 e82637c485
Add support for reflection access filter (#1905)
* Add support for reflection access filter

* Improve documentation

* Fix compilation errors

* Relax handling for BLOCK_ALL when invoking default constructor

* Improve handling for inherited fields

* Fix accessible test failing for static fields

* Simplify ReflectiveTypeAdapterFactory field writing

* Fix GsonBuilder changes affecting created Gson instances

* Improve documentation

* Improve handling for IllegalAccessException

For Java < 9, AccessibleObject.canAccess is not available and therefore checks
might pass even if object is not accessible, causing IllegalAccessException
later.

* Fix incorrect GsonBuilder.addReflectionAccessFilter documentation
2022-04-17 09:05:18 -07:00