FasterXML / java-classmate

Library for introspecting generic type information of types, member/static methods, fields. Especially useful for POJO/Bean introspection.
http://fasterxml.com
Apache License 2.0
258 stars 42 forks source link

Make `GenericType` not implement `Serializable` #73

Closed garretwilson closed 11 months ago

garretwilson commented 11 months ago

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.

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.

cowtowncoder commented 11 months ago

I agree, sounds like an oversight to be corrected. I hope to address this later today (really busy at daytime job but maybe tonight).

As to need for java.io.Serializable, for the longest time there were some (possibly ill-conceived, legacy) use cases related to things like Spark processing, where things like Jackson ObjectMappers needed to be (or was useful to have) Serializable. That's why within Jackson many entities are Serializable. I don't see that as the reason for this one at all, but just mention for sake of completeness.

And yes, due to many, many issues, use of java.io.Serializable is definitely an anti-pattern in general.

garretwilson commented 11 months ago

… really busy at daytime job but maybe tonight …

I can understand that! 😅

Hey, I'll be happy to take this one. I need to set up the project for other changes we've been discussing, and it will give me some pleasure to get Serializable out of there. If you haven't started it, I'll do it and file a pull request now.

garretwilson commented 11 months ago

Hey, I'll be happy to take this one.

Eep, I take that back. I assumed that I could just fork the project, build it, make the change, make sure the unit tests pass, and then file a pull request. But it looks like we have some problems; see #74. (As mentioned there, I can help with that, with a caveat.)

So for the meantime, if this builds on your system, it's probably better if you go ahead and take care of this ticket as you had indicated earlier.

garretwilson commented 10 months ago

I was dropping by here to fix this ticket, but I see you've already done it, and even released v1.6.0. 🎉 Thank you for your attention and quick work! I'm heading to go grab the new version now.