hotspot/test/runtime/CompressedOops/CompressedClassSpaceSize.java
author fzhinkin
Tue, 20 Jan 2015 11:26:20 +0300
changeset 28722 51fe60d9e30c
parent 26688 bb0cdd873e51
child 29678 dd2f3932c21e
permissions -rw-r--r--
8069126: compiler/rtm/locking/TestRTMTotalCountIncrRate.java nightly failure Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     1
/*
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     4
 *
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     7
 * published by the Free Software Foundation.
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     8
 *
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    13
 * accompanied this code).
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    14
 *
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    18
 *
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    21
 * questions.
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    22
 */
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    23
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    24
/*
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    25
 * @test
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    26
 * @bug 8022865
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    27
 * @summary Tests for the -XX:CompressedClassSpaceSize command line option
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    28
 * @library /testlibrary
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    29
 * @run main CompressedClassSpaceSize
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    30
 */
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    31
import com.oracle.java.testlibrary.*;
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    32
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    33
public class CompressedClassSpaceSize {
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    34
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    35
    public static void main(String[] args) throws Exception {
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    36
        ProcessBuilder pb;
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    37
        OutputAnalyzer output;
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    38
        if (Platform.is64bit()) {
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    39
            // Minimum size is 1MB
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    40
            pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=0",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    41
                                                       "-version");
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    42
            output = new OutputAnalyzer(pb.start());
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    43
            output.shouldContain("CompressedClassSpaceSize of 0 is invalid")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    44
                  .shouldHaveExitValue(1);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    45
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    46
            // Invalid size of -1 should be handled correctly
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    47
            pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=-1",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    48
                                                       "-version");
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    49
            output = new OutputAnalyzer(pb.start());
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    50
            output.shouldContain("Improperly specified VM option 'CompressedClassSpaceSize=-1'")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    51
                  .shouldHaveExitValue(1);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    52
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    53
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    54
            // Maximum size is 3GB
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    55
            pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=4g",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    56
                                                       "-version");
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    57
            output = new OutputAnalyzer(pb.start());
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    58
            output.shouldContain("CompressedClassSpaceSize of 4294967296 is invalid")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    59
                  .shouldHaveExitValue(1);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    60
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    61
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    62
            // Make sure the minimum size is set correctly and printed
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    63
            pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    64
                                                       "-XX:CompressedClassSpaceSize=1m",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    65
                                                       "-XX:+PrintCompressedOopsMode",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    66
                                                       "-version");
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    67
            output = new OutputAnalyzer(pb.start());
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    68
            output.shouldContain("Compressed class space size: 1048576")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    69
                  .shouldHaveExitValue(0);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    70
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    71
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    72
            // Make sure the maximum size is set correctly and printed
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    73
            pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    74
                                                       "-XX:CompressedClassSpaceSize=3g",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    75
                                                       "-XX:+PrintCompressedOopsMode",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    76
                                                       "-version");
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    77
            output = new OutputAnalyzer(pb.start());
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    78
            output.shouldContain("Compressed class space size: 3221225472")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    79
                  .shouldHaveExitValue(0);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    80
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    81
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    82
            pb = ProcessTools.createJavaProcessBuilder("-XX:-UseCompressedOops",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    83
                                                       "-XX:CompressedClassSpaceSize=1m",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    84
                                                       "-version");
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    85
            output = new OutputAnalyzer(pb.start());
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    86
            output.shouldContain("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    87
                  .shouldHaveExitValue(0);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    88
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    89
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    90
            pb = ProcessTools.createJavaProcessBuilder("-XX:-UseCompressedClassPointers",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    91
                                                       "-XX:CompressedClassSpaceSize=1m",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    92
                                                       "-version");
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    93
            output = new OutputAnalyzer(pb.start());
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    94
            output.shouldContain("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    95
                  .shouldHaveExitValue(0);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    96
        } else {
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    97
            // 32bit platforms doesn't have compressed oops
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    98
            pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=1m",
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    99
                                                       "-version");
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   100
            output = new OutputAnalyzer(pb.start());
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   101
            output.shouldContain("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   102
                  .shouldHaveExitValue(0);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   103
        }
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   104
    }
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   105
}