test/tools/javac/lambda/methodReferenceExecution/MethodReferencePackagePrivateQualifier.java

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

author
dbuck
date
Tue, 29 Mar 2016 10:48:49 +0000
changeset 3102
e74dd6df4d4c
parent 3076
30f0dce3fbd3
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

aefimov@3076 1 /*
aefimov@3076 2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
aefimov@3076 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aefimov@3076 4 *
aefimov@3076 5 * This code is free software; you can redistribute it and/or modify it
aefimov@3076 6 * under the terms of the GNU General Public License version 2 only, as
aefimov@3076 7 * published by the Free Software Foundation.
aefimov@3076 8 *
aefimov@3076 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aefimov@3076 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aefimov@3076 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aefimov@3076 12 * version 2 for more details (a copy is included in the LICENSE file that
aefimov@3076 13 * accompanied this code).
aefimov@3076 14 *
aefimov@3076 15 * You should have received a copy of the GNU General Public License version
aefimov@3076 16 * 2 along with this work; if not, write to the Free Software Foundation,
aefimov@3076 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aefimov@3076 18 *
aefimov@3076 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aefimov@3076 20 * or visit www.oracle.com if you need additional information or have any
aefimov@3076 21 * questions.
aefimov@3076 22 */
aefimov@3076 23
aefimov@3076 24 /**
aefimov@3076 25 * @test
aefimov@3076 26 * @bug 8068254
aefimov@3076 27 * @summary Method reference uses wrong qualifying type
aefimov@3076 28 * @author srikanth
aefimov@3076 29 * @run main MethodReferencePackagePrivateQualifier
aefimov@3076 30 */
aefimov@3076 31 import pkg.B;
aefimov@3076 32 public class MethodReferencePackagePrivateQualifier {
aefimov@3076 33 public static void main(String... args) {
aefimov@3076 34 pkg.B.m();
aefimov@3076 35 Runnable r = pkg.B::m;
aefimov@3076 36 r.run();
aefimov@3076 37 r = B::m;
aefimov@3076 38 r.run();
aefimov@3076 39 if (!pkg.B.result.equals("A.m()A.m()A.m()"))
aefimov@3076 40 throw new AssertionError("Incorrect result");
aefimov@3076 41 }
aefimov@3076 42 }

mercurial