Mon, 18 Dec 2017 18:18:10 -0500
8189851: [TESTBUG] runtime/RedefineTests/RedefineInterfaceCall.java fails
Summary: modified jtreg tags and package import to work with JDK 8
Reviewed-by: vlivanov, dholmes
dbuck@8997 | 1 | /* |
dbuck@8997 | 2 | * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
dbuck@8997 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
dbuck@8997 | 4 | * |
dbuck@8997 | 5 | * This code is free software; you can redistribute it and/or modify it |
dbuck@8997 | 6 | * under the terms of the GNU General Public License version 2 only, as |
dbuck@8997 | 7 | * published by the Free Software Foundation. |
dbuck@8997 | 8 | * |
dbuck@8997 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
dbuck@8997 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
dbuck@8997 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
dbuck@8997 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
dbuck@8997 | 13 | * accompanied this code). |
dbuck@8997 | 14 | * |
dbuck@8997 | 15 | * You should have received a copy of the GNU General Public License version |
dbuck@8997 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
dbuck@8997 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
dbuck@8997 | 18 | * |
dbuck@8997 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
dbuck@8997 | 20 | * or visit www.oracle.com if you need additional information or have any |
dbuck@8997 | 21 | * questions. |
dbuck@8997 | 22 | */ |
dbuck@8997 | 23 | |
dbuck@8997 | 24 | /* |
dbuck@8997 | 25 | * @test |
dbuck@8997 | 26 | * @bug 8174962 |
dbuck@8997 | 27 | * @summary Redefine class with interface method call |
dbuck@9077 | 28 | * @library /testlibrary |
dbuck@9077 | 29 | * @build RedefineClassHelper |
dbuck@8997 | 30 | * @run main RedefineClassHelper |
dbuck@9077 | 31 | * @run main/othervm -javaagent:redefineagent.jar -XX:TraceRedefineClasses=3174407 RedefineInterfaceCall |
dbuck@8997 | 32 | */ |
dbuck@8997 | 33 | |
dbuck@9077 | 34 | import static com.oracle.java.testlibrary.Asserts.assertEquals; |
dbuck@8997 | 35 | |
dbuck@8997 | 36 | interface I1 { default int m() { return 0; } } |
dbuck@8997 | 37 | interface I2 extends I1 {} |
dbuck@8997 | 38 | |
dbuck@8997 | 39 | public class RedefineInterfaceCall { |
dbuck@8997 | 40 | |
dbuck@8997 | 41 | public static class C implements I2 { |
dbuck@8997 | 42 | public int test(I2 i) { |
dbuck@8997 | 43 | return i.m(); // invokeinterface cpCacheEntry |
dbuck@8997 | 44 | } |
dbuck@8997 | 45 | } |
dbuck@8997 | 46 | |
dbuck@8997 | 47 | static String newI1 = |
dbuck@8997 | 48 | "interface I1 { default int m() { return 1; } }"; |
dbuck@8997 | 49 | |
dbuck@8997 | 50 | static String newC = |
dbuck@8997 | 51 | "public class RedefineInterfaceCall$C implements I2 { " + |
dbuck@8997 | 52 | " public int test(I2 i) { " + |
dbuck@8997 | 53 | " return i.m(); " + |
dbuck@8997 | 54 | " } " + |
dbuck@8997 | 55 | "} "; |
dbuck@8997 | 56 | |
dbuck@8997 | 57 | static int test(I2 i) { |
dbuck@8997 | 58 | return i.m(); // invokeinterface cpCacheEntry |
dbuck@8997 | 59 | } |
dbuck@8997 | 60 | |
dbuck@8997 | 61 | public static void main(String[] args) throws Exception { |
dbuck@8997 | 62 | C c = new C(); |
dbuck@8997 | 63 | |
dbuck@8997 | 64 | assertEquals(test(c), 0); |
dbuck@8997 | 65 | assertEquals(c.test(c), 0); |
dbuck@8997 | 66 | |
dbuck@8997 | 67 | RedefineClassHelper.redefineClass(C.class, newC); |
dbuck@8997 | 68 | |
dbuck@8997 | 69 | assertEquals(c.test(c), 0); |
dbuck@8997 | 70 | |
dbuck@8997 | 71 | RedefineClassHelper.redefineClass(I1.class, newI1); |
dbuck@8997 | 72 | |
dbuck@8997 | 73 | assertEquals(test(c), 1); |
dbuck@8997 | 74 | assertEquals(c.test(c), 1); |
dbuck@8997 | 75 | |
dbuck@8997 | 76 | RedefineClassHelper.redefineClass(C.class, newC); |
dbuck@8997 | 77 | |
dbuck@8997 | 78 | assertEquals(c.test(c), 1); |
dbuck@8997 | 79 | } |
dbuck@8997 | 80 | } |