author | pliden |
Wed, 28 Mar 2018 11:38:47 +0200 | |
changeset 49630 | 2f1b308b4469 |
parent 41533 | 64e1caddf380 |
child 50523 | 7b7c75d87f9b |
child 56540 | ada11a8e2ebc |
permissions | -rw-r--r-- |
38629
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
1 |
/* |
49630 | 2 |
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
38629
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
4 |
* |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
8 |
* |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
13 |
* accompanied this code). |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
14 |
* |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
18 |
* |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
21 |
* questions. |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
22 |
*/ |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
23 |
|
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
24 |
package sun.hotspot.gc; |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
25 |
|
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
26 |
import sun.hotspot.WhiteBox; |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
27 |
|
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
28 |
/** |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
29 |
* API to obtain information about selected and supported Garbage Collectors |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
30 |
* retrieved from the VM with the WhiteBox API. |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
31 |
*/ |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
32 |
public enum GC { |
49630 | 33 |
/* |
34 |
* Enum values much match CollectedHeap::Name |
|
35 |
*/ |
|
38629
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
36 |
Serial(1), |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
37 |
Parallel(2), |
49630 | 38 |
ConcMarkSweep(3), |
39 |
G1(4); |
|
38629
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
40 |
|
49630 | 41 |
private static final WhiteBox WB = WhiteBox.getWhiteBox(); |
38629
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
42 |
|
49630 | 43 |
private final int name; |
38629
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
44 |
|
49630 | 45 |
private GC(int name) { |
46 |
this.name = name; |
|
38629
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
47 |
} |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
48 |
|
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
49 |
/** |
49630 | 50 |
* @return true if this GC is supported by the VM |
38629
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
51 |
*/ |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
52 |
public boolean isSupported() { |
49630 | 53 |
return WB.isGCSupported(name); |
38629
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
54 |
} |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
55 |
|
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
56 |
/** |
49630 | 57 |
* @return true if this GC is currently selected/used |
38629
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
58 |
*/ |
49630 | 59 |
public boolean isSelected() { |
60 |
return WB.isGCSelected(name); |
|
38629
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
61 |
} |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
62 |
|
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
63 |
/** |
49630 | 64 |
* @return true if GC was selected ergonomically, as opposed |
65 |
* to being explicitly specified on the command line |
|
38629
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
66 |
*/ |
49630 | 67 |
public static boolean isSelectedErgonomically() { |
68 |
return WB.isGCSelectedErgonomically(); |
|
38629
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
69 |
} |
0602da3f94c9
8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff
changeset
|
70 |
} |