diff -r 000000000000 -r 959103a6100f test/tools/javac/lambda/TargetType63.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/TargetType63.java Wed Apr 27 01:34:52 2016 +0800 @@ -0,0 +1,40 @@ +/* + * @test /nodynamiccopyright/ + * @summary smoke test for inference of throws type variables + * @compile/fail/ref=TargetType63.out -XDrawDiagnostics TargetType63.java + */ +class TargetType63 { + + interface F { + void m() throws T; + } + + void g1() { } + void g2() throws ClassNotFoundException { } + void g3() throws Exception { } + + void m1(F fz) throws Z { } + void m2(F fz) throws Z { } + + void test1() { + m1(()->{ }); //ok (Z = RuntimeException) + m1(this::g1); //ok (Z = RuntimeException) + } + + void test2() { + m2(()->{ }); //fail (Z = ClassNotFoundException) + m2(this::g1); //fail (Z = ClassNotFoundException) + } + + void test3() { + m1(()->{ throw new ClassNotFoundException(); }); //fail (Z = ClassNotFoundException) + m1(this::g2); //fail (Z = ClassNotFoundException) + m2(()->{ throw new ClassNotFoundException(); }); //fail (Z = ClassNotFoundException) + m2(this::g2); //fail (Z = ClassNotFoundException) + } + + void test4() { + m1(()->{ throw new Exception(); }); //fail (Z = Exception) + m1(this::g3); //fail (Z = Exception) + } +}