Mercurial > hg > truffle
annotate test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java @ 12781:6ae55c10796f
Merge.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 19 Nov 2013 01:39:08 +0100 |
parents | 7944aba7ba41 |
children |
rev | line source |
---|---|
8114
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
1 /* |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
4 * |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
8 * |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
13 * accompanied this code). |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
14 * |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
18 * |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
21 * questions. |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
22 */ |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
23 |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
24 /* |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
8856
diff
changeset
|
25 * @test CompressedClassSpaceSizeInJmapHeap |
8114
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
26 * @bug 8004924 |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
8856
diff
changeset
|
27 * @summary Checks that jmap -heap contains the flag CompressedClassSpaceSize |
8114
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
28 * @library /testlibrary |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
8856
diff
changeset
|
29 * @run main/othervm -XX:CompressedClassSpaceSize=50m CompressedClassSpaceSizeInJmapHeap |
8114
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
30 */ |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
31 |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
32 import com.oracle.java.testlibrary.*; |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
33 import java.nio.file.*; |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
34 import java.io.File; |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
35 import java.nio.charset.Charset; |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
36 import java.util.List; |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
37 |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
8856
diff
changeset
|
38 public class CompressedClassSpaceSizeInJmapHeap { |
8114
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
39 public static void main(String[] args) throws Exception { |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
40 String pid = Integer.toString(ProcessTools.getProcessId()); |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
41 |
8856
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
8114
diff
changeset
|
42 JDKToolLauncher jmap = JDKToolLauncher.create("jmap") |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
8114
diff
changeset
|
43 .addToolArg("-heap") |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
8114
diff
changeset
|
44 .addToolArg(pid); |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
8114
diff
changeset
|
45 ProcessBuilder pb = new ProcessBuilder(jmap.getCommand()); |
8114
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
46 |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
8856
diff
changeset
|
47 File out = new File("CompressedClassSpaceSizeInJmapHeap.stdout.txt"); |
8114
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
48 pb.redirectOutput(out); |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
49 |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
8856
diff
changeset
|
50 File err = new File("CompressedClassSpaceSizeInJmapHeap.stderr.txt"); |
8114
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
51 pb.redirectError(err); |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
52 |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
53 run(pb); |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
54 |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
55 OutputAnalyzer output = new OutputAnalyzer(read(out)); |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
8856
diff
changeset
|
56 output.shouldContain("CompressedClassSpaceSize = 52428800 (50.0MB)"); |
8114
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
57 out.delete(); |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
58 } |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
59 |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
60 private static void run(ProcessBuilder pb) throws Exception { |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
61 Process p = pb.start(); |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
62 p.waitFor(); |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
63 int exitValue = p.exitValue(); |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
64 if (exitValue != 0) { |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
65 throw new Exception("jmap -heap exited with error code: " + exitValue); |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
66 } |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
67 } |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
68 |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
69 private static String read(File f) throws Exception { |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
70 Path p = f.toPath(); |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
71 List<String> lines = Files.readAllLines(p, Charset.defaultCharset()); |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
72 |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
73 StringBuilder sb = new StringBuilder(); |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
74 for (String line : lines) { |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
75 sb.append(line).append('\n'); |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
76 } |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
77 return sb.toString(); |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
78 } |
9a094d29af19
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
79 } |