author | amenkov |
Fri, 12 Oct 2018 10:08:11 -0700 | |
changeset 52110 | 65efb9c57fef |
parent 51716 | e7459270ca63 |
permissions | -rw-r--r-- |
51716
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
1 |
/* |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
4 |
* |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
7 |
* published by the Free Software Foundation. |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
8 |
* |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
13 |
* accompanied this code). |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
14 |
* |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
18 |
* |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
21 |
* questions. |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
22 |
*/ |
2 | 23 |
|
51716
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
24 |
/* |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
25 |
* @test |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
26 |
* @bug 4628760 |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
27 |
* @summary RedefineClasses gets assertion: "Should be a method entry in cpcache!" |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
28 |
* @comment converted from test/jdk/com/sun/jdi/RedefineClasses.sh |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
29 |
* |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
30 |
* @library /test/lib |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
31 |
* @run main/othervm RedefineClasses |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
32 |
*/ |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
33 |
|
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
34 |
/* On windows, with b90, this gets this: |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
35 |
* assert(u2_at_bcp >= 0 && u2_at_bcp < old_cache->length(), "Bad cpcache index!") |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
36 |
* |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
37 |
* Error happened during: VM_RedefineClasses |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
38 |
* |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
39 |
* Error ID: D:/jdk1.4/hotspot\src\share\vm\prims\jvmdi_hotswap.cpp, 331 |
2 | 40 |
|
51716
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
41 |
* On solaris, and on windows with 4559100 fixed, this test fails with: |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
42 |
* |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
43 |
* HotSpot Virtual Machine Error, assertion failure |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
44 |
* Please report this error at |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
45 |
* http://java.sun.com/cgi-bin/bugreport.cgi |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
46 |
* |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
47 |
* Java VM: Java HotSpot(TM) Client VM (1.4-internal-debug mixed mode) |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
48 |
* |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
49 |
* assert(old_cache->entry_at(u2_at_bcp)->is_method_entry(), "Should be a method entry in cpcache!") |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
50 |
* |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
51 |
* Error happened during: VM_RedefineClasses |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
52 |
* |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
53 |
* Error ID: M:\ws\m\b2\service_hs_baseline\src\share\vm\prims\jvmdi_hotswap.cpp, 335 |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
54 |
*/ |
2 | 55 |
|
51716
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
56 |
/* |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
57 |
* With -Xcomp on solaris this passes, but takes 2 minutes. |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
58 |
*/ |
2 | 59 |
|
51716
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
60 |
import lib.jdb.ClassTransformer; |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
61 |
import lib.jdb.JdbCommand; |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
62 |
import lib.jdb.JdbTest; |
2 | 63 |
|
64 |
import java.lang.Thread; |
|
65 |
import java.util.HashMap; |
|
66 |
import javax.swing.*; |
|
67 |
import java.util.*; |
|
68 |
||
51716
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
69 |
class RedefineClassesTarg { |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
70 |
int xxx = 20; |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
71 |
//ThreadGroup k = new ThreadGroup("group"); |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
72 |
int i; |
2 | 73 |
|
51716
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
74 |
public RedefineClassesTarg() { |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
75 |
} |
2 | 76 |
|
51716
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
77 |
public void a1() { |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
78 |
a2(); |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
79 |
} |
2 | 80 |
|
51716
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
81 |
public void a2() { |
2 | 82 |
a3(); |
51716
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
83 |
} |
2 | 84 |
|
51716
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
85 |
public void a3() { |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
86 |
System.out.println("out from a3"); // @1 breakpoint |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
87 |
//System.out.println("hello world"); // @ 1 delete this isn't even necesary |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
88 |
} |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
89 |
public void a4() { |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
90 |
System.out.println("in a4"); |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
91 |
int i = 2; |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
92 |
int j = 3333; |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
93 |
System.out.println("i + j = " + (i + j)); |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
94 |
System.out.println("out from a4"); |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
95 |
System.out.println("def"); |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
96 |
a1(); |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
97 |
} |
2 | 98 |
|
51716
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
99 |
public void aa() { |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
100 |
a4(); |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
101 |
System.out.println("out from aa"); |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
102 |
} |
2 | 103 |
|
104 |
||
51716
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
105 |
public static void main(String[] args) { |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
106 |
byte xyz[] = new byte[] { 'a', 'b', 'c' }; |
2 | 107 |
|
51716
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
108 |
int x1 = 100; |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
109 |
x1 = 101; |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
110 |
x1 = 102; |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
111 |
x1 = 103; |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
112 |
String m1 = "def"; |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
113 |
String m2 = "abc"; |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
114 |
String m3 = "def"; |
2 | 115 |
|
51716
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
116 |
int[] m = new int[] { 100, 200, 300 }; |
2 | 117 |
|
51716
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
118 |
RedefineClassesTarg untitled31 = new RedefineClassesTarg(); |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
119 |
untitled31.aa(); |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
120 |
} |
2 | 121 |
} |
122 |
||
51716
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
123 |
public class RedefineClasses extends JdbTest { |
2 | 124 |
|
51716
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
125 |
public static void main(String argv[]) { |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
126 |
new RedefineClasses().run(); |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
127 |
} |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
128 |
|
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
129 |
private RedefineClasses() { |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
130 |
super(DEBUGGEE_CLASS, SOURCE_FILE); |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
131 |
} |
2 | 132 |
|
51716
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
133 |
private static final String DEBUGGEE_CLASS = RedefineClassesTarg.class.getName(); |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
134 |
private static final String SOURCE_FILE = "RedefineClasses.java"; |
2 | 135 |
|
51716
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
136 |
@Override |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
137 |
protected void runCases() { |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
138 |
setBreakpoints(1); |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
139 |
jdb.command(JdbCommand.run()); |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
140 |
String transformedClassFile = ClassTransformer.fromTestSource(SOURCE_FILE) |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
141 |
.transform(1, DEBUGGEE_CLASS); |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
142 |
jdb.command(JdbCommand.redefine(DEBUGGEE_CLASS, transformedClassFile)); |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
143 |
jdb.command(JdbCommand.redefine(DEBUGGEE_CLASS, transformedClassFile)); |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
144 |
jdb.command(JdbCommand.redefine(DEBUGGEE_CLASS, transformedClassFile)); |
e7459270ca63
8210560: [TEST] convert com/sun/jdi redefineClass-related tests
amenkov
parents:
47216
diff
changeset
|
145 |
} |
2 | 146 |
} |