Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve TypeToken creation validation #2072

Merged

Commits on Jul 26, 2020

  1. Copy the full SHA
    f8b33f4 View commit details
    Browse the repository at this point in the history
  2. Remove WildcardType check in getCollectionElementType

    The returned Type is never a wildcard due to the changes made to getSupertype
    by commit b1fb9ca.
    Marcono1234 committed Jul 26, 2020
    Copy the full SHA
    9faa6c3 View commit details
    Browse the repository at this point in the history
  3. Remove redundant getRawType call from MapTypeAdapterFactory

    getRawType(TypeToken.getType()) is the same as calling TypeToken.getRawType().
    Marcono1234 committed Jul 26, 2020
    Copy the full SHA
    074ec48 View commit details
    Browse the repository at this point in the history

Commits on Jul 29, 2020

  1. Copy the full SHA
    a264348 View commit details
    Browse the repository at this point in the history
  2. 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>>() {}`
    Marcono1234 committed Jul 29, 2020
    Copy the full SHA
    0e69593 View commit details
    Browse the repository at this point in the history
  3. 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>.
    Marcono1234 committed Jul 29, 2020
    Copy the full SHA
    02b7500 View commit details
    Browse the repository at this point in the history

Commits on Jul 30, 2020

  1. 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.
    Marcono1234 committed Jul 30, 2020
    Copy the full SHA
    85159c4 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    11c1d05 View commit details
    Browse the repository at this point in the history
  3. Rename $Gson$Types.getGenericSupertype parameter

    Rename the method parameter to match the documentation of the method and
    to be similar to getSupertype(...).
    Marcono1234 committed Jul 30, 2020
    Copy the full SHA
    f853dbb View commit details
    Browse the repository at this point in the history

Commits on Feb 6, 2022

  1. Copy the full SHA
    0530cde View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    4436078 View commit details
    Browse the repository at this point in the history
  3. Copy the full SHA
    446bf92 View commit details
    Browse the repository at this point in the history

Commits on Feb 16, 2022

  1. 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).
    Marcono1234 committed Feb 16, 2022
    Copy the full SHA
    cba0307 View commit details
    Browse the repository at this point in the history