test/hotspot/jtreg/gc/concurrent_phase_control/CheckUnsupported.java
author tschatzl
Mon, 14 May 2018 11:47:03 +0200
changeset 50097 ed8a43d83fcc
parent 47216 71c04702a3d5
child 53647 82c95d4b61f0
permissions -rw-r--r--
8201491: G1 support for java.lang.ref.Reference precleaning Summary: Implement single-threaded concurrent reference precleaning for G1. Reviewed-by: sangheki, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
46384
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
     1
/*
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
     4
 *
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
     7
 * published by the Free Software Foundation.
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
     8
 *
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    13
 * accompanied this code).
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    14
 *
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    18
 *
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    21
 * questions.
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    22
 */
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    23
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    24
package gc.concurrent_phase_control;
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    25
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    26
/*
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    27
 * Utility class that provides verification of expected behavior of
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    28
 * the Concurrent GC Phase Control WB API when the current GC does not
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    29
 * support phase control.  The invoking test must provide WhiteBox access.
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    30
 */
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    31
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    32
import sun.hotspot.WhiteBox;
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    33
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    34
public class CheckUnsupported {
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    35
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    36
    private static final WhiteBox WB = WhiteBox.getWhiteBox();
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    37
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    38
    public static void check(String gcName) throws Exception {
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    39
        // Verify unsupported.
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    40
        if (WB.supportsConcurrentGCPhaseControl()) {
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    41
            throw new RuntimeException(
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    42
                gcName + " unexpectedly supports phase control");
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    43
        }
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    44
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    45
        // Verify phase sequence is empty.
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    46
        String[] phases = WB.getConcurrentGCPhases();
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    47
        if (phases.length > 0) {
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    48
            throw new RuntimeException(
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    49
                gcName + " unexpectedly has non-empty phases");
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    50
        }
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    51
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    52
        // Verify IllegalStateException thrown by request attempt.
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    53
        boolean illegalStateThrown = false;
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    54
        try {
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    55
            WB.requestConcurrentGCPhase("UNKNOWN PHASE");
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    56
        } catch (IllegalStateException e) {
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    57
            // Expected.
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    58
            illegalStateThrown = true;
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    59
        } catch (Exception e) {
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    60
            throw new RuntimeException(
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    61
                gcName + ": Unexpected exception when requesting phase: "
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    62
                + e.toString());
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    63
        }
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    64
        if (!illegalStateThrown) {
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    65
            throw new RuntimeException(
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    66
                gcName + ": No exception when requesting phase");
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    67
        }
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    68
    }
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    69
}
dacebddcdea0 8169517: WhiteBox should provide concurrent GC phase control
kbarrett
parents:
diff changeset
    70