author | iignatyev |
Wed, 17 Jan 2018 21:44:44 -0800 | |
changeset 48791 | 6e079ff6c83c |
parent 47216 | 71c04702a3d5 |
child 53523 | 4c5184c56dc2 |
permissions | -rw-r--r-- |
19322
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
1 |
/* |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
30604
diff
changeset
|
2 |
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. |
19322
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
4 |
* |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
8 |
* |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
13 |
* accompanied this code). |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
14 |
* |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
18 |
* |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
21 |
* questions. |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
22 |
*/ |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
23 |
|
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
24 |
import java.lang.management.RuntimeMXBean; |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
25 |
import java.lang.management.ManagementFactory; |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
26 |
import java.util.List; |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
27 |
|
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
28 |
/** |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
29 |
* This class provides access to the input arguments to the VM. |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
30 |
*/ |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
31 |
public class InputArguments { |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
32 |
private static final List<String> args; |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
33 |
|
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
34 |
static { |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
35 |
RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
36 |
args = runtimeMxBean.getInputArguments(); |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
37 |
} |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
38 |
|
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
39 |
/** |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
40 |
* Returns true if {@code arg} is an input argument to the VM. |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
41 |
* |
20001
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
42 |
* This is useful for checking boolean flags such as -XX:+UseSerialGC or |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
43 |
* -XX:-UsePerfData. |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
44 |
* |
19322
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
45 |
* @param arg The name of the argument. |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
46 |
* @return {@code true} if the given argument is an input argument, |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
47 |
* otherwise {@code false}. |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
48 |
*/ |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
49 |
public static boolean contains(String arg) { |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
50 |
return args.contains(arg); |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
51 |
} |
20001
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
52 |
|
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
53 |
/** |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
54 |
* Returns true if {@code prefix} is the start of an input argument to the |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
55 |
* VM. |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
56 |
* |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
57 |
* This is useful for checking if flags describing a quantity, such as |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
58 |
* -XX:+MaxMetaspaceSize=100m, is set without having to know the quantity. |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
59 |
* To check if the flag -XX:MaxMetaspaceSize is set, use |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
60 |
* {@code InputArguments.containsPrefix("-XX:MaxMetaspaceSize")}. |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
61 |
* |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
62 |
* @param prefix The start of the argument. |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
63 |
* @return {@code true} if the given argument is the start of an input |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
64 |
* argument, otherwise {@code false}. |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
65 |
*/ |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
66 |
public static boolean containsPrefix(String prefix) { |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
67 |
for (String arg : args) { |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
68 |
if (arg.startsWith(prefix)) { |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
69 |
return true; |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
70 |
} |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
71 |
} |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
72 |
return false; |
7446501f55bc
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
19322
diff
changeset
|
73 |
} |
19322
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
diff
changeset
|
74 |
} |