Community
Participate
Working Groups
When I enabled the compiler warning Advanced -> Field declaration hides another field or variable, I get the warning: The field Two.serialVersionUID is hiding a field from type One. This is pretty simple to reproduce: public class One implements Serializable{ static final long serialVersionUID = 1234567890L; } public class Two extends One{ static final long serialVersionUID = 987654321L; } I'd suggest that serialVersionUID should be ignored for this set of warnings.
I agree. We already treat it special when flagging unused private members.
Created attachment 9237 [details] ignore serialization fields during fieldHiding This checks for the serialVersionUID and serialPersistentFields. Does it matter that there is no check to see if the class implements java.io.Serializable?
It doesn't particularly matter to me if it checks that the class implements java.io.Serializable. As far as I know it's legal (though silly/useless) to define serialVersionUID whether it does or not. This is offtopic, I know, but I think it'd be great to have a separate rule which checks that a Serializable class: -defines a serialVersionUID -contains only members that are Serializable, transient or static -has a unique serialVersionUID (check and compare) -does not extend a class that *can't* be serialized, such as a socket or stream or database connection etc I've already implemented the above checks in my code by abusing Javadoc doclets, so I don't really need it. But perhaps someone else could benefit from such a thing.
Patch looks good. This is the check we had in #unusedPrivateField. Fixed. Added regression test: NegativeTest#test416.
Verified in 200405180816
I think this bug is back in the Kepler release