--- old/test/runtime/Nestmates/membership/TestNestmateMembership.java 2017-09-15 02:59:05.019720945 -0400 +++ new/test/runtime/Nestmates/membership/TestNestmateMembership.java 2017-09-15 02:59:03.159615446 -0400 @@ -25,8 +25,7 @@ * @test * @bug 8046171 * @summary Test the various rules for nest members and nest-tops - * @compile -XDdisablePrivateAccessors - * TestNestmateMembership.java + * @compile TestNestmateMembership.java * PackagedNestTop.java * PackagedNestTop2.java * NotAMember2.java --- old/test/runtime/Nestmates/privateConstructors/TestConstructorHierarchy.java 2017-09-15 02:59:10.572035855 -0400 +++ new/test/runtime/Nestmates/privateConstructors/TestConstructorHierarchy.java 2017-09-15 02:59:08.719930810 -0400 @@ -26,7 +26,7 @@ * @bug 8046171 * @summary Test access to private constructors in the hierarchy that are * outside the nest - * @compile -XDdisablePrivateAccessors TestConstructorHierarchy.java + * @compile TestConstructorHierarchy.java * @compile ExternalSuper.jcod * ExternalSub.jcod * @run main TestConstructorHierarchy --- old/test/runtime/Nestmates/privateConstructors/TestInvokeSpecial.java 2017-09-15 02:59:16.292360290 -0400 +++ new/test/runtime/Nestmates/privateConstructors/TestInvokeSpecial.java 2017-09-15 02:59:14.348250027 -0400 @@ -26,9 +26,11 @@ * @bug 8046171 * @summary Test access to private constructors between nestmates and nest-top * using different flavours of named nested types that will - * generate invokespecial for the calls - * @compile -XDdisablePrivateAccessors TestInvokeSpecial.java + * generate invokespecial for the calls. The -Xcomp run is a special + * regression test for a compiler assertion that would fire when + * "loading" a nest-top class. * @run main TestInvokeSpecial + * @run main/othervm -Xcomp TestInvokeSpecial */ public class TestInvokeSpecial { --- old/test/runtime/Nestmates/privateConstructors/TestMethodHandles.java 2017-09-15 02:59:21.920679510 -0400 +++ new/test/runtime/Nestmates/privateConstructors/TestMethodHandles.java 2017-09-15 02:59:20.056573784 -0400 @@ -26,7 +26,6 @@ * @bug 8046171 * @summary Test access to private constructors between nestmates and nest-top * using different flavours of named nested types using method handles - * @compile -XDdisablePrivateAccessors TestMethodHandles.java * @run main TestMethodHandles */ @@ -55,19 +54,19 @@ // The arg is a dummy for overloading purposes default void doConstruct(TestMethodHandles o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findConstructor(TestMethodHandles.class, NOARG_T); TestMethodHandles obj = (TestMethodHandles) mh.invoke(); obj = (TestMethodHandles) mh.invokeExact(); } default void doConstruct(TestMethodHandles outer, InnerNested o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findConstructor(InnerNested.class, INNER_T); InnerNested obj = (InnerNested) mh.invoke(outer); obj = (InnerNested) mh.invokeExact(outer); } default void doConstruct(StaticNested o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findConstructor(StaticNested.class, NOARG_T); StaticNested obj = (StaticNested) mh.invoke(); obj = (StaticNested) mh.invokeExact(); @@ -82,19 +81,19 @@ // The arg is a dummy for overloading purposes public void doConstruct(TestMethodHandles o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findConstructor(TestMethodHandles.class, NOARG_T); TestMethodHandles obj = (TestMethodHandles) mh.invoke(); obj = (TestMethodHandles) mh.invokeExact(); } public void doConstruct(TestMethodHandles outer, InnerNested o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findConstructor(InnerNested.class, INNER_T); InnerNested obj = (InnerNested) mh.invoke(outer); obj = (InnerNested) mh.invokeExact(outer); } public void doConstruct(StaticNested o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findConstructor(StaticNested.class, NOARG_T); StaticNested obj = (StaticNested) mh.invoke(); obj = (StaticNested) mh.invokeExact(); @@ -109,19 +108,19 @@ // The arg is a dummy for overloading purposes public void doConstruct(TestMethodHandles o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findConstructor(TestMethodHandles.class, NOARG_T); TestMethodHandles obj = (TestMethodHandles) mh.invoke(); obj = (TestMethodHandles) mh.invokeExact(); } public void doConstruct(TestMethodHandles outer, InnerNested o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findConstructor(InnerNested.class, INNER_T); InnerNested obj = (InnerNested) mh.invoke(outer); obj = (InnerNested) mh.invokeExact(outer); } public void doConstruct(StaticNested o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findConstructor(StaticNested.class, NOARG_T); StaticNested obj = (StaticNested) mh.invoke(); obj = (StaticNested) mh.invokeExact(); @@ -130,7 +129,7 @@ public static void main(String[] args) throws Throwable { // These initial constructions test nest-top access - MethodHandle mh = + MethodHandle mh = lookup().findConstructor(TestMethodHandles.class, NOARG_T); TestMethodHandles o = (TestMethodHandles) mh.invoke(); o = (TestMethodHandles) mh.invokeExact(); --- old/test/runtime/Nestmates/privateFields/TestMethodHandles.java 2017-09-15 02:59:27.488995329 -0400 +++ new/test/runtime/Nestmates/privateFields/TestMethodHandles.java 2017-09-15 02:59:25.612888920 -0400 @@ -26,7 +26,6 @@ * @bug 8046171 * @summary Test access to private fields between nestmates and nest-top * using different flavours of named nested types using method handles - * @compile -XDdisablePrivateAccessors TestMethodHandles.java * @run main TestMethodHandles */ --- old/test/runtime/Nestmates/privateFields/TestPrivateField.java 2017-09-15 02:59:33.057311148 -0400 +++ new/test/runtime/Nestmates/privateFields/TestPrivateField.java 2017-09-15 02:59:31.185204966 -0400 @@ -26,7 +26,6 @@ * @bug 8046171 * @summary Test access to private fields between nestmates and nest-top * using different flavours of named nested types - * @compile -XDdisablePrivateAccessors TestPrivateField.java * @run main TestPrivateField */ --- old/test/runtime/Nestmates/privateFields/TestReflection.java 2017-09-15 02:59:38.597625375 -0400 +++ new/test/runtime/Nestmates/privateFields/TestReflection.java 2017-09-15 02:59:36.741520105 -0400 @@ -26,7 +26,6 @@ * @bug 8046171 * @summary Test access to private fields between nestmates and nest-top * using different flavours of named nested types using core reflection - * @compile -XDdisablePrivateAccessors TestReflection.java * @run main TestReflection */ --- old/test/runtime/Nestmates/privateMethods/TestInvoke.java 2017-09-15 02:59:44.233945049 -0400 +++ new/test/runtime/Nestmates/privateMethods/TestInvoke.java 2017-09-15 02:59:42.297835241 -0400 @@ -26,8 +26,7 @@ * @bug 8046171 * @summary Test access to private methods between nestmates and nest-top * using different flavours of named nested types - * @compile -XDdisablePrivateAccessors TestInvoke.java - * @run main TestInvoke + * @run main TestInvoke */ public class TestInvoke { @@ -113,6 +112,9 @@ // public constructor so we aren't relying on private access public InnerNested() {} + void access_priv() { + TestInvoke.this.priv_invoke(); // check this$0 access + } void access_priv(TestInvoke o) { o.priv_invoke(); } @@ -143,6 +145,7 @@ s.access_priv(new StaticNested()); s.access_priv(intf); + i.access_priv(); i.access_priv(o); i.access_priv(o.new InnerNested()); i.access_priv(s); --- old/test/runtime/Nestmates/privateMethods/TestInvokeErrors.java 2017-09-15 02:59:51.530358880 -0400 +++ new/test/runtime/Nestmates/privateMethods/TestInvokeErrors.java 2017-09-15 02:59:49.662252927 -0400 @@ -27,7 +27,7 @@ * @summary Setup nestmate calls to private methods then use * modified jcod classes to introduce errors. Test with * and without verification enabled - * @compile -XDdisablePrivateAccessors TestInvokeErrors.java + * @compile TestInvokeErrors.java * @compile MissingMethod.jcod * MissingMethodWithSuper.jcod * MissingNestTop.jcod --- old/test/runtime/Nestmates/privateMethods/TestInvokeHierarchy.java 2017-09-15 02:59:57.138676965 -0400 +++ new/test/runtime/Nestmates/privateMethods/TestInvokeHierarchy.java 2017-09-15 02:59:55.226568517 -0400 @@ -27,7 +27,7 @@ * @summary Test access to private methods between nestmates where there * is an inheritance hierarchy and we invoke private methods that * exist in specific classes in the hierarchy. - * @compile -XDdisablePrivateAccessors TestInvokeHierarchy.java + * @compile TestInvokeHierarchy.java * @compile ExternalSuper.jcod ExternalSub.jcod * @run main TestInvokeHierarchy */ --- old/test/runtime/Nestmates/privateMethods/TestMethodHandles.java 2017-09-15 03:00:02.963007303 -0400 +++ new/test/runtime/Nestmates/privateMethods/TestMethodHandles.java 2017-09-15 03:00:00.830886376 -0400 @@ -26,8 +26,7 @@ * @bug 8046171 * @summary Test access to private methods between nestmates and nest-top * using different flavours of named nested types using MethodHandles - * @compile -XDdisablePrivateAccessors TestMethodHandles.java - * @run main TestMethodHandles + * @run main TestMethodHandles */ @@ -50,7 +49,7 @@ // Methods that will access private methods of nestmates void access_priv(TestMethodHandles o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); @@ -58,7 +57,7 @@ checkBadInvoke(mh, mh); // completely wrong type } void access_priv(InnerNested o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); @@ -66,7 +65,7 @@ checkBadInvoke(mh, mh); // completely wrong type } void access_priv(StaticNested o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); @@ -74,7 +73,7 @@ checkBadInvoke(mh, mh); // completely wrong type } void access_priv(StaticIface o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findSpecial(StaticIface.class, "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); @@ -93,7 +92,7 @@ // Methods that will access private methods of nestmates default void access_priv(TestMethodHandles o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, StaticIface.class); mh.invoke(o); mh.invokeExact(o); @@ -101,7 +100,7 @@ checkBadInvoke(mh, mh); // completely wrong type } default void access_priv(InnerNested o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, StaticIface.class); mh.invoke(o); mh.invokeExact(o); @@ -109,7 +108,7 @@ checkBadInvoke(mh, mh); // completely wrong type } default void access_priv(StaticNested o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, StaticIface.class); mh.invoke(o); mh.invokeExact(o); @@ -117,7 +116,7 @@ checkBadInvoke(mh, mh); // completely wrong type } default void access_priv(StaticIface o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findSpecial(StaticIface.class, "priv_invoke", M_T, StaticIface.class); mh.invoke(o); mh.invokeExact(o); @@ -138,7 +137,7 @@ // Methods that will access private methods of nestmates void access_priv(TestMethodHandles o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); @@ -146,7 +145,7 @@ checkBadInvoke(mh, mh); // completely wrong type } void access_priv(InnerNested o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); @@ -154,7 +153,7 @@ checkBadInvoke(mh, mh); // completely wrong type } void access_priv(StaticNested o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); @@ -162,7 +161,7 @@ checkBadInvoke(mh, mh); // completely wrong type } void access_priv(StaticIface o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findSpecial(StaticIface.class, "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); @@ -181,7 +180,7 @@ public InnerNested() {} void access_priv(TestMethodHandles o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); @@ -189,7 +188,7 @@ checkBadInvoke(mh, mh); // completely wrong type } void access_priv(InnerNested o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); @@ -197,7 +196,7 @@ checkBadInvoke(mh, mh); // completely wrong type } void access_priv(StaticNested o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); @@ -205,7 +204,7 @@ checkBadInvoke(mh, mh); // completely wrong type } void access_priv(StaticIface o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findSpecial(StaticIface.class, "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); --- old/test/runtime/Nestmates/privateMethods/TestReflection.java 2017-09-15 03:00:08.543323799 -0400 +++ new/test/runtime/Nestmates/privateMethods/TestReflection.java 2017-09-15 03:00:06.679218073 -0400 @@ -26,7 +26,6 @@ * @bug 8046171 * @summary Test access to private methods between nestmates and nest-top * using different flavours of named nested types using core reflection - * @compile -XDdisablePrivateAccessors TestReflection.java * @run main TestReflection */ --- old/test/runtime/Nestmates/privateStaticFields/TestMethodHandles.java 2017-09-15 03:00:14.095638710 -0400 +++ new/test/runtime/Nestmates/privateStaticFields/TestMethodHandles.java 2017-09-15 03:00:12.235533209 -0400 @@ -26,7 +26,6 @@ * @bug 8046171 * @summary Test access to private static fields between nestmates and nest-top * using different flavours of named nested types using core reflection - * @compile -XDdisablePrivateAccessors TestMethodHandles.java * @run main TestMethodHandles */ --- old/test/runtime/Nestmates/privateStaticFields/TestPrivateStaticField.java 2017-09-15 03:00:19.723957930 -0400 +++ new/test/runtime/Nestmates/privateStaticFields/TestPrivateStaticField.java 2017-09-15 03:00:17.863852431 -0400 @@ -26,7 +26,6 @@ * @bug 8046171 * @summary Test access to private static fields between nestmates and nest-top * using different flavours of named nested types - * @compile -XDdisablePrivateAccessors TestPrivateStaticField.java * @run main TestPrivateStaticField */ @@ -41,7 +40,7 @@ // Methods that will access private static fields of nestmates // We use the arguments for overloading purposes and use the fact // you can access a static field through an object reference for - // convenience. + // convenience. // NOTE: No InnerNested calls in this test because non-static nested types // can't have static fields. Also no StaticIface calls as static interface --- old/test/runtime/Nestmates/privateStaticFields/TestReflection.java 2017-09-15 03:00:25.272272609 -0400 +++ new/test/runtime/Nestmates/privateStaticFields/TestReflection.java 2017-09-15 03:00:23.412167110 -0400 @@ -26,7 +26,6 @@ * @bug 8046171 * @summary Test access to private static fields between nestmates and nest-top * using different flavours of named nested types using core reflection - * @compile -XDdisablePrivateAccessors TestReflection.java * @run main TestReflection */ --- old/test/runtime/Nestmates/privateStaticMethods/TestInvokeStatic.java 2017-09-15 03:00:31.284613614 -0400 +++ new/test/runtime/Nestmates/privateStaticMethods/TestInvokeStatic.java 2017-09-15 03:00:28.968482247 -0400 @@ -26,7 +26,6 @@ * @bug 8046171 * @summary Test access to private static methods between nestmates and nest-top * using different flavours of named nested types - * @compile -XDdisablePrivateAccessors TestInvokeStatic.java * @run main TestInvokeStatic */ --- old/test/runtime/Nestmates/privateStaticMethods/TestMethodHandles.java 2017-09-15 03:00:36.840928746 -0400 +++ new/test/runtime/Nestmates/privateStaticMethods/TestMethodHandles.java 2017-09-15 03:00:34.980823251 -0400 @@ -26,7 +26,6 @@ * @bug 8046171 * @summary Test access to private static methods between nestmates and nest-top * using different flavours of named nested types using MethodHandles - * @compile -XDdisablePrivateAccessors TestMethodHandles.java * @run main TestMethodHandles */ @@ -53,19 +52,19 @@ // can't have static methods void access_priv(TestMethodHandles o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findStatic(o.getClass(), "priv_static_invoke", INVOKE_T); mh.invoke(); mh.invokeExact(); } void access_priv(StaticNested o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findStatic(o.getClass(), "priv_static_invoke", INVOKE_T); mh.invoke(); mh.invokeExact(); } void access_priv(StaticIface o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findStatic(StaticIface.class, "priv_static_invoke", INVOKE_T); mh.invoke(); mh.invokeExact(); @@ -82,19 +81,19 @@ // Methods that will access private static methods of nestmates default void access_priv(TestMethodHandles o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findStatic(o.getClass(), "priv_static_invoke", INVOKE_T); mh.invoke(); mh.invokeExact(); } default void access_priv(StaticNested o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findStatic(o.getClass(), "priv_static_invoke", INVOKE_T); mh.invoke(); mh.invokeExact(); } default void access_priv(StaticIface o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findStatic(StaticIface.class, "priv_static_invoke", INVOKE_T); mh.invoke(); mh.invokeExact(); @@ -113,19 +112,19 @@ // Methods that will access private static methods of nestmates void access_priv(TestMethodHandles o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findStatic(o.getClass(), "priv_static_invoke", INVOKE_T); mh.invoke(); mh.invokeExact(); } void access_priv(StaticNested o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findStatic(o.getClass(), "priv_static_invoke", INVOKE_T); mh.invoke(); mh.invokeExact(); } void access_priv(StaticIface o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findStatic(StaticIface.class, "priv_static_invoke", INVOKE_T); mh.invoke(); mh.invokeExact(); @@ -138,19 +137,19 @@ public InnerNested() {} void access_priv(TestMethodHandles o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findStatic(o.getClass(), "priv_static_invoke", INVOKE_T); mh.invoke(); mh.invokeExact(); } void access_priv(StaticNested o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findStatic(o.getClass(), "priv_static_invoke", INVOKE_T); mh.invoke(); mh.invokeExact(); } void access_priv(StaticIface o) throws Throwable { - MethodHandle mh = + MethodHandle mh = lookup().findStatic(StaticIface.class, "priv_static_invoke", INVOKE_T); mh.invoke(); mh.invokeExact(); --- old/test/runtime/Nestmates/privateStaticMethods/TestReflection.java 2017-09-15 03:00:42.425245474 -0400 +++ new/test/runtime/Nestmates/privateStaticMethods/TestReflection.java 2017-09-15 03:00:40.565139973 -0400 @@ -26,7 +26,6 @@ * @bug 8046171 * @summary Test access to private static methods between nestmates and nest-top * using different flavours of named nested types using core reflection - * @compile -XDdisablePrivateAccessors TestReflection.java * @run main TestReflection */ --- /dev/null 2016-12-30 14:52:30.584485998 -0500 +++ new/test/runtime/Nestmates/privateMethods/StaticIfaceError.jcod 2017-09-15 03:00:47.921557205 -0400 @@ -0,0 +1,147 @@ +/* + * Copyright (c) 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. + */ + +// Generated from the source in TestInvokeInterface.java, compiled for +// nestmates, but edited to set classfile version back to 52 - where +// use of invokeinterface for private interface methods is not permitted. + +class TestInvokeInterface$StaticIface { + 0xCAFEBABE; + 0; // minor version + 52; // version + [] { // Constant Pool + ; // first element is empty + Field #19 #20; // #1 + String #21; // #2 + Method #22 #23; // #3 + InterfaceMethod #5 #24; // #4 + class #25; // #5 + class #26; // #6 + Utf8 "priv_invoke"; // #7 + Utf8 "()V"; // #8 + Utf8 "Code"; // #9 + Utf8 "LineNumberTable"; // #10 + Utf8 "access_priv"; // #11 + Utf8 "StaticIface"; // #12 + Utf8 "InnerClasses"; // #13 + Utf8 "(LTestInvokeInterface$StaticIface;)V"; // #14 + Utf8 "SourceFile"; // #15 + Utf8 "TestInvokeInterface.java"; // #16 + Utf8 "MemberOfNest"; // #17 + class #27; // #18 + class #28; // #19 + NameAndType #29 #30; // #20 + Utf8 "StaticIface::priv_invoke"; // #21 + class #31; // #22 + NameAndType #32 #33; // #23 + NameAndType #7 #8; // #24 + Utf8 "TestInvokeInterface$StaticIface"; // #25 + Utf8 "java/lang/Object"; // #26 + Utf8 "TestInvokeInterface"; // #27 + Utf8 "java/lang/System"; // #28 + Utf8 "out"; // #29 + Utf8 "Ljava/io/PrintStream;"; // #30 + Utf8 "java/io/PrintStream"; // #31 + Utf8 "println"; // #32 + Utf8 "(Ljava/lang/String;)V"; // #33 + } // Constant Pool + + 0x0600; // access + #5;// this_cpx + #6;// super_cpx + + [] { // Interfaces + } // Interfaces + + [] { // fields + } // fields + + [] { // methods + { // Member + 0x0002; // access + #7; // name_cpx + #8; // sig_cpx + [] { // Attributes + Attr(#9) { // Code + 2; // max_stack + 1; // max_locals + Bytes[]{ + 0xB200011202B60003; + 0xB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#10) { // LineNumberTable + [] { // LineNumberTable + 0 42; + 8 43; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0001; // access + #11; // name_cpx + #14; // sig_cpx + [] { // Attributes + Attr(#9) { // Code + 1; // max_stack + 2; // max_locals + Bytes[]{ + 0x2BB900040100B1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#10) { // LineNumberTable + [] { // LineNumberTable + 0 46; + 6 47; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + } // methods + + [] { // Attributes + Attr(#15) { // SourceFile + #16; + } // end SourceFile + ; + Attr(#17) { // MemberOfNest + 0x0012; + } // end MemberOfNest + ; + Attr(#13) { // InnerClasses + [] { // InnerClasses + #5 #18 #12 1544; + } + } // end InnerClasses + } // Attributes +} // end class TestInvokeInterface$StaticIface --- /dev/null 2016-12-30 14:52:30.584485998 -0500 +++ new/test/runtime/Nestmates/privateMethods/StaticIfaceGood.jcod 2017-09-15 03:00:53.433869848 -0400 @@ -0,0 +1,148 @@ +/* + * Copyright (c) 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. + */ + +// Generated from the source in TestInvokeInterface.java, compiled for +// nestmates. The code is not modified from that but exists as a jcod file +// to ensure we don't accidentally compile it dynamically for the wrong +// release. + +class TestInvokeInterface$StaticIface { + 0xCAFEBABE; + 0; // minor version + 53; // version - FXME: will need to be real nestmate release version + [] { // Constant Pool + ; // first element is empty + Field #19 #20; // #1 + String #21; // #2 + Method #22 #23; // #3 + InterfaceMethod #5 #24; // #4 + class #25; // #5 + class #26; // #6 + Utf8 "priv_invoke"; // #7 + Utf8 "()V"; // #8 + Utf8 "Code"; // #9 + Utf8 "LineNumberTable"; // #10 + Utf8 "access_priv"; // #11 + Utf8 "StaticIface"; // #12 + Utf8 "InnerClasses"; // #13 + Utf8 "(LTestInvokeInterface$StaticIface;)V"; // #14 + Utf8 "SourceFile"; // #15 + Utf8 "TestInvokeInterface.java"; // #16 + Utf8 "MemberOfNest"; // #17 + class #27; // #18 + class #28; // #19 + NameAndType #29 #30; // #20 + Utf8 "StaticIface::priv_invoke"; // #21 + class #31; // #22 + NameAndType #32 #33; // #23 + NameAndType #7 #8; // #24 + Utf8 "TestInvokeInterface$StaticIface"; // #25 + Utf8 "java/lang/Object"; // #26 + Utf8 "TestInvokeInterface"; // #27 + Utf8 "java/lang/System"; // #28 + Utf8 "out"; // #29 + Utf8 "Ljava/io/PrintStream;"; // #30 + Utf8 "java/io/PrintStream"; // #31 + Utf8 "println"; // #32 + Utf8 "(Ljava/lang/String;)V"; // #33 + } // Constant Pool + + 0x0600; // access + #5;// this_cpx + #6;// super_cpx + + [] { // Interfaces + } // Interfaces + + [] { // fields + } // fields + + [] { // methods + { // Member + 0x0002; // access + #7; // name_cpx + #8; // sig_cpx + [] { // Attributes + Attr(#9) { // Code + 2; // max_stack + 1; // max_locals + Bytes[]{ + 0xB200011202B60003; + 0xB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#10) { // LineNumberTable + [] { // LineNumberTable + 0 42; + 8 43; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0001; // access + #11; // name_cpx + #14; // sig_cpx + [] { // Attributes + Attr(#9) { // Code + 1; // max_stack + 2; // max_locals + Bytes[]{ + 0x2BB900040100B1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#10) { // LineNumberTable + [] { // LineNumberTable + 0 46; + 6 47; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + } // methods + + [] { // Attributes + Attr(#15) { // SourceFile + #16; + } // end SourceFile + ; + Attr(#17) { // MemberOfNest + 0x0012; + } // end MemberOfNest + ; + Attr(#13) { // InnerClasses + [] { // InnerClasses + #5 #18 #12 1544; + } + } // end InnerClasses + } // Attributes +} // end class TestInvokeInterface$StaticIface --- /dev/null 2016-12-30 14:52:30.584485998 -0500 +++ new/test/runtime/Nestmates/privateMethods/TestInvokeInterface.java 2017-09-15 03:00:59.018186572 -0400 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 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. + */ + +// We compile two versions of the nested StaticIface which contains a call +// to a private interface method. Both versions are compiled to use +// invokeinterface, but one is modified to declare a lower classfile version, +// which makes the use of invokeinterface illegal in that context. +// We run the test twice, each time using a different version of the +// StaticIface class. + +/* + * @test + * @bug 8046171 + * @summary Test use of invokeinterface versus invokespecial for private + * interface method invocation + * @compile TestInvokeInterface.java + * @compile StaticIfaceGood.jcod + * @run main TestInvokeInterface pass + * @compile StaticIfaceError.jcod + * @run main TestInvokeInterface fail + */ + +public class TestInvokeInterface { + + static interface StaticIface { + + private void priv_invoke() { + System.out.println("StaticIface::priv_invoke"); + } + + default void access_priv(StaticIface o) { + o.priv_invoke(); + } + } + + public static void main(String[] args) { + boolean shouldFail = args[0].equals("fail"); + String icce = "IncompatibleClassChangeError: private interface method requires invokespecial"; + StaticIface intf = new StaticIface() {}; + try { + intf.access_priv(new StaticIface(){}); + if (shouldFail) + throw new Error("Do not get expected exception: " + icce); + else + System.out.println("Invocation succeeded as expected"); + } + catch (IncompatibleClassChangeError e) { + if (shouldFail && e.toString().contains(icce)) + System.out.println("Got expected exception: " + e); + else + throw new Error("Unexpected cause of exception: " + e); + } + } +}