Should IG's Serializable class without serialVersionUID apply to enum?

See subject

0
4 comments
Avatar
Permanently deleted user


No. The JVM is supposed to magically handle all of the serialization issues of enums. This is somewhat annoyingly inconsistent, but if you weren't up for annoying inconsistency, you would be using Java serialization functionality.

I've fixed the "Serializable without serialVersionUID" and "Serializable without readObject() and writeObject()" inspections to ignore enumerated classes. Good catch.

--Dave Griffith

0
Avatar
Permanently deleted user

/s/would/wouldn't

0
Avatar
Permanently deleted user

I see in the enum documentation that "All are Serializable, Comparable and effectively final." If I'm reading the documentation right, would a new inspection that says Serializable on a enum is unnecessary/redundant be appropriate?

Thanks,
Jon

0
Avatar
Permanently deleted user


There's already an inspection for redundant interface declarations that would catch this case. I run with it off because I like the documentation effect. That said, I agree that defining an enumerated class as Serializable or Comparable would look fairly stupid. I'll think about if the existing inspection can be sharpened, or if a new inspection is appropriate.

--Dave Griffith

0

Please sign in to leave a comment.