|
1 /* |
|
2 * Copyright (c) 2014, 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 8041663 |
|
27 */ |
|
28 |
|
29 public class AmbiguityErrorTest { |
|
30 |
|
31 public interface A { } |
|
32 |
|
33 public interface B extends A { } |
|
34 |
|
35 public interface C { |
|
36 A m(B strategy); |
|
37 } |
|
38 |
|
39 public interface D { |
|
40 A m(A strategy); |
|
41 A m(B strategy); |
|
42 } |
|
43 |
|
44 public interface T1 extends C, D { } |
|
45 public interface T2 extends D, C { } |
|
46 |
|
47 int count; |
|
48 |
|
49 class T1Impl implements T1, T2 { |
|
50 public A m(B strategy) { |
|
51 count++; |
|
52 return null; |
|
53 } |
|
54 public A m(A strategy) { |
|
55 throw new AssertionError("Should not get here."); |
|
56 } |
|
57 } |
|
58 |
|
59 public static void main(String... args) { |
|
60 new AmbiguityErrorTest().test(); |
|
61 } |
|
62 |
|
63 void test() { |
|
64 T1 t1 = new T1Impl(); |
|
65 T2 t2 = new T1Impl(); |
|
66 final B b = new B() { }; |
|
67 t1.m(b); |
|
68 t2.m(b); |
|
69 |
|
70 if (count != 2) { |
|
71 throw new IllegalStateException("Did not call the methods properly"); |
|
72 } |
|
73 } |
|
74 |
|
75 } |