diff -r f76cab33bee3 -r 8f9fc5d876e4 langtools/test/tools/javac/lambda/TargetType63.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/lambda/TargetType63.java Wed Jul 17 14:04:01 2013 +0100 @@ -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) + } +}