author | roland |
Wed, 29 Jul 2015 17:25:04 +0200 | |
changeset 32372 | b82e88dcb26c |
parent 30604 | b8d532cb6420 |
child 38152 | 80e5da81fb2c |
permissions | -rw-r--r-- |
24837
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
1 |
/* |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
24837
diff
changeset
|
2 |
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
24837
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 |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
24837
diff
changeset
|
28 |
* @modules java.compiler |
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
24837
diff
changeset
|
29 |
* java.instrument |
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
24837
diff
changeset
|
30 |
* jdk.jartool/sun.tools.jar |
24837
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
31 |
* @build RedefineClassHelper |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
32 |
* @run main RedefineClassHelper |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
33 |
* @run main/othervm -javaagent:redefineagent.jar RedefineClassTest |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
34 |
*/ |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
35 |
|
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
36 |
import static jdk.test.lib.Asserts.*; |
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
37 |
import jdk.test.lib.*; |
24837
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 |
/* |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
40 |
* Proof of concept test for the test utility class RedefineClassHelper |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
41 |
*/ |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
42 |
public class RedefineClassTest { |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
43 |
|
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
44 |
public static String newClass = "class RedefineClassTest$A { public int Method() { return 2; } }"; |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
45 |
public static void main(String[] args) throws Exception { |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
46 |
A a = new A(); |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
47 |
assertTrue(a.Method() == 1); |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
48 |
RedefineClassHelper.redefineClass(A.class, newClass); |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
49 |
assertTrue(a.Method() == 2); |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
50 |
} |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
51 |
|
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
52 |
static class A { |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
53 |
public int Method() { |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
54 |
return 1; |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
55 |
} |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
56 |
} |
b9c998a3e9fd
8044364: runtime/RedefineFinalizer test fails on windows
ctornqvi
parents:
diff
changeset
|
57 |
} |