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.
The most common use of
GenericType, as explained even in its own Javadocs, is:However, for reasons I don't understand,
GenericTypeimplementsSerializable. This means that in ever single usage like the above, I will need to suppress a warning related to the lack of aserialVersionUID.Serializable.TypeReferencedoes not implementSerializable.ParameterizedTypeReferencedoes not implementSerializable.TypeLiteraldoes not implementSerializable.TypeTokenwhich does not implementSerializable.TypeTokenunfortunately does implementSerializable, so at least ClassMate is not alone on this.So only ClassMate and Guava implement
Serializablefor 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 Serializablefrom ClassMateGenericType<T>? No one needs or even wantsSerializablein 2023. There are few if any cases that anyone should be creating new code usingSerializable, and here it just brings a headache.