jdk/test/java/io/Serializable/6966692/README
author skoppar
Tue, 28 Sep 2010 01:13:22 -0700
changeset 7031 d77ff2048ad5
permissions -rw-r--r--
6966692: defaultReadObject can set a field multiple times Reviewed-by: hawtin

Testcase shows default deserialisation of the Victim having two values for the same field. 

Probably requires dual core to run successfully. 

Reading thread is warmed up so that it can easily win the race for the demonstration, but this means we need to make the field volatile.

Typical output:

Victim@1551f60 BBBB
Victim@1551f60 AAAA

The output when its fixed is, 
Victim@1975b59 AAAA
Victim@1975b59 AAAA  - The value is retained

and when it is not fixed, it shows something like 
Victim@173a10f AAAA
Victim@173a10f BBBB - the value of the object gets set again and hence is different. This is a bug

Look at the 
AAAA AAAA 
and 
AAAA BBBB