Mon, 06 Nov 2017 16:51:47 +0800
[Code Reorganization] remove trailing whitespace to pass jcheck test
1 /*
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
24 import com.oracle.java.testlibrary.ExitCode;
25 import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
27 /**
28 * @test
29 * @bug 8031323
30 * @summary Verify SurvivorAlignmentInBytes option processing.
31 * @library /testlibrary
32 * @requires vm.opt.SurvivorAlignmentInBytes == null
33 * & vm.opt.ObjectAlignmentInBytes == null
34 * & vm.opt.UnlockExperimentalVMOptions == null
35 * & (vm.opt.IgnoreUnrecognizedVMOptions == null
36 * | vm.opt.IgnoreUnrecognizedVMOptions == "false")
37 * @run main TestSurvivorAlignmentInBytesOption
38 */
39 public class TestSurvivorAlignmentInBytesOption {
40 public static void main(String args[]) throws Throwable {
41 String optionName = "SurvivorAlignmentInBytes";
42 String unlockExperimentalVMOpts = "UnlockExperimentalVMOptions";
43 String optionIsExperimental
44 = CommandLineOptionTest.getExperimentalOptionErrorMessage(
45 optionName);
46 String valueIsTooSmall= ".*SurvivorAlignmentInBytes=.*must be greater"
47 + " than ObjectAlignmentInBytes.*";
48 String mustBePowerOf2 = ".*SurvivorAlignmentInBytes=.*must be "
49 + "power of 2.*";
51 // Verify that without -XX:+UnlockExperimentalVMOptions usage of
52 // SurvivorAlignmentInBytes option will cause JVM startup failure
53 // with the warning message saying that that option is experimental.
54 CommandLineOptionTest.verifyJVMStartup(
55 new String[]{optionIsExperimental}, null, ExitCode.FAIL, false,
56 "-XX:-UnlockExperimentalVMOptions",
57 CommandLineOptionTest.prepareBooleanFlag(
58 unlockExperimentalVMOpts, false),
59 CommandLineOptionTest.prepareNumericFlag(optionName, 64));
61 // Verify that with -XX:+UnlockExperimentalVMOptions passed to JVM
62 // usage of SurvivorAlignmentInBytes option won't cause JVM startup
63 // failure.
64 CommandLineOptionTest.verifyJVMStartup(
65 null, new String[]{optionIsExperimental}, ExitCode.OK, false,
66 CommandLineOptionTest.prepareBooleanFlag(
67 unlockExperimentalVMOpts, true),
68 CommandLineOptionTest.prepareNumericFlag(optionName, 64));
70 // Verify that if specified SurvivorAlignmentInBytes is lower then
71 // ObjectAlignmentInBytes, then the JVM startup will fail with
72 // appropriate error message.
73 CommandLineOptionTest.verifyJVMStartup(
74 new String[]{valueIsTooSmall}, null, ExitCode.FAIL, false,
75 CommandLineOptionTest.prepareBooleanFlag(
76 unlockExperimentalVMOpts, true),
77 CommandLineOptionTest.prepareNumericFlag(optionName, 2));
79 // Verify that if specified SurvivorAlignmentInBytes value is not
80 // a power of 2 then the JVM startup will fail with appropriate error
81 // message.
82 CommandLineOptionTest.verifyJVMStartup(
83 new String[]{mustBePowerOf2}, null, ExitCode.FAIL, false,
84 CommandLineOptionTest.prepareBooleanFlag(
85 unlockExperimentalVMOpts, true),
86 CommandLineOptionTest.prepareNumericFlag(optionName, 127));
88 // Verify that if SurvivorAlignmentInBytes has correct value, then
89 // the JVM will be started without errors.
90 CommandLineOptionTest.verifyJVMStartup(
91 null, new String[]{".*SurvivorAlignmentInBytes.*"},
92 ExitCode.OK, false,
93 CommandLineOptionTest.prepareBooleanFlag(
94 unlockExperimentalVMOpts, true),
95 CommandLineOptionTest.prepareNumericFlag(optionName, 128));
97 // Verify that we can setup different SurvivorAlignmentInBytes values.
98 for (int alignment = 32; alignment <= 128; alignment *= 2) {
99 CommandLineOptionTest.verifyOptionValue(optionName,
100 Integer.toString(alignment),
101 CommandLineOptionTest.prepareBooleanFlag(
102 unlockExperimentalVMOpts, true),
103 CommandLineOptionTest.prepareNumericFlag(
104 optionName, alignment));
105 }
106 }
107 }