test/tools/javac/lambda/TargetType63.java

Thu, 26 Mar 2015 11:34:50 +0100

author
jlahoda
date
Thu, 26 Mar 2015 11:34:50 +0100
changeset 2734
ba758e1ffa69
parent 0
959103a6100f
permissions
-rw-r--r--

8054220: Debugger doesn't show variables *outside* lambda
8058227: Debugger has no access to outer variables inside Lambda
Summary: Put local variables captured by lambda into the lambda method's LocalVariableTable.
Reviewed-by: mcimadamore, rfield

     1 /*
     2  * @test /nodynamiccopyright/
     3  * @summary smoke test for inference of throws type variables
     4  * @compile/fail/ref=TargetType63.out -XDrawDiagnostics TargetType63.java
     5  */
     6 class TargetType63 {
     8     interface F<T extends Throwable> {
     9         void m() throws T;
    10     }
    12     void g1() { }
    13     void g2() throws ClassNotFoundException { }
    14     void g3() throws Exception { }
    16     <Z extends Throwable> void m1(F<Z> fz) throws Z { }
    17     <Z extends ClassNotFoundException> void m2(F<Z> fz) throws Z { }
    19     void test1() {
    20         m1(()->{ }); //ok (Z = RuntimeException)
    21         m1(this::g1); //ok (Z = RuntimeException)
    22     }
    24     void test2() {
    25         m2(()->{ }); //fail (Z = ClassNotFoundException)
    26         m2(this::g1); //fail (Z = ClassNotFoundException)
    27     }
    29     void test3() {
    30         m1(()->{ throw new ClassNotFoundException(); }); //fail (Z = ClassNotFoundException)
    31         m1(this::g2); //fail (Z = ClassNotFoundException)
    32         m2(()->{ throw new ClassNotFoundException(); }); //fail (Z = ClassNotFoundException)
    33         m2(this::g2); //fail (Z = ClassNotFoundException)
    34     }
    36     void test4() {
    37         m1(()->{ throw new Exception(); }); //fail (Z = Exception)
    38         m1(this::g3); //fail (Z = Exception)
    39     }
    40 }

mercurial