equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
33 */ |
33 */ |
34 |
34 |
35 import java.io.*; |
35 import java.io.*; |
36 |
36 |
37 class A implements Serializable { |
37 class A implements Serializable { |
|
38 private static final long serialVersionUID = 1L; |
|
39 |
38 Object writeReplace() throws ObjectStreamException { |
40 Object writeReplace() throws ObjectStreamException { |
39 return new B(); |
41 return new B(); |
40 } |
42 } |
41 } |
43 } |
42 |
44 |
43 class B implements Serializable { |
45 class B implements Serializable { |
|
46 private static final long serialVersionUID = 1L; |
|
47 |
44 Object writeReplace() throws ObjectStreamException { |
48 Object writeReplace() throws ObjectStreamException { |
45 return new C(); |
49 return new C(); |
46 } |
50 } |
47 } |
51 } |
48 |
52 |
49 class C implements Serializable { |
53 class C implements Serializable { |
|
54 private static final long serialVersionUID = 1L; |
50 |
55 |
51 static int writeReplaceCalled = 0; |
56 static int writeReplaceCalled = 0; |
52 |
57 |
53 Object writeReplace() throws ObjectStreamException { |
58 Object writeReplace() throws ObjectStreamException { |
54 writeReplaceCalled++; |
59 writeReplaceCalled++; |
59 return new D(); |
64 return new D(); |
60 } |
65 } |
61 } |
66 } |
62 |
67 |
63 class D implements Serializable { |
68 class D implements Serializable { |
|
69 private static final long serialVersionUID = 1L; |
|
70 |
64 Object readResolve() throws ObjectStreamException { |
71 Object readResolve() throws ObjectStreamException { |
65 throw new Error("readResolve() called more than once"); |
72 throw new Error("readResolve() called more than once"); |
66 } |
73 } |
67 } |
74 } |
68 |
75 |