Check for serialVersionUID in Serializable classes

"Roman Scheiter" <[email protected]>
Newsgroups gmane.comp.java.audit.checkstyle.user
Message-ID <[email protected]>
Hi,

 

I am in need of a check that verifies that all of the classes
implementing the Serializable interface have the serialVersionUID
defined.

Trolling through the plenty available checks, I did not see such a check
being available today. I also noticed that there is a request for such
check in the bug tracking system.

If anyone has a check for this, please let me know and point me to it.

 

I have started writing my own check. The scenarios that I would need to
cover are:

1. Class implements Serializable interface, validate that
serialVersionUID is assigned

2. Class implements InterfaceA which extends Serializable, validate that
serialVersionUID is assigned

3. Class extends ClassA which implements Serializable (or Interface A),
validate that serialVersionUID is assigned.

4. Class implements Serializable through type hierarchy, but is not
serializable, i.e. throws NotSerializableException for read/writeObject,
do not require serialVersionUID.

 

Item 1 is very straight forward and I can put this together following
the "Write a Check" tutorial. I am not clear how I can establish and
examine the Type hierarchy.

 

Does anyone have suggestions as to how this Check can be implemented? Is
this something that can be accomplished using the FileSetChecks?

 

Thanks for the help,

Roman

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08

_______________________________________________
Checkstyle-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.