author | stefank |
Mon, 18 Aug 2014 14:12:48 +0200 | |
changeset 26152 | 2e5e15618d8e |
parent 25958 | 8dc85547d6d6 |
child 26702 | 20051b40655a |
permissions | -rw-r--r-- |
25908
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
1 |
/* |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
4 |
* |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
8 |
* |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
13 |
* accompanied this code). |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
14 |
* |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
18 |
* |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
21 |
* questions. |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
22 |
*/ |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
23 |
|
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
24 |
/* |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
25 |
* @test |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
26 |
* @key gc |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
27 |
* @bug 8049831 |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
28 |
* @library /testlibrary /testlibrary/whitebox |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
29 |
* @build TestCMSClassUnloadingEnabledHWM AllocateBeyondMetaspaceSize |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
30 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox |
25958
8dc85547d6d6
8011397: JTREG needs to copy additional WhiteBox class file to JTwork/scratch/sun/hotspot
mgerdin
parents:
25908
diff
changeset
|
31 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
25908
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
32 |
* @run driver TestCMSClassUnloadingEnabledHWM |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
33 |
* @summary Test that -XX:-CMSClassUnloadingEnabled will trigger a Full GC when more than MetaspaceSize metadata is allocated. |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
34 |
*/ |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
35 |
|
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
36 |
import com.oracle.java.testlibrary.OutputAnalyzer; |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
37 |
import com.oracle.java.testlibrary.ProcessTools; |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
38 |
|
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
39 |
import java.util.ArrayList; |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
40 |
import java.util.Arrays; |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
41 |
|
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
42 |
public class TestCMSClassUnloadingEnabledHWM { |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
43 |
private static long MetaspaceSize = 32 * 1024 * 1024; |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
44 |
private static long YoungGenSize = 32 * 1024 * 1024; |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
45 |
|
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
46 |
private static OutputAnalyzer run(boolean enableUnloading) throws Exception { |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
47 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
48 |
"-Xbootclasspath/a:.", |
26152
2e5e15618d8e
8055275: Several gc/class_unloading/ tests fail due to missed +UnlockDiagnosticVMOptions flag
stefank
parents:
25958
diff
changeset
|
49 |
"-XX:+UnlockDiagnosticVMOptions", |
25908
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
50 |
"-XX:+WhiteBoxAPI", |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
51 |
"-XX:MetaspaceSize=" + MetaspaceSize, |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
52 |
"-Xmn" + YoungGenSize, |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
53 |
"-XX:+UseConcMarkSweepGC", |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
54 |
"-XX:" + (enableUnloading ? "+" : "-") + "CMSClassUnloadingEnabled", |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
55 |
"-XX:+PrintHeapAtGC", |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
56 |
"-XX:+PrintGCDetails", |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
57 |
"AllocateBeyondMetaspaceSize", |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
58 |
"" + MetaspaceSize, |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
59 |
"" + YoungGenSize); |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
60 |
return new OutputAnalyzer(pb.start()); |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
61 |
} |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
62 |
|
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
63 |
public static OutputAnalyzer runWithCMSClassUnloading() throws Exception { |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
64 |
return run(true); |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
65 |
} |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
66 |
|
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
67 |
public static OutputAnalyzer runWithoutCMSClassUnloading() throws Exception { |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
68 |
return run(false); |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
69 |
} |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
70 |
|
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
71 |
public static void testWithoutCMSClassUnloading() throws Exception { |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
72 |
// -XX:-CMSClassUnloadingEnabled is used, so we expect a full GC instead of a concurrent cycle. |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
73 |
OutputAnalyzer out = runWithoutCMSClassUnloading(); |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
74 |
|
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
75 |
out.shouldMatch(".*Full GC.*"); |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
76 |
out.shouldNotMatch(".*CMS Initial Mark.*"); |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
77 |
} |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
78 |
|
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
79 |
public static void testWithCMSClassUnloading() throws Exception { |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
80 |
// -XX:+CMSClassUnloadingEnabled is used, so we expect a concurrent cycle instead of a full GC. |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
81 |
OutputAnalyzer out = runWithCMSClassUnloading(); |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
82 |
|
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
83 |
out.shouldMatch(".*CMS Initial Mark.*"); |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
84 |
out.shouldNotMatch(".*Full GC.*"); |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
85 |
} |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
86 |
|
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
87 |
public static void main(String args[]) throws Exception { |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
88 |
testWithCMSClassUnloading(); |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
89 |
testWithoutCMSClassUnloading(); |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
90 |
} |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
91 |
} |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
92 |