NameClashTest.java revision 3067:4b374a9b4b22
1/* 2 * Copyright (c) 2015 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 8074803 27 * @summary Incorrect name clash error 28 * 29 * @compile NameClashTest.java 30 */ 31 32public class NameClashTest { 33 34 String log = ""; 35 36 interface A1 { 37 A1 m(String s); 38 } 39 40 abstract class A2 implements A1 { 41 public abstract A2 m(String s); 42 } 43 44 interface B1 { 45 A1 m(String s); 46 } 47 48 interface B2 extends B1 { 49 A2 m(String s); 50 } 51 52 abstract class C extends A2 implements B2 {} 53 54 class D extends C { 55 56 public A2 m(String s) { 57 log += s; 58 return null; 59 } 60 } 61 62 public static void main(String[] args) { 63 NameClashTest nct = new NameClashTest(); 64 A1 a1 = nct.new D(); 65 a1.m("A1.m "); 66 A2 a2 = nct.new D(); 67 a2.m("A2.m "); 68 B1 b1 = nct.new D(); 69 b1.m("B1.m "); 70 B2 b2 = nct.new D(); 71 b2.m("B2.m "); 72 C c = nct.new D(); 73 c.m("C.m "); 74 D d = nct.new D(); 75 d.m("D.m "); 76 if (!nct.log.equals("A1.m A2.m B1.m B2.m C.m D.m ")) 77 throw new AssertionError("unexpected output: " + nct.log); 78 } 79} 80