author | sogoel |
Thu, 05 Jun 2014 10:57:10 -0700 | |
changeset 24797 | 850ebd4d80a7 |
parent 19655 | 39cf56516b13 |
child 32337 | c9d3ab9f601c |
permissions | -rw-r--r-- |
19655
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
1 |
/* |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
4 |
* |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
10 |
* |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
15 |
* accompanied this code). |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
16 |
* |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
20 |
* |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
23 |
* questions. |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
24 |
*/ |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
25 |
|
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
26 |
/* |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
27 |
* @test |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
28 |
* @bug 8022316 |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
29 |
* @summary Generic throws, overriding and method reference |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
30 |
* @compile/fail/ref=CompilerErrorGenericThrowPlusMethodRefTest.out -XDrawDiagnostics CompilerErrorGenericThrowPlusMethodRefTest.java |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
31 |
*/ |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
32 |
|
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
33 |
@SuppressWarnings("unchecked") |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
34 |
public class CompilerErrorGenericThrowPlusMethodRefTest { |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
35 |
interface SAM11 { |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
36 |
public <E extends Throwable> void foo() throws E ; |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
37 |
} |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
38 |
|
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
39 |
interface SAM12 extends SAM11{ |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
40 |
@Override |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
41 |
public void foo() throws Throwable; |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
42 |
} |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
43 |
|
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
44 |
public void boo() throws RuntimeException {} |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
45 |
|
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
46 |
static void test1() { |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
47 |
try { |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
48 |
SAM12 s2 = new CompilerErrorGenericThrowPlusMethodRefTest()::boo; |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
49 |
s2.foo(); |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
50 |
} catch(Throwable ex) {} |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
51 |
} |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
52 |
|
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
53 |
static void test2() { |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
54 |
SAM11 s1 = null; |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
55 |
s1.<Exception>foo(); |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
56 |
s1.<RuntimeException>foo(); |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
57 |
} |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
58 |
|
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
59 |
interface SAM21 { |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
60 |
<E extends Exception> void m(E arg) throws E; |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
61 |
} |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
62 |
|
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
63 |
interface SAM22 { |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
64 |
<F extends Exception> void m(F arg) throws F; |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
65 |
} |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
66 |
|
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
67 |
interface SAM23 extends SAM21, SAM22 {} |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
68 |
|
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
69 |
public <E extends Exception> void bar(E e) throws E {} |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
70 |
|
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
71 |
static <E extends Exception> void test3(E e) { |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
72 |
try { |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
73 |
SAM23 s2 = new CompilerErrorGenericThrowPlusMethodRefTest()::bar; |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
74 |
s2.m(e); |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
75 |
} catch(Exception ex) {} |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
76 |
} |
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
77 |
|
39cf56516b13
8022316: Generic throws, overriding and method reference
vromero
parents:
diff
changeset
|
78 |
} |