test/testlibrary_tests/RedefineClassTest.java

Thu, 05 Jul 2018 18:27:02 +0200

author
sgehwolf
date
Thu, 05 Jul 2018 18:27:02 +0200
changeset 9346
5ba59d58d976
parent 8050
3e5e398431a8
permissions
-rw-r--r--

8206425: .gnu_debuglink sections added unconditionally when no debuginfo is stripped
Summary: Only add .gnu_debuglink sections when there is some stripping done.
Reviewed-by: erikj, dholmes

ctornqvi@8050 1 /*
ctornqvi@8050 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
ctornqvi@8050 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ctornqvi@8050 4 *
ctornqvi@8050 5 * This code is free software; you can redistribute it and/or modify it
ctornqvi@8050 6 * under the terms of the GNU General Public License version 2 only, as
ctornqvi@8050 7 * published by the Free Software Foundation.
ctornqvi@8050 8 *
ctornqvi@8050 9 * This code is distributed in the hope that it will be useful, but WITHOUT
ctornqvi@8050 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ctornqvi@8050 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ctornqvi@8050 12 * version 2 for more details (a copy is included in the LICENSE file that
ctornqvi@8050 13 * accompanied this code).
ctornqvi@8050 14 *
ctornqvi@8050 15 * You should have received a copy of the GNU General Public License version
ctornqvi@8050 16 * 2 along with this work; if not, write to the Free Software Foundation,
ctornqvi@8050 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ctornqvi@8050 18 *
ctornqvi@8050 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ctornqvi@8050 20 * or visit www.oracle.com if you need additional information or have any
ctornqvi@8050 21 * questions.
ctornqvi@8050 22 */
ctornqvi@8050 23
ctornqvi@8050 24 /*
ctornqvi@8050 25 * @test
ctornqvi@8050 26 * @library /testlibrary
ctornqvi@8050 27 * @summary Proof of concept test for RedefineClassHelper
ctornqvi@8050 28 * @build RedefineClassHelper
ctornqvi@8050 29 * @run main RedefineClassHelper
ctornqvi@8050 30 * @run main/othervm -javaagent:redefineagent.jar RedefineClassTest
ctornqvi@8050 31 */
ctornqvi@8050 32
ctornqvi@8050 33 import static com.oracle.java.testlibrary.Asserts.*;
ctornqvi@8050 34 import com.oracle.java.testlibrary.*;
ctornqvi@8050 35
ctornqvi@8050 36 /*
ctornqvi@8050 37 * Proof of concept test for the test utility class RedefineClassHelper
ctornqvi@8050 38 */
ctornqvi@8050 39 public class RedefineClassTest {
ctornqvi@8050 40
ctornqvi@8050 41 public static String newClass = "class RedefineClassTest$A { public int Method() { return 2; } }";
ctornqvi@8050 42 public static void main(String[] args) throws Exception {
ctornqvi@8050 43 A a = new A();
ctornqvi@8050 44 assertTrue(a.Method() == 1);
ctornqvi@8050 45 RedefineClassHelper.redefineClass(A.class, newClass);
ctornqvi@8050 46 assertTrue(a.Method() == 2);
ctornqvi@8050 47 }
ctornqvi@8050 48
ctornqvi@8050 49 static class A {
ctornqvi@8050 50 public int Method() {
ctornqvi@8050 51 return 1;
ctornqvi@8050 52 }
ctornqvi@8050 53 }
ctornqvi@8050 54 }

mercurial