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
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 */
39
40 #include "jni.h"
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
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 };
54
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;
67
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 */
79
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 */
173
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;
191
192 typedef struct {
193 const char* name;
194 const char* description;
195 const char* impact;
196 int num_arguments;
197 jboolean enabled;
198 } dcmdInfo;
199
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;
209
210 typedef struct jmmInterface_1_ {
211 void* reserved1;
212 void* reserved2;
213
214 jint (JNICALL *GetVersion) (JNIEnv *env);
215
216 jint (JNICALL *GetOptionalSupport) (JNIEnv *env,
217 jmmOptionalSupport* support_ptr);
218
219 /* This is used by JDK 6 and earlier.
220 * For JDK 7 and after, use GetInputArgumentArray.
221 */
222 jobject (JNICALL *GetInputArguments) (JNIEnv *env);
223
224 jint (JNICALL *GetThreadInfo) (JNIEnv *env,
225 jlongArray ids,
226 jint maxDepth,
227 jobjectArray infoArray);
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;
331
332 #ifdef __cplusplus
333 } /* extern "C" */
334 #endif /* __cplusplus */
335
336 #endif /* !_JAVA_JMM_H_ */
|
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
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 */
39
40 #include "jni.h"
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
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_1_2_2 = 0x20010202,
53 JMM_VERSION = 0x20010203
54 };
55
56 typedef struct {
57 unsigned int isLowMemoryDetectionSupported : 1;
58 unsigned int isCompilationTimeMonitoringSupported : 1;
59 unsigned int isThreadContentionMonitoringSupported : 1;
60 unsigned int isCurrentThreadCpuTimeSupported : 1;
61 unsigned int isOtherThreadCpuTimeSupported : 1;
62 unsigned int isBootClassPathSupported : 1;
63 unsigned int isObjectMonitorUsageSupported : 1;
64 unsigned int isSynchronizerUsageSupported : 1;
65 unsigned int isThreadAllocatedMemorySupported : 1;
66 unsigned int isRemoteDiagnosticCommandsSupported : 1;
67 unsigned int : 22;
68 } jmmOptionalSupport;
69
70 typedef enum {
71 JMM_CLASS_LOADED_COUNT = 1, /* Total number of loaded classes */
72 JMM_CLASS_UNLOADED_COUNT = 2, /* Total number of unloaded classes */
73 JMM_THREAD_TOTAL_COUNT = 3, /* Total number of threads that have been started */
74 JMM_THREAD_LIVE_COUNT = 4, /* Current number of live threads */
75 JMM_THREAD_PEAK_COUNT = 5, /* Peak number of live threads */
76 JMM_THREAD_DAEMON_COUNT = 6, /* Current number of daemon threads */
77 JMM_JVM_INIT_DONE_TIME_MS = 7, /* Time when the JVM finished initialization */
78 JMM_COMPILE_TOTAL_TIME_MS = 8, /* Total accumulated time spent in compilation */
79 JMM_GC_TIME_MS = 9, /* Total accumulated time spent in collection */
80 JMM_GC_COUNT = 10, /* Total number of collections */
81
82 JMM_INTERNAL_ATTRIBUTE_INDEX = 100,
83 JMM_CLASS_LOADED_BYTES = 101, /* Number of bytes loaded instance classes */
84 JMM_CLASS_UNLOADED_BYTES = 102, /* Number of bytes unloaded instance classes */
85 JMM_TOTAL_CLASSLOAD_TIME_MS = 103, /* Accumulated VM class loader time (TraceClassLoadingTime) */
86 JMM_VM_GLOBAL_COUNT = 104, /* Number of VM internal flags */
87 JMM_SAFEPOINT_COUNT = 105, /* Total number of safepoints */
175
176 /* Caller has to set the following fields before calling GetLastGCStat
177 * o usage_before_gc - array of MemoryUsage objects
178 * o usage_after_gc - array of MemoryUsage objects
179 * o gc_ext_attribute_values_size - size of gc_ext_atttribute_values array
180 * o gc_ext_attribtue_values - array of jvalues
181 */
182 typedef struct {
183 jlong gc_index; /* Index of the collections */
184 jlong start_time; /* Start time of the GC */
185 jlong end_time; /* End time of the GC */
186 jobjectArray usage_before_gc; /* Memory usage array before GC */
187 jobjectArray usage_after_gc; /* Memory usage array after GC */
188 jint gc_ext_attribute_values_size; /* set by the caller of GetGCStat */
189 jvalue* gc_ext_attribute_values; /* Array of jvalue for GC extension attributes */
190 jint num_gc_ext_attributes; /* number of GC extension attribute values s are filled */
191 /* -1 indicates gc_ext_attribute_values is not big enough */
192 } jmmGCStat;
193
194 typedef struct {
195 const char* name; /* Name of the diagnostic command */
196 const char* description; /* Short description */
197 const char* impact; /* Impact on the JVM */
198 const char* permission_class; /* Class name of the required permission if any */
199 const char* permission_name; /* Permission name of the required permission if any */
200 const char* permission_action; /* Action name of the required permission if any*/
201 int num_arguments; /* Number of supported options or arguments */
202 jboolean enabled; /* True if the diagnostic command can be invoked, false otherwise */
203 } dcmdInfo;
204
205 typedef struct {
206 const char* name; /* Option/Argument name*/
207 const char* description; /* Short description */
208 const char* type; /* Type: STRING, BOOLEAN, etc. */
209 const char* default_string; /* Default value in a parsable string */
210 jboolean mandatory; /* True if the option/argument is mandatory */
211 jboolean option; /* True if it is an option, false if it is an argument */
212 /* (see diagnosticFramework.hpp for option/argument definitions) */
213 jboolean multiple; /* True is the option can be specified several time */
214 int position; /* Expected position for this argument (this field is */
215 /* meaningless for options) */
216 } dcmdArgInfo;
217
218 typedef struct jmmInterface_1_ {
219 void* reserved1;
220 void* reserved2;
221
222 jint (JNICALL *GetVersion) (JNIEnv *env);
223
224 jint (JNICALL *GetOptionalSupport) (JNIEnv *env,
225 jmmOptionalSupport* support_ptr);
226
227 /* This is used by JDK 6 and earlier.
228 * For JDK 7 and after, use GetInputArgumentArray.
229 */
230 jobject (JNICALL *GetInputArguments) (JNIEnv *env);
231
232 jint (JNICALL *GetThreadInfo) (JNIEnv *env,
233 jlongArray ids,
234 jint maxDepth,
235 jobjectArray infoArray);
318 void* reserved6;
319 jobjectArray (JNICALL *DumpThreads) (JNIEnv *env,
320 jlongArray ids,
321 jboolean lockedMonitors,
322 jboolean lockedSynchronizers);
323 void (JNICALL *SetGCNotificationEnabled) (JNIEnv *env,
324 jobject mgr,
325 jboolean enabled);
326 jobjectArray (JNICALL *GetDiagnosticCommands) (JNIEnv *env);
327 void (JNICALL *GetDiagnosticCommandInfo)
328 (JNIEnv *env,
329 jobjectArray cmds,
330 dcmdInfo *infoArray);
331 void (JNICALL *GetDiagnosticCommandArgumentsInfo)
332 (JNIEnv *env,
333 jstring commandName,
334 dcmdArgInfo *infoArray);
335 jstring (JNICALL *ExecuteDiagnosticCommand)
336 (JNIEnv *env,
337 jstring command);
338 void (JNICALL *SetDiagnosticFrameworkNotificationEnabled)
339 (JNIEnv *env,
340 jboolean enabled);
341 } JmmInterface;
342
343 #ifdef __cplusplus
344 } /* extern "C" */
345 #endif /* __cplusplus */
346
347 #endif /* !_JAVA_JMM_H_ */
|