1 /*
2 * Copyright (c) 2003, 2011, 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
40 import sun.security.action.GetPropertyAction;
41
42 /**
43 * Implementation of VMManagement interface that accesses the management
44 * attributes and operations locally within the same Java virtual
45 * machine.
46 */
47 class VMManagementImpl implements VMManagement {
48
49 private static String version;
50
51 private static boolean compTimeMonitoringSupport;
52 private static boolean threadContentionMonitoringSupport;
53 private static boolean currentThreadCpuTimeSupport;
54 private static boolean otherThreadCpuTimeSupport;
55 private static boolean bootClassPathSupport;
56 private static boolean objectMonitorUsageSupport;
57 private static boolean synchronizerUsageSupport;
58 private static boolean threadAllocatedMemorySupport;
59 private static boolean gcNotificationSupport;
60
61
62 static {
63 version = getVersion0();
64 if (version == null) {
65 throw new AssertionError("Invalid Management Version");
66 }
67 initOptionalSupportFields();
68 }
69 private native static String getVersion0();
70 private native static void initOptionalSupportFields();
71
72 // Optional supports
73 public boolean isCompilationTimeMonitoringSupported() {
74 return compTimeMonitoringSupport;
75 }
76
77 public boolean isThreadContentionMonitoringSupported() {
78 return threadContentionMonitoringSupport;
79 }
89 public boolean isBootClassPathSupported() {
90 return bootClassPathSupport;
91 }
92
93 public boolean isObjectMonitorUsageSupported() {
94 return objectMonitorUsageSupport;
95 }
96
97 public boolean isSynchronizerUsageSupported() {
98 return synchronizerUsageSupport;
99 }
100
101 public boolean isThreadAllocatedMemorySupported() {
102 return threadAllocatedMemorySupport;
103 }
104
105 public boolean isGcNotificationSupported() {
106 return gcNotificationSupport;
107 }
108
109 public native boolean isThreadContentionMonitoringEnabled();
110 public native boolean isThreadCpuTimeEnabled();
111 public native boolean isThreadAllocatedMemoryEnabled();
112
113 // Class Loading Subsystem
114 public int getLoadedClassCount() {
115 long count = getTotalClassCount() - getUnloadedClassCount();
116 return (int) count;
117 }
118 public native long getTotalClassCount();
119 public native long getUnloadedClassCount();
120
121 public native boolean getVerboseClass();
122
123 // Memory Subsystem
124 public native boolean getVerboseGC();
125
126 // Runtime Subsystem
127 public String getManagementVersion() {
128 return version;
251 }
252 perfInstr = new PerfInstrumentation(bb);
253 } catch (IllegalArgumentException e) {
254 // If the shared memory doesn't exist e.g. if -XX:-UsePerfData
255 // was set
256 noPerfData = true;
257 } catch (IOException e) {
258 throw new AssertionError(e);
259 }
260 return perfInstr;
261 }
262
263 public List<Counter> getInternalCounters(String pattern) {
264 PerfInstrumentation perf = getPerfInstrumentation();
265 if (perf != null) {
266 return perf.findByPattern(pattern);
267 } else {
268 return Collections.emptyList();
269 }
270 }
271 }
|
1 /*
2 * Copyright (c) 2003, 2012, 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
40 import sun.security.action.GetPropertyAction;
41
42 /**
43 * Implementation of VMManagement interface that accesses the management
44 * attributes and operations locally within the same Java virtual
45 * machine.
46 */
47 class VMManagementImpl implements VMManagement {
48
49 private static String version;
50
51 private static boolean compTimeMonitoringSupport;
52 private static boolean threadContentionMonitoringSupport;
53 private static boolean currentThreadCpuTimeSupport;
54 private static boolean otherThreadCpuTimeSupport;
55 private static boolean bootClassPathSupport;
56 private static boolean objectMonitorUsageSupport;
57 private static boolean synchronizerUsageSupport;
58 private static boolean threadAllocatedMemorySupport;
59 private static boolean gcNotificationSupport;
60 private static boolean remoteDiagnosticCommandsSupport;
61
62
63 static {
64 version = getVersion0();
65 if (version == null) {
66 throw new AssertionError("Invalid Management Version");
67 }
68 initOptionalSupportFields();
69 }
70 private native static String getVersion0();
71 private native static void initOptionalSupportFields();
72
73 // Optional supports
74 public boolean isCompilationTimeMonitoringSupported() {
75 return compTimeMonitoringSupport;
76 }
77
78 public boolean isThreadContentionMonitoringSupported() {
79 return threadContentionMonitoringSupport;
80 }
90 public boolean isBootClassPathSupported() {
91 return bootClassPathSupport;
92 }
93
94 public boolean isObjectMonitorUsageSupported() {
95 return objectMonitorUsageSupport;
96 }
97
98 public boolean isSynchronizerUsageSupported() {
99 return synchronizerUsageSupport;
100 }
101
102 public boolean isThreadAllocatedMemorySupported() {
103 return threadAllocatedMemorySupport;
104 }
105
106 public boolean isGcNotificationSupported() {
107 return gcNotificationSupport;
108 }
109
110 public boolean isRemoteDiagnosticCommandsSupported() {
111 return remoteDiagnosticCommandsSupport;
112 }
113
114 public native boolean isThreadContentionMonitoringEnabled();
115 public native boolean isThreadCpuTimeEnabled();
116 public native boolean isThreadAllocatedMemoryEnabled();
117
118 // Class Loading Subsystem
119 public int getLoadedClassCount() {
120 long count = getTotalClassCount() - getUnloadedClassCount();
121 return (int) count;
122 }
123 public native long getTotalClassCount();
124 public native long getUnloadedClassCount();
125
126 public native boolean getVerboseClass();
127
128 // Memory Subsystem
129 public native boolean getVerboseGC();
130
131 // Runtime Subsystem
132 public String getManagementVersion() {
133 return version;
256 }
257 perfInstr = new PerfInstrumentation(bb);
258 } catch (IllegalArgumentException e) {
259 // If the shared memory doesn't exist e.g. if -XX:-UsePerfData
260 // was set
261 noPerfData = true;
262 } catch (IOException e) {
263 throw new AssertionError(e);
264 }
265 return perfInstr;
266 }
267
268 public List<Counter> getInternalCounters(String pattern) {
269 PerfInstrumentation perf = getPerfInstrumentation();
270 if (perf != null) {
271 return perf.findByPattern(pattern);
272 } else {
273 return Collections.emptyList();
274 }
275 }
276
277 @Override
278 public native String[] getDiagnosticCommands();
279 @Override
280 public native DiagnosticCommandInfo[] getDiagnosticCommandInfo(String[] commands);
281 @Override
282 public native String executeDiagnosticCommand(String command);
283 }
|