author | mcimadamore |
Wed, 17 Jul 2013 14:04:01 +0100 | |
changeset 18909 | 8f9fc5d876e4 |
permissions | -rw-r--r-- |
18909
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
1 |
/* |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
2 |
* @test /nodynamiccopyright/ |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
3 |
* @summary smoke test for inference of throws type variables |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
4 |
* @compile/fail/ref=TargetType63.out -XDrawDiagnostics TargetType63.java |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
5 |
*/ |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
6 |
class TargetType63 { |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
7 |
|
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
8 |
interface F<T extends Throwable> { |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
9 |
void m() throws T; |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
10 |
} |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
11 |
|
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
12 |
void g1() { } |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
13 |
void g2() throws ClassNotFoundException { } |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
14 |
void g3() throws Exception { } |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
15 |
|
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
16 |
<Z extends Throwable> void m1(F<Z> fz) throws Z { } |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
17 |
<Z extends ClassNotFoundException> void m2(F<Z> fz) throws Z { } |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
18 |
|
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
19 |
void test1() { |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
20 |
m1(()->{ }); //ok (Z = RuntimeException) |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
21 |
m1(this::g1); //ok (Z = RuntimeException) |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
22 |
} |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
23 |
|
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
24 |
void test2() { |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
25 |
m2(()->{ }); //fail (Z = ClassNotFoundException) |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
26 |
m2(this::g1); //fail (Z = ClassNotFoundException) |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
27 |
} |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
28 |
|
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
29 |
void test3() { |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
30 |
m1(()->{ throw new ClassNotFoundException(); }); //fail (Z = ClassNotFoundException) |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
31 |
m1(this::g2); //fail (Z = ClassNotFoundException) |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
32 |
m2(()->{ throw new ClassNotFoundException(); }); //fail (Z = ClassNotFoundException) |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
33 |
m2(this::g2); //fail (Z = ClassNotFoundException) |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
34 |
} |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
35 |
|
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
36 |
void test4() { |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
37 |
m1(()->{ throw new Exception(); }); //fail (Z = Exception) |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
38 |
m1(this::g3); //fail (Z = Exception) |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
39 |
} |
8f9fc5d876e4
8012242: Lambda compatibility and checked exceptions
mcimadamore
parents:
diff
changeset
|
40 |
} |