Skip to content

Make GenericType not implement Serializable #73

Description

@garretwilson

The most common use of GenericType, as explained even in its own Javadocs, is:

new GenericType<List<Integer>>() { }

However, for reasons I don't understand, GenericType implements Serializable. This means that in ever single usage like the above, I will need to suppress a warning related to the lack of a serialVersionUID.

  • The original example in Neil Gafter's famous Super Type Tokens does not implement Serializable.
  • Jackson's TypeReference does not implement Serializable.
  • Spring's ParameterizedTypeReference does not implement Serializable.
  • The Guice TypeLiteral does not implement Serializable.
  • The GeantyRef fork of gentyref has a TypeToken which does not implement Serializable.
  • Guava's TypeToken unfortunately does implement Serializable, so at least ClassMate is not alone on this.

So only ClassMate and Guava implement Serializable for the class with identical functionality. The rest don't. It's not clear to me how it would ever be useful.

Can we remove implements Serializable from ClassMate GenericType<T>? No one needs or even wants Serializable in 2023. There are few if any cases that anyone should be creating new code using Serializable, and here it just brings a headache.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions