test/tools/javac/lambda/MethodReference09.java

changeset 0
959103a6100f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/lambda/MethodReference09.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,25 @@
     1.4 +/*
     1.5 + * @test /nodynamiccopyright/
     1.6 + * @bug 8003280
     1.7 + * @summary Add lambda tests
     1.8 + *  check that non static members cannot be referenced from a method reference qualifier
     1.9 + * @author  Maurizio Cimadamore
    1.10 + * @compile/fail/ref=MethodReference09.out -XDrawDiagnostics MethodReference09.java
    1.11 + */
    1.12 +
    1.13 +class MethodReference09 {
    1.14 +    interface SAM {
    1.15 +       String m(Foo f);
    1.16 +    }
    1.17 +
    1.18 +    static class Foo<X> {
    1.19 +       String getX() { return null; }
    1.20 +
    1.21 +       Foo<X> getThis() { return this; }
    1.22 +
    1.23 +       static void test() {
    1.24 +          SAM s1 = Foo.getThis()::getX;
    1.25 +          SAM s2 = this::getX;
    1.26 +       }
    1.27 +    }
    1.28 +}

mercurial