test/lib/sun/hotspot/gc/GC.java
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--
8199927: Make WhiteBox more GC agnostic Reviewed-by: shade, eosterlund
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38629
0602da3f94c9 8154096: Extend WhiteBox API with methods which retrieve from VM information about available GC
dfazunen
parents:
diff changeset
     1
/*
49630
2f1b308b4469 8199927: Make WhiteBox more GC agnostic
pliden
parents: 41533
diff changeset
     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
2f1b308b4469 8199927: Make WhiteBox more GC agnostic
pliden
parents: 41533
diff changeset
    33
    /*
2f1b308b4469 8199927: Make WhiteBox more GC agnostic
pliden
parents: 41533
diff changeset
    34
     * Enum values much match CollectedHeap::Name
2f1b308b4469 8199927: Make WhiteBox more GC agnostic
pliden
parents: 41533
diff changeset
    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
2f1b308b4469 8199927: Make WhiteBox more GC agnostic
pliden
parents: 41533
diff changeset
    38
    ConcMarkSweep(3),
2f1b308b4469 8199927: Make WhiteBox more GC agnostic
pliden
parents: 41533
diff changeset
    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
2f1b308b4469 8199927: Make WhiteBox more GC agnostic
pliden
parents: 41533
diff changeset
    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
2f1b308b4469 8199927: Make WhiteBox more GC agnostic
pliden
parents: 41533
diff changeset
    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
2f1b308b4469 8199927: Make WhiteBox more GC agnostic
pliden
parents: 41533
diff changeset
    45
    private GC(int name) {
2f1b308b4469 8199927: Make WhiteBox more GC agnostic
pliden
parents: 41533
diff changeset
    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
2f1b308b4469 8199927: Make WhiteBox more GC agnostic
pliden
parents: 41533
diff changeset
    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
2f1b308b4469 8199927: Make WhiteBox more GC agnostic
pliden
parents: 41533
diff changeset
    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
2f1b308b4469 8199927: Make WhiteBox more GC agnostic
pliden
parents: 41533
diff changeset
    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
2f1b308b4469 8199927: Make WhiteBox more GC agnostic
pliden
parents: 41533
diff changeset
    59
    public boolean isSelected() {
2f1b308b4469 8199927: Make WhiteBox more GC agnostic
pliden
parents: 41533
diff changeset
    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
2f1b308b4469 8199927: Make WhiteBox more GC agnostic
pliden
parents: 41533
diff changeset
    64
     * @return true if GC was selected ergonomically, as opposed
2f1b308b4469 8199927: Make WhiteBox more GC agnostic
pliden
parents: 41533
diff changeset
    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
2f1b308b4469 8199927: Make WhiteBox more GC agnostic
pliden
parents: 41533
diff changeset
    67
    public static boolean isSelectedErgonomically() {
2f1b308b4469 8199927: Make WhiteBox more GC agnostic
pliden
parents: 41533
diff changeset
    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
}