1/*
2 * @test /nodynamiccopyright/
3 * @bug 8022316
4 * @summary Generic throws, overriding and method reference
5 * @compile/fail/ref=CompilerErrorGenericThrowPlusMethodRefTest.out -XDrawDiagnostics CompilerErrorGenericThrowPlusMethodRefTest.java
6 */
7
8@SuppressWarnings("unchecked")
9public class CompilerErrorGenericThrowPlusMethodRefTest {
10    interface SAM11 {
11        public <E extends Throwable> void foo() throws E ;
12    }
13
14    interface SAM12 extends SAM11{
15        @Override
16        public void foo() throws Throwable;
17    }
18
19    public void boo() throws RuntimeException {}
20
21    static void test1() {
22        try {
23            SAM12 s2 = new CompilerErrorGenericThrowPlusMethodRefTest()::boo;
24            s2.foo();
25        } catch(Throwable ex) {}
26    }
27
28    static void test2() {
29        SAM11 s1 = null;
30        s1.<Exception>foo();
31        s1.<RuntimeException>foo();
32    }
33
34    interface SAM21 {
35        <E extends Exception> void m(E arg) throws E;
36    }
37
38    interface SAM22 {
39        <F extends Exception> void m(F arg) throws F;
40    }
41
42    interface SAM23 extends SAM21, SAM22 {}
43
44    public <E extends Exception> void bar(E e) throws E {}
45
46    static <E extends Exception> void test3(E e) {
47        try {
48            SAM23 s2 = new CompilerErrorGenericThrowPlusMethodRefTest()::bar;
49            s2.m(e);
50        } catch(Exception ex) {}
51    }
52
53}
54