<p>In Java, static and transient fields are not serialized. However, I found out that initialization of static fields causes the generated serialVersionUID to be changed. For example, <code>static int MYINT = 3;</code> causes the serialVersionUID to change. In this example, it makes sense because different versions of the class would get different initial values. Why does any initialization change the serialVersionUID? For example, <code>static String MYSTRING = System.getProperty("foo");</code> also causes the serialVersionUID to change.</p>

<p>To be specific, my question is why does initialization with a method cause the serialVersionUID to change. The problem I hit is that I added a new static field that was initialized with a system property value (getProperty). That change caused a serialization exception on a remote call.</p>

If I read the spec correctly the automatic
```
serialVersionUID
```
shouldn't change if you change the value of a static of transient field. Take a look at
Chapter 5.6
of the Spec.
However
, if you think about this a bit - you start by serializing an object that has
```
static int MYINT = 3
```
, when you then deserialize the class you expect to get the same object back, that is, with
```
MYINT = 3
```
. So, if you change the static initialization you would expect the
```
serialVersionUID
```
to change because you can't get the same object back again.
Anyways
, keep this in all your serializable classes and you can control the
```
serialVersionUID
```
:
```
```
private static final long serialVersionUID = 7526472295622776147L;
```
```