1 /*
2 * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
34
35 public class TestExplicitGC {
36
37 enum Mode {
38 PRODUCT,
39 DIAGNOSTIC,
40 EXPERIMENTAL,
41 }
42
43 public static void main(String[] args) throws Exception {
44 if (args.length > 0) {
45 System.out.println("Calling System.gc()");
46 System.gc();
47 return;
48 }
49
50 String[] full = new String[] {
51 "Pause Full"
52 };
53
54 String[] concurrent = new String[] {
55 "Pause Init Mark",
56 "Pause Final Mark",
57 };
58
59 {
60 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
61 "-XX:+UnlockExperimentalVMOptions",
62 "-XX:+UseShenandoahGC",
63 "-verbose:gc",
64 TestExplicitGC.class.getName(),
65 "test");
66 OutputAnalyzer output = new OutputAnalyzer(pb.start());
67 for (String p : full) {
68 output.shouldNotContain(p);
69 }
70 for (String p : concurrent) {
71 output.shouldContain(p);
72 }
73 }
74
75 {
76 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
77 "-XX:+UnlockExperimentalVMOptions",
78 "-XX:+UseShenandoahGC",
79 "-verbose:gc",
80 "-XX:+DisableExplicitGC",
81 TestExplicitGC.class.getName(),
82 "test");
83 OutputAnalyzer output = new OutputAnalyzer(pb.start());
84 for (String p : full) {
85 output.shouldNotContain(p);
86 }
87 for (String p : concurrent) {
88 output.shouldNotContain(p);
89 }
90 }
91
92 {
93 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
94 "-XX:+UnlockExperimentalVMOptions",
95 "-XX:+UseShenandoahGC",
96 "-verbose:gc",
97 "-XX:+ExplicitGCInvokesConcurrent",
98 TestExplicitGC.class.getName(),
99 "test");
100 OutputAnalyzer output = new OutputAnalyzer(pb.start());
101 for (String p : full) {
102 output.shouldNotContain(p);
103 }
104 for (String p : concurrent) {
105 output.shouldContain(p);
106 }
107 }
108
109 {
110 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
111 "-XX:+UnlockExperimentalVMOptions",
112 "-XX:+UseShenandoahGC",
113 "-verbose:gc",
114 "-XX:-ExplicitGCInvokesConcurrent",
115 TestExplicitGC.class.getName(),
116 "test");
117 OutputAnalyzer output = new OutputAnalyzer(pb.start());
118 for (String p : full) {
119 output.shouldContain(p);
120 }
121 for (String p : concurrent) {
122 output.shouldNotContain(p);
123 }
124 }
125 }
126 }
|
1 '/*
2 * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
34
35 public class TestExplicitGC {
36
37 enum Mode {
38 PRODUCT,
39 DIAGNOSTIC,
40 EXPERIMENTAL,
41 }
42
43 public static void main(String[] args) throws Exception {
44 if (args.length > 0) {
45 System.out.println("Calling System.gc()");
46 System.gc();
47 return;
48 }
49
50 String[] full = new String[] {
51 "Pause Full"
52 };
53
54 String[] concNormal = new String[] {
55 "Pause Init Mark",
56 "Pause Final Mark",
57 };
58
59 String[] concTraversal = new String[] {
60 "Pause Init Traversal",
61 "Pause Final Traversal",
62 };
63
64 {
65 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
66 "-XX:+UnlockExperimentalVMOptions",
67 "-XX:+UseShenandoahGC",
68 "-verbose:gc",
69 TestExplicitGC.class.getName(),
70 "test");
71 OutputAnalyzer output = new OutputAnalyzer(pb.start());
72 for (String p : full) {
73 output.shouldNotContain(p);
74 }
75 for (String p : concNormal) {
76 output.shouldContain(p);
77 }
78 for (String p : concTraversal) {
79 output.shouldNotContain(p);
80 }
81 }
82
83 {
84 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
85 "-XX:+UnlockExperimentalVMOptions",
86 "-XX:+UseShenandoahGC",
87 "-verbose:gc",
88 "-XX:+DisableExplicitGC",
89 TestExplicitGC.class.getName(),
90 "test");
91 OutputAnalyzer output = new OutputAnalyzer(pb.start());
92 for (String p : full) {
93 output.shouldNotContain(p);
94 }
95 for (String p : concNormal) {
96 output.shouldNotContain(p);
97 }
98 for (String p : concTraversal) {
99 output.shouldNotContain(p);
100 }
101 }
102
103 {
104 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
105 "-XX:+UnlockExperimentalVMOptions",
106 "-XX:+UseShenandoahGC",
107 "-verbose:gc",
108 "-XX:+ExplicitGCInvokesConcurrent",
109 TestExplicitGC.class.getName(),
110 "test");
111 OutputAnalyzer output = new OutputAnalyzer(pb.start());
112 for (String p : full) {
113 output.shouldNotContain(p);
114 }
115 for (String p : concNormal) {
116 output.shouldContain(p);
117 }
118 for (String p : concTraversal) {
119 output.shouldNotContain(p);
120 }
121 }
122
123 {
124 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
125 "-XX:+UnlockExperimentalVMOptions",
126 "-XX:+UseShenandoahGC",
127 "-verbose:gc",
128 "-XX:+ExplicitGCInvokesConcurrent",
129 "-XX:ShenandoahGCMode=traversal",
130 TestExplicitGC.class.getName(),
131 "test");
132 OutputAnalyzer output = new OutputAnalyzer(pb.start());
133 for (String p : full) {
134 output.shouldNotContain(p);
135 }
136 for (String p : concNormal) {
137 output.shouldNotContain(p);
138 }
139 for (String p : concTraversal) {
140 output.shouldContain(p);
141 }
142 }
143
144 {
145 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
146 "-XX:+UnlockExperimentalVMOptions",
147 "-XX:+UseShenandoahGC",
148 "-verbose:gc",
149 "-XX:-ExplicitGCInvokesConcurrent",
150 TestExplicitGC.class.getName(),
151 "test");
152 OutputAnalyzer output = new OutputAnalyzer(pb.start());
153 for (String p : full) {
154 output.shouldContain(p);
155 }
156 for (String p : concNormal) {
157 output.shouldNotContain(p);
158 }
159 for (String p : concTraversal) {
160 output.shouldNotContain(p);
161 }
162 }
163 }
164 }
|