5

Suppose here is my class :

class B implements Serializable {

    private static final long serialVersionUID = -5186261241138469827L; // what algo is used to generate this
     ..........
}

What algorithm eclipse uses to generate serialVersionUID = -5186261241138469827L ?

Prateek
  • 12,014
  • 12
  • 60
  • 81
  • Maybe it's using [serialver](http://docs.oracle.com/javase/6/docs/technotes/tools/solaris/serialver.html) – Maroun Sep 30 '13 at 07:39
  • Duplicated: http://stackoverflow.com/questions/7738162/how-serialversionuid-is-calculated – Averroes Sep 30 '13 at 07:51

2 Answers2

2

Java Object Serialization Specification Docs ,given that algo

The hash value is assembled from the first and second 32-bit values of the SHA-1 message digest. If the result of the message digest, the five 32-bit words H0 H1 H2 H3 H4, is in an array of five int values named sha, the hash value would be computed as follows:

  long hash = ((sha[0] >>> 24) & 0xFF) |
              ((sha[0] >>> 16) & 0xFF) << 8 |
              ((sha[0] >>> 8) & 0xFF) << 16 |
              ((sha[0] >>> 0) & 0xFF) << 24 |
              ((sha[1] >>> 24) & 0xFF) << 32 |
              ((sha[1] >>> 16) & 0xFF) << 40 |
              ((sha[1] >>> 8) & 0xFF) << 48 |
              ((sha[1] >>> 0) & 0xFF) << 56;
Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
2

Eclipse implements the relevant Java spec to compute Serialization ID.

In Eclipse, this is implemented by calculateSerialVersionId method in org.eclipse.jdt.internal.ui.text.correction.SerialVersionHashOperation class.

krishnakumarp
  • 8,967
  • 3
  • 49
  • 55