1 /* |
|
2 * Copyright (c) 2013, 2018, 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 */ |
|
23 |
|
24 /** |
|
25 * @test CdsDifferentObjectAlignment |
|
26 * @summary Testing CDS (class data sharing) using varying object alignment. |
|
27 * Using different object alignment for each dump/load pair. |
|
28 * This is a negative test; using object alignment for loading that |
|
29 * is different from object alignment for creating a CDS file |
|
30 * should fail when loading. |
|
31 * @requires vm.cds |
|
32 * @requires vm.bits == 64 |
|
33 * @library /test/lib |
|
34 * @bug 8025642 |
|
35 * @modules java.base/jdk.internal.misc |
|
36 * java.management |
|
37 * @run driver CdsDifferentObjectAlignment |
|
38 */ |
|
39 |
|
40 import jdk.test.lib.cds.CDSTestUtils; |
|
41 import jdk.test.lib.process.OutputAnalyzer; |
|
42 import jdk.test.lib.Platform; |
|
43 |
|
44 public class CdsDifferentObjectAlignment { |
|
45 |
|
46 public static void main(String[] args) throws Exception { |
|
47 createAndLoadSharedArchive(16, 64); |
|
48 createAndLoadSharedArchive(64, 32); |
|
49 } |
|
50 |
|
51 // Parameters are object alignment expressed in bytes |
|
52 private static void |
|
53 createAndLoadSharedArchive(int createAlignment, int loadAlignment) |
|
54 throws Exception { |
|
55 String createAlignmentArgument = "-XX:ObjectAlignmentInBytes=" + |
|
56 createAlignment; |
|
57 String loadAlignmentArgument = "-XX:ObjectAlignmentInBytes=" + |
|
58 loadAlignment; |
|
59 String expectedErrorMsg = |
|
60 String.format( |
|
61 "The shared archive file's ObjectAlignmentInBytes of %d " + |
|
62 "does not equal the current ObjectAlignmentInBytes of %d", |
|
63 createAlignment, |
|
64 loadAlignment); |
|
65 |
|
66 CDSTestUtils.createArchiveAndCheck(createAlignmentArgument); |
|
67 |
|
68 OutputAnalyzer out = CDSTestUtils.runWithArchive(loadAlignmentArgument); |
|
69 CDSTestUtils.checkExecExpectError(out, 1, expectedErrorMsg); |
|
70 } |
|
71 } |
|