test/tools/javac/lambda/MethodReference41.java

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

author
dbuck
date
Tue, 29 Mar 2016 10:48:49 +0000
changeset 3102
e74dd6df4d4c
parent 2015
a4b9a8859e58
child 2525
2eb010b6cb22
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 8003280
     4  * @summary Add lambda tests
     5  *  check that diamond inference is applied when using raw constructor reference qualifier
     6  * @compile/fail/ref=MethodReference41.out -XDrawDiagnostics MethodReference41.java
     7  */
     9 public class MethodReference41 {
    11     interface SAM1 {
    12        void m(String s);
    13     }
    15     interface SAM2 {
    16        void m(Integer s);
    17     }
    19     interface SAM3 {
    20        void m(Object o);
    21     }
    23     static class Foo<X extends Number> {
    24         Foo(X x) { }
    25     }
    27     static void m1(SAM1 s) { }
    29     static void m2(SAM2 s) { }
    31     static void m3(SAM3 s) { }
    33     static void m4(SAM1 s) { }
    34     static void m4(SAM2 s) { }
    35     static void m4(SAM3 s) { }
    37     public static void main(String[] args) {
    38         m1(Foo::new);
    39         m2(Foo::new);
    40         m3(Foo::new);
    41         m4(Foo::new);
    42     }
    43 }

mercurial