test/tools/javac/lambda/LambdaScope05.java

Tue, 29 Mar 2016 10:48:49 +0000

author
dbuck
date
Tue, 29 Mar 2016 10:48:49 +0000
changeset 3102
e74dd6df4d4c
parent 0
959103a6100f
permissions
-rw-r--r--

8143647: Javac compiles method reference that allows results in an IllegalAccessError
Summary: Lambda implementation method synthesized by javac should not mention inaccessible types.
Reviewed-by: mcimadamore

     1 /*
     2  * @test /nodynamiccopyright/
     3  * @bug 8015648
     4  * @summary Duplicate variable in lambda causes javac crash
     5  * @compile/fail/ref=LambdaScope05.out -XDrawDiagnostics LambdaScope05.java
     6  */
     8 class LambdaScope05 {
     9     interface VoidFun1 {
    10         void m(int i);
    11     }
    13     static Runnable r1 = () -> { VoidFun1 p = p -> { }; };
    14     Runnable r2 = () -> { VoidFun1 p = p -> { }; };
    16     static {
    17         Runnable r = () -> { VoidFun1 p = p -> { }; };
    18     }
    20     {
    21         Runnable r = () -> { VoidFun1 p = p -> { }; };
    22     }
    24     static void m_static() {
    25         Runnable r = () -> { VoidFun1 p = p -> { }; };
    26     }
    28     void m() {
    29         Runnable r = () -> { VoidFun1 p = p -> { }; };
    30     }
    31 }

mercurial