Sun, 03 Feb 2013 22:28:08 +0400
8002048: Protocol to discovery of manageable Java processes on a network
Summary: Introduce a protocol to discover manageble Java instances across a network subnet, JDP
Reviewed-by: sla, dfuchs
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
23 * questions.
24 */
26 #ifndef _JAVA_JMM_H_
27 #define _JAVA_JMM_H_
29 /*
30 * This is a private interface used by JDK for JVM monitoring
31 * and management.
32 *
33 * Bump the version number when either of the following happens:
34 *
35 * 1. There is a change in functions in JmmInterface.
36 *
37 * 2. There is a change in the contract between VM and Java classes.
38 */
40 #include "jni.h"
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
46 enum {
47 JMM_VERSION_1 = 0x20010000,
48 JMM_VERSION_1_0 = 0x20010000,
49 JMM_VERSION_1_1 = 0x20010100, // JDK 6
50 JMM_VERSION_1_2 = 0x20010200, // JDK 7
51 JMM_VERSION_1_2_1 = 0x20010201, // JDK 7 GA
52 JMM_VERSION = 0x20010202
53 };
55 typedef struct {
56 unsigned int isLowMemoryDetectionSupported : 1;
57 unsigned int isCompilationTimeMonitoringSupported : 1;
58 unsigned int isThreadContentionMonitoringSupported : 1;
59 unsigned int isCurrentThreadCpuTimeSupported : 1;
60 unsigned int isOtherThreadCpuTimeSupported : 1;
61 unsigned int isBootClassPathSupported : 1;
62 unsigned int isObjectMonitorUsageSupported : 1;
63 unsigned int isSynchronizerUsageSupported : 1;
64 unsigned int isThreadAllocatedMemorySupported : 1;
65 unsigned int : 23;
66 } jmmOptionalSupport;
68 typedef enum {
69 JMM_CLASS_LOADED_COUNT = 1, /* Total number of loaded classes */
70 JMM_CLASS_UNLOADED_COUNT = 2, /* Total number of unloaded classes */
71 JMM_THREAD_TOTAL_COUNT = 3, /* Total number of threads that have been started */
72 JMM_THREAD_LIVE_COUNT = 4, /* Current number of live threads */
73 JMM_THREAD_PEAK_COUNT = 5, /* Peak number of live threads */
74 JMM_THREAD_DAEMON_COUNT = 6, /* Current number of daemon threads */
75 JMM_JVM_INIT_DONE_TIME_MS = 7, /* Time when the JVM finished initialization */
76 JMM_COMPILE_TOTAL_TIME_MS = 8, /* Total accumulated time spent in compilation */
77 JMM_GC_TIME_MS = 9, /* Total accumulated time spent in collection */
78 JMM_GC_COUNT = 10, /* Total number of collections */
80 JMM_INTERNAL_ATTRIBUTE_INDEX = 100,
81 JMM_CLASS_LOADED_BYTES = 101, /* Number of bytes loaded instance classes */
82 JMM_CLASS_UNLOADED_BYTES = 102, /* Number of bytes unloaded instance classes */
83 JMM_TOTAL_CLASSLOAD_TIME_MS = 103, /* Accumulated VM class loader time (TraceClassLoadingTime) */
84 JMM_VM_GLOBAL_COUNT = 104, /* Number of VM internal flags */
85 JMM_SAFEPOINT_COUNT = 105, /* Total number of safepoints */
86 JMM_TOTAL_SAFEPOINTSYNC_TIME_MS = 106, /* Accumulated time spent getting to safepoints */
87 JMM_TOTAL_STOPPED_TIME_MS = 107, /* Accumulated time spent at safepoints */
88 JMM_TOTAL_APP_TIME_MS = 108, /* Accumulated time spent in Java application */
89 JMM_VM_THREAD_COUNT = 109, /* Current number of VM internal threads */
90 JMM_CLASS_INIT_TOTAL_COUNT = 110, /* Number of classes for which initializers were run */
91 JMM_CLASS_INIT_TOTAL_TIME_MS = 111, /* Accumulated time spent in class initializers */
92 JMM_METHOD_DATA_SIZE_BYTES = 112, /* Size of method data in memory */
93 JMM_CLASS_VERIFY_TOTAL_TIME_MS = 113, /* Accumulated time spent in class verifier */
94 JMM_SHARED_CLASS_LOADED_COUNT = 114, /* Number of shared classes loaded */
95 JMM_SHARED_CLASS_UNLOADED_COUNT = 115, /* Number of shared classes unloaded */
96 JMM_SHARED_CLASS_LOADED_BYTES = 116, /* Number of bytes loaded shared classes */
97 JMM_SHARED_CLASS_UNLOADED_BYTES = 117, /* Number of bytes unloaded shared classes */
99 JMM_OS_ATTRIBUTE_INDEX = 200,
100 JMM_OS_PROCESS_ID = 201, /* Process id of the JVM */
101 JMM_OS_MEM_TOTAL_PHYSICAL_BYTES = 202, /* Physical memory size */
103 JMM_GC_EXT_ATTRIBUTE_INFO_SIZE = 401 /* the size of the GC specific attributes for a given GC memory manager */
104 } jmmLongAttribute;
106 typedef enum {
107 JMM_VERBOSE_GC = 21,
108 JMM_VERBOSE_CLASS = 22,
109 JMM_THREAD_CONTENTION_MONITORING = 23,
110 JMM_THREAD_CPU_TIME = 24,
111 JMM_THREAD_ALLOCATED_MEMORY = 25
112 } jmmBoolAttribute;
115 enum {
116 JMM_THREAD_STATE_FLAG_SUSPENDED = 0x00100000,
117 JMM_THREAD_STATE_FLAG_NATIVE = 0x00400000
118 };
120 #define JMM_THREAD_STATE_FLAG_MASK 0xFFF00000
122 typedef enum {
123 JMM_STAT_PEAK_THREAD_COUNT = 801,
124 JMM_STAT_THREAD_CONTENTION_COUNT = 802,
125 JMM_STAT_THREAD_CONTENTION_TIME = 803,
126 JMM_STAT_THREAD_CONTENTION_STAT = 804,
127 JMM_STAT_PEAK_POOL_USAGE = 805,
128 JMM_STAT_GC_STAT = 806
129 } jmmStatisticType;
131 typedef enum {
132 JMM_USAGE_THRESHOLD_HIGH = 901,
133 JMM_USAGE_THRESHOLD_LOW = 902,
134 JMM_COLLECTION_USAGE_THRESHOLD_HIGH = 903,
135 JMM_COLLECTION_USAGE_THRESHOLD_LOW = 904
136 } jmmThresholdType;
138 /* Should match what is allowed in globals.hpp */
139 typedef enum {
140 JMM_VMGLOBAL_TYPE_UNKNOWN = 0,
141 JMM_VMGLOBAL_TYPE_JBOOLEAN = 1,
142 JMM_VMGLOBAL_TYPE_JSTRING = 2,
143 JMM_VMGLOBAL_TYPE_JLONG = 3
144 } jmmVMGlobalType;
146 typedef enum {
147 JMM_VMGLOBAL_ORIGIN_DEFAULT = 1, /* Default value */
148 JMM_VMGLOBAL_ORIGIN_COMMAND_LINE = 2, /* Set at command line (or JNI invocation) */
149 JMM_VMGLOBAL_ORIGIN_MANAGEMENT = 3, /* Set via management interface */
150 JMM_VMGLOBAL_ORIGIN_ENVIRON_VAR = 4, /* Set via environment variables */
151 JMM_VMGLOBAL_ORIGIN_CONFIG_FILE = 5, /* Set via config file (such as .hotspotrc) */
152 JMM_VMGLOBAL_ORIGIN_ERGONOMIC = 6, /* Set via ergonomic */
153 JMM_VMGLOBAL_ORIGIN_OTHER = 99 /* Set via some other mechanism */
154 } jmmVMGlobalOrigin;
156 typedef struct {
157 jstring name;
158 jvalue value;
159 jmmVMGlobalType type; /* Data type */
160 jmmVMGlobalOrigin origin; /* Default or non-default value */
161 unsigned int writeable : 1; /* dynamically writeable */
162 unsigned int external : 1; /* external supported interface */
163 unsigned int reserved : 30;
164 void *reserved1;
165 void *reserved2;
166 } jmmVMGlobal;
168 typedef struct {
169 const char* name;
170 char type;
171 const char* description;
172 } jmmExtAttributeInfo;
174 /* Caller has to set the following fields before calling GetLastGCStat
175 * o usage_before_gc - array of MemoryUsage objects
176 * o usage_after_gc - array of MemoryUsage objects
177 * o gc_ext_attribute_values_size - size of gc_ext_atttribute_values array
178 * o gc_ext_attribtue_values - array of jvalues
179 */
180 typedef struct {
181 jlong gc_index; /* Index of the collections */
182 jlong start_time; /* Start time of the GC */
183 jlong end_time; /* End time of the GC */
184 jobjectArray usage_before_gc; /* Memory usage array before GC */
185 jobjectArray usage_after_gc; /* Memory usage array after GC */
186 jint gc_ext_attribute_values_size; /* set by the caller of GetGCStat */
187 jvalue* gc_ext_attribute_values; /* Array of jvalue for GC extension attributes */
188 jint num_gc_ext_attributes; /* number of GC extension attribute values s are filled */
189 /* -1 indicates gc_ext_attribute_values is not big enough */
190 } jmmGCStat;
192 typedef struct {
193 const char* name;
194 const char* description;
195 const char* impact;
196 int num_arguments;
197 jboolean enabled;
198 } dcmdInfo;
200 typedef struct {
201 const char* name;
202 const char* description;
203 const char* type;
204 const char* default_string;
205 jboolean mandatory;
206 jboolean option;
207 int position;
208 } dcmdArgInfo;
210 typedef struct jmmInterface_1_ {
211 void* reserved1;
212 void* reserved2;
214 jint (JNICALL *GetVersion) (JNIEnv *env);
216 jint (JNICALL *GetOptionalSupport) (JNIEnv *env,
217 jmmOptionalSupport* support_ptr);
219 /* This is used by JDK 6 and earlier.
220 * For JDK 7 and after, use GetInputArgumentArray.
221 */
222 jobject (JNICALL *GetInputArguments) (JNIEnv *env);
224 jint (JNICALL *GetThreadInfo) (JNIEnv *env,
225 jlongArray ids,
226 jint maxDepth,
227 jobjectArray infoArray);
228 jobjectArray (JNICALL *GetInputArgumentArray) (JNIEnv *env);
230 jobjectArray (JNICALL *GetMemoryPools) (JNIEnv* env, jobject mgr);
232 jobjectArray (JNICALL *GetMemoryManagers) (JNIEnv* env, jobject pool);
234 jobject (JNICALL *GetMemoryPoolUsage) (JNIEnv* env, jobject pool);
235 jobject (JNICALL *GetPeakMemoryPoolUsage) (JNIEnv* env, jobject pool);
237 void (JNICALL *GetThreadAllocatedMemory)
238 (JNIEnv *env,
239 jlongArray ids,
240 jlongArray sizeArray);
242 jobject (JNICALL *GetMemoryUsage) (JNIEnv* env, jboolean heap);
244 jlong (JNICALL *GetLongAttribute) (JNIEnv *env, jobject obj, jmmLongAttribute att);
245 jboolean (JNICALL *GetBoolAttribute) (JNIEnv *env, jmmBoolAttribute att);
246 jboolean (JNICALL *SetBoolAttribute) (JNIEnv *env, jmmBoolAttribute att, jboolean flag);
248 jint (JNICALL *GetLongAttributes) (JNIEnv *env,
249 jobject obj,
250 jmmLongAttribute* atts,
251 jint count,
252 jlong* result);
254 jobjectArray (JNICALL *FindCircularBlockedThreads) (JNIEnv *env);
256 // Not used in JDK 6 or JDK 7
257 jlong (JNICALL *GetThreadCpuTime) (JNIEnv *env, jlong thread_id);
259 jobjectArray (JNICALL *GetVMGlobalNames) (JNIEnv *env);
260 jint (JNICALL *GetVMGlobals) (JNIEnv *env,
261 jobjectArray names,
262 jmmVMGlobal *globals,
263 jint count);
265 jint (JNICALL *GetInternalThreadTimes) (JNIEnv *env,
266 jobjectArray names,
267 jlongArray times);
269 jboolean (JNICALL *ResetStatistic) (JNIEnv *env,
270 jvalue obj,
271 jmmStatisticType type);
273 void (JNICALL *SetPoolSensor) (JNIEnv *env,
274 jobject pool,
275 jmmThresholdType type,
276 jobject sensor);
278 jlong (JNICALL *SetPoolThreshold) (JNIEnv *env,
279 jobject pool,
280 jmmThresholdType type,
281 jlong threshold);
282 jobject (JNICALL *GetPoolCollectionUsage) (JNIEnv* env, jobject pool);
284 jint (JNICALL *GetGCExtAttributeInfo) (JNIEnv *env,
285 jobject mgr,
286 jmmExtAttributeInfo *ext_info,
287 jint count);
288 void (JNICALL *GetLastGCStat) (JNIEnv *env,
289 jobject mgr,
290 jmmGCStat *gc_stat);
292 jlong (JNICALL *GetThreadCpuTimeWithKind)
293 (JNIEnv *env,
294 jlong thread_id,
295 jboolean user_sys_cpu_time);
296 void (JNICALL *GetThreadCpuTimesWithKind)
297 (JNIEnv *env,
298 jlongArray ids,
299 jlongArray timeArray,
300 jboolean user_sys_cpu_time);
302 jint (JNICALL *DumpHeap0) (JNIEnv *env,
303 jstring outputfile,
304 jboolean live);
305 jobjectArray (JNICALL *FindDeadlocks) (JNIEnv *env,
306 jboolean object_monitors_only);
307 void (JNICALL *SetVMGlobal) (JNIEnv *env,
308 jstring flag_name,
309 jvalue new_value);
310 void* reserved6;
311 jobjectArray (JNICALL *DumpThreads) (JNIEnv *env,
312 jlongArray ids,
313 jboolean lockedMonitors,
314 jboolean lockedSynchronizers);
315 void (JNICALL *SetGCNotificationEnabled) (JNIEnv *env,
316 jobject mgr,
317 jboolean enabled);
318 jobjectArray (JNICALL *GetDiagnosticCommands) (JNIEnv *env);
319 void (JNICALL *GetDiagnosticCommandInfo)
320 (JNIEnv *env,
321 jobjectArray cmds,
322 dcmdInfo *infoArray);
323 void (JNICALL *GetDiagnosticCommandArgumentsInfo)
324 (JNIEnv *env,
325 jstring commandName,
326 dcmdArgInfo *infoArray);
327 jstring (JNICALL *ExecuteDiagnosticCommand)
328 (JNIEnv *env,
329 jstring command);
330 } JmmInterface;
332 #ifdef __cplusplus
333 } /* extern "C" */
334 #endif /* __cplusplus */
336 #endif /* !_JAVA_JMM_H_ */