gson-comments/gson
Marcono1234 b1c399fd62
Improve TypeToken creation validation (#2072)
* Add comments regarding multiple bounds of wildcard

* Remove WildcardType check in getCollectionElementType

The returned Type is never a wildcard due to the changes made to getSupertype
by commit b1fb9ca9a1.

* Remove redundant getRawType call from MapTypeAdapterFactory

getRawType(TypeToken.getType()) is the same as calling TypeToken.getRawType().

* Make TypeToken members private

* Remove incorrect statement about TypeToken wildcards

It is possible to use wildcards as part of the type argument, e.g.:
`new TypeToken<List<? extends CharSequence>>() {}`

* Only allow direct subclasses of TypeToken

Previously subclasses of subclasses (...) of TypeToken were allowed which
can behave incorrectly when retrieving the type argument, e.g.:

  class SubTypeToken<T> extends TypeToken<Integer> {}
  new SubTypeToken<String>() {}.getType()

This returned `String` despite the class extending TypeToken<Integer>.

* Throw exception when TypeToken captures type variable

Due to type erasure the runtime type argument for a type variable is not
available. Therefore there is no point in capturing a type variable and it
might even give a false sense of type-safety.

* Make $Gson$Types members private

* Rename $Gson$Types.getGenericSupertype parameter

Rename the method parameter to match the documentation of the method and
to be similar to getSupertype(...).

* Improve tests and handle raw TypeToken supertype better

* Make some $Gson$Types members package-private again to prevent synthetic accessors

* Remove TypeToken check for type variable

As mentioned in review comments, there are cases during serialization where
usage of the type variable is not so problematic (but still not ideal).
2022-04-19 08:20:58 -07:00
..
src Improve TypeToken creation validation (#2072) 2022-04-19 08:20:58 -07:00
bnd.bnd Change target Java version to 7 (#2043) 2021-12-31 07:20:29 -08:00
LICENSE Updating License to contain the full text. 2011-04-12 21:21:39 +00:00
pom.xml Bump maven-surefire-plugin from 3.0.0-M5 to 3.0.0-M6 (#2101) 2022-04-03 20:08:33 -07:00
README.md Add READMEs to Maven modules (#2039) 2021-12-27 10:17:41 -08:00

gson

This Maven module contains the Gson source code. The artifacts created by this module are deployed to Maven Central under the coordinates com.google.code.gson:gson.