Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serial version uid and eclipse

There is a nice feature in eclipse to generate serial version uid. But when class is updated eclipse does not warn that serial version uid has to be updated, it does not even have a feature to regenerate this uid, it has to be removed manually first and only then eclipse will ask to generate new one.

Are there any plugin or another trick to serial version uids up to date?

like image 319
michael nesterenko Avatar asked Nov 22 '11 12:11

michael nesterenko


1 Answers

But when class is updated eclipse does not warn that serial version uid has to be updated.

Actually, it typically doesn't have to be updated, and indeed it is difficult to know (automatically) whether or not this is the case.

The serial version UID is "... a 64-bit hash of the class name, interface class names, methods, and fields" (here). That means that the UID changes when any of these "attributes" changes. However, some of these attributes can change without violating binary compatibility of serialized objects and (thus) without necessitating a change in the UID. For instance, method signatures can change and fields can be added without violating binary compatibility, according to this.

And if the UID doesn't have to be updated, then there's an argument that says that it shouldn't be updated, because updating the UID in the class means that it won't be able to read serialized classes ... that it might have been able to read if you hadn't updated the id!


To answer your question:

  • I know of no such tool or plugin.
  • If you do find one you should think twice about running it over your code.
like image 175
Stephen C Avatar answered Oct 17 '22 01:10

Stephen C