Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/runtime/RedefineTests/RedefineInterfaceCall.java
32284 views
/*1* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 817496226* @summary Redefine class with interface method call27* @library /testlibrary28* @build RedefineClassHelper29* @run main RedefineClassHelper30* @run main/othervm -javaagent:redefineagent.jar -XX:TraceRedefineClasses=3174407 RedefineInterfaceCall31*/3233import static com.oracle.java.testlibrary.Asserts.assertEquals;3435interface I1 { default int m() { return 0; } }36interface I2 extends I1 {}3738public class RedefineInterfaceCall {3940public static class C implements I2 {41public int test(I2 i) {42return i.m(); // invokeinterface cpCacheEntry43}44}4546static String newI1 =47"interface I1 { default int m() { return 1; } }";4849static String newC =50"public class RedefineInterfaceCall$C implements I2 { " +51" public int test(I2 i) { " +52" return i.m(); " +53" } " +54"} ";5556static int test(I2 i) {57return i.m(); // invokeinterface cpCacheEntry58}5960public static void main(String[] args) throws Exception {61C c = new C();6263assertEquals(test(c), 0);64assertEquals(c.test(c), 0);6566RedefineClassHelper.redefineClass(C.class, newC);6768assertEquals(c.test(c), 0);6970RedefineClassHelper.redefineClass(I1.class, newI1);7172assertEquals(test(c), 1);73assertEquals(c.test(c), 1);7475RedefineClassHelper.redefineClass(C.class, newC);7677assertEquals(c.test(c), 1);78}79}808182