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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7031
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
     1
Testcase shows default deserialisation of the Victim having two values for the same field. 
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
     2
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
     3
Probably requires dual core to run successfully. 
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
     4
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
     5
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.
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
     6
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
     7
Typical output:
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
     8
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
     9
Victim@1551f60 BBBB
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
    10
Victim@1551f60 AAAA
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
    11
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
    12
The output when its fixed is, 
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
    13
Victim@1975b59 AAAA
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
    14
Victim@1975b59 AAAA  - The value is retained
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
    15
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
    16
and when it is not fixed, it shows something like 
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
    17
Victim@173a10f AAAA
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
    18
Victim@173a10f BBBB - the value of the object gets set again and hence is different. This is a bug
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
    19
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
    20
Look at the 
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
    21
AAAA AAAA 
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
    22
and 
d77ff2048ad5 6966692: defaultReadObject can set a field multiple times
skoppar
parents:
diff changeset
    23
AAAA BBBB