langtools/test/tools/javac/lambda/privateMethodReferences/ThirdClass.java
author rfield
Wed, 23 Oct 2013 10:28:10 -0700
changeset 21493 d3f44b144a76
permissions -rw-r--r--
8022720: Method refeerences - private method should be accessible (nested classes) Reviewed-by: jjg, ksrini
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21493
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
     1
/*
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
     4
 *
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
     8
 *
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    13
 * accompanied this code).
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    14
 *
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    18
 *
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    21
 * questions.
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    22
 */
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    23
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    24
/*
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    25
 * @test
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    26
 * @bug 8022720
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    27
 * @summary private method should be accessible (nested classes)
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    28
 * @run main ThirdClass
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    29
 */
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    30
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    31
interface MyFunctionalInterface3 {
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    32
    int invokeMethodReference();
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    33
}
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    34
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    35
public class ThirdClass {
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    36
    public static void main(String[] args) throws Exception {
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    37
        MethodInvoker.invoke();
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    38
        System.out.println("Passed!");
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    39
    }
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    40
    static class MethodSupplier {
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    41
        private int m() {
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    42
            return 999;
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    43
        }
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    44
    }
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    45
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    46
    static class MethodInvoker {
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    47
        public static void invoke() throws Exception {
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    48
            MethodSupplier ms = new MethodSupplier();
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    49
            MyFunctionalInterface3 fi = ms::m;
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    50
            if (fi.invokeMethodReference() != 999) {
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    51
                throw new Exception();
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    52
            }
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    53
        }
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    54
    }
d3f44b144a76 8022720: Method refeerences - private method should be accessible (nested classes)
rfield
parents:
diff changeset
    55
}