author | ykantser |
Fri, 13 Feb 2015 13:17:13 +0100 | |
changeset 29069 | 938c1c97ad3b |
parent 28363 | 047115468f16 |
child 29678 | dd2f3932c21e |
child 30123 | 7a8b6bd85e24 |
permissions | -rw-r--r-- |
28363
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
1 |
/* |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
4 |
* |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
8 |
* |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
13 |
* accompanied this code). |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
14 |
* |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
18 |
* |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
21 |
* questions. |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
22 |
*/ |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
23 |
|
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
24 |
/* |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
25 |
* @test |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
26 |
* @bug 8059510 |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
27 |
* @summary Test SharedSymbolTableBucketSize option |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
28 |
* @library /testlibrary |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
29 |
*/ |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
30 |
|
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
31 |
import com.oracle.java.testlibrary.*; |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
32 |
|
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
33 |
public class SharedSymbolTableBucketSize { |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
34 |
public static void main(String[] args) throws Exception { |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
35 |
int bucket_size = 8; |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
36 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
37 |
"-Xshare:dump", "-XX:+PrintSharedSpaces", |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
38 |
"-XX:+UnlockDiagnosticVMOptions", |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
39 |
"-XX:SharedArchiveFile=./sample.jsa", |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
40 |
"-XX:SharedSymbolTableBucketSize=" + Integer.valueOf(bucket_size)); |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
41 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
42 |
output.shouldContain("Loading classes to share"); |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
43 |
output.shouldHaveExitValue(0); |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
44 |
|
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
45 |
String s = output.firstMatch("Average bucket size : .*"); |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
46 |
Float f = Float.parseFloat(s.substring(25)); |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
47 |
int size = Math.round(f); |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
48 |
if (size != bucket_size) { |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
49 |
throw new Exception("FAILED: incorrect bucket size " + size + |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
50 |
", expect " + bucket_size); |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
51 |
} |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
52 |
|
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
53 |
|
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
54 |
// Invalid SharedSymbolTableBucketSize input |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
55 |
String input[] = {"-XX:SharedSymbolTableBucketSize=-1", |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
56 |
"-XX:SharedSymbolTableBucketSize=2.5"}; |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
57 |
for (int i = 0; i < input.length; i++) { |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
58 |
pb = ProcessTools.createJavaProcessBuilder( |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
59 |
"-Xshare:dump", "-XX:+PrintSharedSpaces", |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
60 |
"-XX:+UnlockDiagnosticVMOptions", |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
61 |
"-XX:SharedArchiveFile=./sample.jsa", |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
62 |
input[i]); |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
63 |
output = new OutputAnalyzer(pb.start()); |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
64 |
output.shouldContain("Improperly specified VM option"); |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
65 |
} |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
66 |
} |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
diff
changeset
|
67 |
} |