author | sundar |
Fri, 22 Aug 2014 22:50:38 +0530 | |
changeset 26238 | 829648e12198 |
parent 23509 | 08e26f93c9a5 |
child 28733 | 0fc2c4609840 |
permissions | -rw-r--r-- |
15811
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
1 |
/* |
8214dcd0be2a
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. |
8214dcd0be2a
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. |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
4 |
* |
8214dcd0be2a
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 |
8214dcd0be2a
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 |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
8 |
* |
8214dcd0be2a
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 |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8214dcd0be2a
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 |
8214dcd0be2a
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 |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
13 |
* accompanied this code). |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
14 |
* |
8214dcd0be2a
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 |
8214dcd0be2a
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, |
8214dcd0be2a
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. |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
18 |
* |
8214dcd0be2a
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 |
8214dcd0be2a
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 |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
21 |
* questions. |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
22 |
*/ |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
23 |
|
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
24 |
/* |
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
16607
diff
changeset
|
25 |
* @test CompressedClassSpaceSizeInJmapHeap |
15811
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
26 |
* @bug 8004924 |
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
16607
diff
changeset
|
27 |
* @summary Checks that jmap -heap contains the flag CompressedClassSpaceSize |
15811
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
28 |
* @library /testlibrary |
23509
08e26f93c9a5
8027924: gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java fails with warning
ehelin
parents:
19979
diff
changeset
|
29 |
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:CompressedClassSpaceSize=50m CompressedClassSpaceSizeInJmapHeap |
15811
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
30 |
*/ |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
31 |
|
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
32 |
import com.oracle.java.testlibrary.*; |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
33 |
import java.nio.file.*; |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
34 |
import java.io.File; |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
35 |
import java.nio.charset.Charset; |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
36 |
import java.util.List; |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
37 |
|
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
16607
diff
changeset
|
38 |
public class CompressedClassSpaceSizeInJmapHeap { |
15811
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
39 |
public static void main(String[] args) throws Exception { |
23509
08e26f93c9a5
8027924: gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java fails with warning
ehelin
parents:
19979
diff
changeset
|
40 |
if (!Platform.is64bit()) { |
08e26f93c9a5
8027924: gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java fails with warning
ehelin
parents:
19979
diff
changeset
|
41 |
// Compressed Class Space is only available on 64-bit JVMs |
08e26f93c9a5
8027924: gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java fails with warning
ehelin
parents:
19979
diff
changeset
|
42 |
return; |
08e26f93c9a5
8027924: gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java fails with warning
ehelin
parents:
19979
diff
changeset
|
43 |
} |
08e26f93c9a5
8027924: gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java fails with warning
ehelin
parents:
19979
diff
changeset
|
44 |
|
15811
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
45 |
String pid = Integer.toString(ProcessTools.getProcessId()); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
46 |
|
16607
2581c39b3b93
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
15811
diff
changeset
|
47 |
JDKToolLauncher jmap = JDKToolLauncher.create("jmap") |
2581c39b3b93
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
15811
diff
changeset
|
48 |
.addToolArg("-heap") |
2581c39b3b93
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
15811
diff
changeset
|
49 |
.addToolArg(pid); |
2581c39b3b93
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
15811
diff
changeset
|
50 |
ProcessBuilder pb = new ProcessBuilder(jmap.getCommand()); |
15811
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
51 |
|
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
16607
diff
changeset
|
52 |
File out = new File("CompressedClassSpaceSizeInJmapHeap.stdout.txt"); |
15811
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
53 |
pb.redirectOutput(out); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
54 |
|
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
16607
diff
changeset
|
55 |
File err = new File("CompressedClassSpaceSizeInJmapHeap.stderr.txt"); |
15811
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
56 |
pb.redirectError(err); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
57 |
|
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
58 |
run(pb); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
59 |
|
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
60 |
OutputAnalyzer output = new OutputAnalyzer(read(out)); |
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
16607
diff
changeset
|
61 |
output.shouldContain("CompressedClassSpaceSize = 52428800 (50.0MB)"); |
15811
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
62 |
out.delete(); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
63 |
} |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
64 |
|
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
65 |
private static void run(ProcessBuilder pb) throws Exception { |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
66 |
Process p = pb.start(); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
67 |
p.waitFor(); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
68 |
int exitValue = p.exitValue(); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
69 |
if (exitValue != 0) { |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
70 |
throw new Exception("jmap -heap exited with error code: " + exitValue); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
71 |
} |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
72 |
} |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
73 |
|
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
74 |
private static String read(File f) throws Exception { |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
75 |
Path p = f.toPath(); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
76 |
List<String> lines = Files.readAllLines(p, Charset.defaultCharset()); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
77 |
|
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
78 |
StringBuilder sb = new StringBuilder(); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
79 |
for (String line : lines) { |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
80 |
sb.append(line).append('\n'); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
81 |
} |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
82 |
return sb.toString(); |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
83 |
} |
8214dcd0be2a
8004924: NPG: jmap -heap output should contain ClassMetaspaceSize value
ehelin
parents:
diff
changeset
|
84 |
} |