test/tools/javac/CloneableProblem.java

changeset 0
959103a6100f
child 2525
2eb010b6cb22
equal deleted inserted replaced
-1:000000000000 0:959103a6100f
1 /*
2 * Copyright (c) 1997, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 4047816
27 * @summary certain inheritance patterns involving methods defined in
28 * Object used to cause spurious error messages.
29 * @author turnidge
30 *
31 * @compile CloneableProblem.java
32 */
33
34 interface A extends Cloneable
35 {
36 public Object clone() throws CloneNotSupportedException;
37 }
38 interface B extends A
39 { }
40 interface C extends A
41 { }
42 interface D extends B, C
43 { }
44
45 public class CloneableProblem implements D
46 {
47 private int i;
48 public CloneableProblem(int i)
49 {
50 this.i = i;
51 }
52 public Object clone()
53 {
54 CloneableProblem theCloneableProblem = null;
55 try
56 {
57 theCloneableProblem = (CloneableProblem) super.clone();
58 theCloneableProblem.i = i;
59 }
60 catch (CloneNotSupportedException cnse)
61 { }
62 return theCloneableProblem;
63 }
64 public static void main(String argv[])
65 {
66 try
67 {
68 A a0 = new CloneableProblem(0);
69 A a1 = (A) a0.clone();
70 B b0 = new CloneableProblem(0);
71 B b1 = (B) b0.clone();
72 C c0 = new CloneableProblem(0);
73 C c1 = (C) c0.clone();
74 D d0 = new CloneableProblem(0);
75 D d1 = (D) d0.clone();
76 }
77 catch (CloneNotSupportedException cnse)
78 { }
79 }
80 }

mercurial