author | ctornqvi |
Fri, 19 Aug 2016 10:06:30 -0400 | |
changeset 40631 | ed82623d7831 |
parent 38152 | 80e5da81fb2c |
child 40668 | 60d799be5dda |
permissions | -rw-r--r-- |
26558
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
1 |
/* |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
38152
diff
changeset
|
2 |
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. |
26558
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
4 |
* |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
8 |
* |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
13 |
* accompanied this code). |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
14 |
* |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
18 |
* |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
21 |
* questions. |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
22 |
*/ |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
23 |
|
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
24 |
/* |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
25 |
* @test |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
26 |
* @bug 8055008 |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
27 |
* @summary Redefine EMCP and non-EMCP methods that are running in an infinite loop |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
38152
diff
changeset
|
28 |
* @library /test/lib |
38152
80e5da81fb2c
8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents:
29678
diff
changeset
|
29 |
* @modules java.base/jdk.internal.misc |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
26558
diff
changeset
|
30 |
* @modules java.compiler |
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
26558
diff
changeset
|
31 |
* java.instrument |
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
26558
diff
changeset
|
32 |
* jdk.jartool/sun.tools.jar |
26558
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
33 |
* @run main RedefineClassHelper |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
34 |
* @run main/othervm -javaagent:redefineagent.jar -XX:TraceRedefineClasses=0x600 RedefineRunningMethods |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
35 |
*/ |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
36 |
public class RedefineRunningMethods { |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
37 |
|
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
38 |
public static String newB = |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
39 |
"class RedefineRunningMethods$B {" + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
40 |
" static int count1 = 0;" + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
41 |
" static int count2 = 0;" + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
42 |
" public static volatile boolean stop = false;" + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
43 |
" static void localSleep() { " + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
44 |
" try{ " + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
45 |
" Thread.currentThread().sleep(10);" + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
46 |
" } catch(InterruptedException ie) { " + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
47 |
" } " + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
48 |
" } " + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
49 |
" public static void infinite() { " + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
50 |
" System.out.println(\"infinite called\");" + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
51 |
" }" + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
52 |
" public static void infinite_emcp() { " + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
53 |
" while (!stop) { count2++; localSleep(); }" + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
54 |
" }" + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
55 |
"}"; |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
56 |
|
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
57 |
public static String evenNewerB = |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
58 |
"class RedefineRunningMethods$B {" + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
59 |
" static int count1 = 0;" + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
60 |
" static int count2 = 0;" + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
61 |
" public static volatile boolean stop = false;" + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
62 |
" static void localSleep() { " + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
63 |
" try{ " + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
64 |
" Thread.currentThread().sleep(1);" + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
65 |
" } catch(InterruptedException ie) { " + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
66 |
" } " + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
67 |
" } " + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
68 |
" public static void infinite() { }" + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
69 |
" public static void infinite_emcp() { " + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
70 |
" System.out.println(\"infinite_emcp now obsolete called\");" + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
71 |
" }" + |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
72 |
"}"; |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
73 |
|
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
74 |
static class B { |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
75 |
static int count1 = 0; |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
76 |
static int count2 = 0; |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
77 |
public static volatile boolean stop = false; |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
78 |
static void localSleep() { |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
79 |
try{ |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
80 |
Thread.currentThread().sleep(10);//sleep for 10 ms |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
81 |
} catch(InterruptedException ie) { |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
82 |
} |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
83 |
} |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
84 |
|
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
85 |
public static void infinite() { |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
86 |
while (!stop) { count1++; localSleep(); } |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
87 |
} |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
88 |
public static void infinite_emcp() { |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
89 |
while (!stop) { count2++; localSleep(); } |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
90 |
} |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
91 |
} |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
92 |
|
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
93 |
|
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
94 |
public static void main(String[] args) throws Exception { |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
95 |
|
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
96 |
new Thread() { |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
97 |
public void run() { |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
98 |
B.infinite(); |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
99 |
} |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
100 |
}.start(); |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
101 |
|
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
102 |
new Thread() { |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
103 |
public void run() { |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
104 |
B.infinite_emcp(); |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
105 |
} |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
106 |
}.start(); |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
107 |
|
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
108 |
RedefineClassHelper.redefineClass(B.class, newB); |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
109 |
|
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
110 |
System.gc(); |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
111 |
|
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
112 |
B.infinite(); |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
113 |
|
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
114 |
// Start a thread with the second version of infinite_emcp running |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
115 |
new Thread() { |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
116 |
public void run() { |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
117 |
B.infinite_emcp(); |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
118 |
} |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
119 |
}.start(); |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
120 |
|
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
121 |
for (int i = 0; i < 20 ; i++) { |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
122 |
String s = new String("some garbage"); |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
123 |
System.gc(); |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
124 |
} |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
125 |
|
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
126 |
RedefineClassHelper.redefineClass(B.class, evenNewerB); |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
127 |
System.gc(); |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
128 |
|
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
129 |
for (int i = 0; i < 20 ; i++) { |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
130 |
B.infinite(); |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
131 |
String s = new String("some garbage"); |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
132 |
System.gc(); |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
133 |
} |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
134 |
|
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
135 |
B.infinite_emcp(); |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
136 |
|
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
137 |
// purge should clean everything up. |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
138 |
B.stop = true; |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
139 |
|
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
140 |
for (int i = 0; i < 20 ; i++) { |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
141 |
B.infinite(); |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
142 |
String s = new String("some garbage"); |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
143 |
System.gc(); |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
144 |
} |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
145 |
} |
b7df27df6384
8055008: Clean up code that saves the previous versions of redefined classes
coleenp
parents:
diff
changeset
|
146 |
} |