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