--- old/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java 2018-05-08 21:33:09.923925444 -0400 +++ new/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java 2018-05-08 21:33:08.311831935 -0400 @@ -93,8 +93,7 @@ private final Name dollarCloseResource; private final Types types; private final boolean debugLower; - private final boolean disableAccessors; - private final boolean disablePrivateAccessors; + private final boolean disableProtectedAccessors; // experimental private final PkgInfo pkginfoOpt; protected Lower(Context context) { @@ -123,8 +122,7 @@ Options options = Options.instance(context); debugLower = options.isSet("debuglower"); pkginfoOpt = PkgInfo.get(options); - disableAccessors = options.isSet("disableAccessors"); - disablePrivateAccessors = options.isSet("disablePrivateAccessors"); + disableProtectedAccessors = options.isSet("disableProtectedAccessors"); } /** The currently enclosing class. @@ -1010,8 +1008,7 @@ /** Do we need an access method to reference private symbol? */ boolean needsPrivateAccess(Symbol sym) { - if (disableAccessors || disablePrivateAccessors || - target.hasNestmateAccess()) { + if (target.hasNestmateAccess()) { return false; } if ((sym.flags() & PRIVATE) == 0 || sym.owner == currentClass) { @@ -1028,7 +1025,7 @@ /** Do we need an access method to reference symbol in other package? */ boolean needsProtectedAccess(Symbol sym, JCTree tree) { - if (disableAccessors) return false; + if (disableProtectedAccessors) return false; if ((sym.flags() & PROTECTED) == 0 || sym.owner.owner == currentClass.owner || // fast special case sym.packge() == currentClass.packge()) --- old/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java 2018-05-08 21:33:14.876212701 -0400 +++ new/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java 2018-05-08 21:33:13.264119192 -0400 @@ -1881,8 +1881,6 @@ } poolbuf.appendChar(target.majorVersion); - // TODO: Need to skip this for Modules - not sure where - // that check really belongs, but this works. if (c.owner.kind != MDL) { if (target.hasNestmateAccess()) { acount += writeNestMembersIfNeeded(c); --- old/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java 2018-05-08 21:33:19.220464687 -0400 +++ new/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java 2018-05-08 21:33:17.620371874 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -126,7 +126,7 @@ genCrt = options.isSet(XJCOV); debugCode = options.isSet("debug.code"); allowBetterNullChecks = target.hasObjects(); - virtualizePrivateAccess = options.isSet("virtualizePrivateAccess"); + disableVirtualizedPrivateInvoke = options.isSet("disableVirtualizedPrivateInvoke"); pool = new Pool(types); // ignore cldc because we cannot have both stackmap formats @@ -141,7 +141,7 @@ private final boolean genCrt; private final boolean debugCode; private final boolean allowBetterNullChecks; - private boolean virtualizePrivateAccess; + private boolean disableVirtualizedPrivateInvoke; /** Code buffer, set by genMethod. */ @@ -2072,8 +2072,9 @@ //where private boolean nonVirtualForPrivateAccess(Symbol sym) { - return !(virtualizePrivateAccess || target.hasVirtualPrivateInvoke()) && - ((sym.flags() & PRIVATE) != 0); + boolean useVirtual = target.hasVirtualPrivateInvoke() && + !disableVirtualizedPrivateInvoke; + return !useVirtual && ((sym.flags() & PRIVATE) != 0); } public void visitSelect(JCFieldAccess tree) { --- old/test/jdk/java/lang/invoke/SpecialInterfaceCall.java 2018-05-08 21:33:23.608719230 -0400 +++ new/test/jdk/java/lang/invoke/SpecialInterfaceCall.java 2018-05-08 21:33:22.004626182 -0400 @@ -25,8 +25,8 @@ * @test * @bug 8200167 8010319 * @summary Test direct and MethodHandle access to interface methods using invokespecial semantics - * @comment This must be compiled for JDK 10 so that invokespecial is generated. - * @compile -source 10 -target 10 SpecialInterfaceCall.java + * @comment This must be compiled so invokespecial is used + * @compile -XDdisableVirtualizedPrivateInvoke SpecialInterfaceCall.java * @compile SpecialInterfaceCallI4.jasm * @run main/othervm -Xint SpecialInterfaceCall * @run main/othervm -Xbatch -XX:+TieredCompilation -XX:TieredStopAtLevel=1 SpecialInterfaceCall --- old/test/langtools/tools/javac/valhalla/nestmate/CheckNestmateAttrs.java 2018-05-08 21:33:29.353052424 -0400 +++ /dev/null 2018-04-28 00:26:07.190086997 -0400 @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @summary Smoke test for nestmate classfile support - * @run main CheckNestmateAttrs - * @modules - * jdk.compiler - * jdk.jdeps/com.sun.tools.javap - */ - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.nio.file.Paths; - -public class CheckNestmateAttrs { - - private void test() { } - - class Inner { - void m() { - class LocalInner { - void testInner() { - test(); - } - } - } - } - - static class Nested { - void s() { - class LocalNested { } - } - } - - public static void main(String[] args) { - new CheckNestmateAttrs().run(); - } - - void run() { - String [] params = new String [] { "-v", - Paths.get(System.getProperty("test.classes"), - "CheckNestmateAttrs.class").toString() }; - runCheck(params, new String [] { - "NestMembers:" + - " CheckNestmateAttrs$Nested" + - " CheckNestmateAttrs$Nested$1LocalNested" + - " CheckNestmateAttrs$Inner" + - " CheckNestmateAttrs$Inner$1LocalInner" - }); - - params = new String [] { "-v", - Paths.get(System.getProperty("test.classes"), - "CheckNestmateAttrs$Inner.class").toString() }; - - runCheck(params, new String [] { "NestHost: class CheckNestmateAttrs" }); - - params = new String [] { "-v", - Paths.get(System.getProperty("test.classes"), - "CheckNestmateAttrs$Nested.class").toString() }; - - runCheck(params, new String [] { "NestHost: class CheckNestmateAttrs" }); - - params = new String [] { "-v", - Paths.get(System.getProperty("test.classes"), - "CheckNestmateAttrs$Inner$1LocalInner.class").toString() }; - - runCheck(params, new String [] { - "NestHost: class CheckNestmateAttrs", - "0: aload_0", - "1: getfield #1 // Field this$1:LCheckNestmateAttrs$Inner;", - "4: getfield #3 // Field CheckNestmateAttrs$Inner.this$0:LCheckNestmateAttrs;", - "7: invokevirtual #4 // Method CheckNestmateAttrs.test:()V", - "10: return" - }); - - params = new String [] { "-v", - Paths.get(System.getProperty("test.classes"), - "CheckNestmateAttrs$Nested$1LocalNested.class").toString() }; - - runCheck(params, new String [] { "NestHost: class CheckNestmateAttrs" }); - } - - void runCheck(String [] params, String [] expectedOut) { - StringWriter s; - String out; - - try (PrintWriter pw = new PrintWriter(s = new StringWriter())) { - com.sun.tools.javap.Main.run(params, pw); - out = s.toString(); - } - for (String eo: expectedOut) { - if (!out.contains(eo)) { - System.out.println("Actual output: " + out); - throw new AssertionError("Missing output: " + eo); - } - } - } -} --- /dev/null 2018-04-28 00:26:07.190086997 -0400 +++ new/test/langtools/tools/javac/nestmates/CheckNestmateAttrs.java 2018-05-08 21:33:26.376879796 -0400 @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary Smoke test for nestmate classfile support + * @run main CheckNestmateAttrs + * @modules + * jdk.compiler + * jdk.jdeps/com.sun.tools.javap + */ + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.file.Paths; + +public class CheckNestmateAttrs { + + private void test() { } + + class Inner { + void m() { + class LocalInner { + void testInner() { + test(); + } + } + } + } + + static class Nested { + void s() { + class LocalNested { } + } + } + + public static void main(String[] args) { + new CheckNestmateAttrs().run(); + } + + void run() { + String [] params = new String [] { "-v", + Paths.get(System.getProperty("test.classes"), + "CheckNestmateAttrs.class").toString() }; + runCheck(params, new String [] { + "NestMembers:" + + " CheckNestmateAttrs$Nested" + + " CheckNestmateAttrs$Nested$1LocalNested" + + " CheckNestmateAttrs$Inner" + + " CheckNestmateAttrs$Inner$1LocalInner" + }); + + params = new String [] { "-v", + Paths.get(System.getProperty("test.classes"), + "CheckNestmateAttrs$Inner.class").toString() }; + + runCheck(params, new String [] { "NestHost: class CheckNestmateAttrs" }); + + params = new String [] { "-v", + Paths.get(System.getProperty("test.classes"), + "CheckNestmateAttrs$Nested.class").toString() }; + + runCheck(params, new String [] { "NestHost: class CheckNestmateAttrs" }); + + params = new String [] { "-v", + Paths.get(System.getProperty("test.classes"), + "CheckNestmateAttrs$Inner$1LocalInner.class").toString() }; + + runCheck(params, new String [] { + "NestHost: class CheckNestmateAttrs", + "0: aload_0", + "1: getfield #1 // Field this$1:LCheckNestmateAttrs$Inner;", + "4: getfield #3 // Field CheckNestmateAttrs$Inner.this$0:LCheckNestmateAttrs;", + "7: invokevirtual #4 // Method CheckNestmateAttrs.test:()V", + "10: return" + }); + + params = new String [] { "-v", + Paths.get(System.getProperty("test.classes"), + "CheckNestmateAttrs$Nested$1LocalNested.class").toString() }; + + runCheck(params, new String [] { "NestHost: class CheckNestmateAttrs" }); + } + + void runCheck(String [] params, String [] expectedOut) { + StringWriter s; + String out; + + try (PrintWriter pw = new PrintWriter(s = new StringWriter())) { + com.sun.tools.javap.Main.run(params, pw); + out = s.toString(); + } + for (String eo: expectedOut) { + if (!out.contains(eo)) { + System.out.println("Actual output: " + out); + throw new AssertionError("Missing output: " + eo); + } + } + } +}