Mercurial > hg > graal-compiler
annotate src/share/vm/prims/jvm.h @ 935:05f89f00a864
6798898: CMS: bugs related to class unloading
Summary: Override should_remember_klasses() and remember_klass() as needed.
Reviewed-by: ysr, jcoomes
author | jmasa |
---|---|
date | Mon, 24 Aug 2009 10:36:31 -0700 |
parents | abe076e3636f |
children | 89e0543e1737 ad6585fd4087 |
rev | line source |
---|---|
0 | 1 /* |
196 | 2 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. |
0 | 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. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 #ifndef _JAVASOFT_JVM_H_ | |
26 #define _JAVASOFT_JVM_H_ | |
27 | |
28 // HotSpot integration note: | |
29 // | |
30 // This file and jvm.h used with the JDK are identical, | |
31 // except for the three includes removed below and the | |
32 // SUPPORT_OLD_REFLECTION sections cut out of the JDK's jvm.h. | |
33 | |
34 // #include <sys/stat.h> | |
35 // #include "jni.h" | |
36 // #include "jvm_md.h" | |
37 | |
38 | |
39 #ifdef __cplusplus | |
40 extern "C" { | |
41 #endif | |
42 | |
43 /* | |
44 * This file contains additional functions exported from the VM. | |
45 * These functions are complementary to the standard JNI support. | |
46 * There are three parts to this file: | |
47 * | |
48 * First, this file contains the VM-related functions needed by native | |
49 * libraries in the standard Java API. For example, the java.lang.Object | |
50 * class needs VM-level functions that wait for and notify monitors. | |
51 * | |
52 * Second, this file contains the functions and constant definitions | |
53 * needed by the byte code verifier and class file format checker. | |
54 * These functions allow the verifier and format checker to be written | |
55 * in a VM-independent way. | |
56 * | |
57 * Third, this file contains various I/O and nerwork operations needed | |
58 * by the standard Java I/O and network APIs. | |
59 */ | |
60 | |
61 /* | |
62 * Bump the version number when either of the following happens: | |
63 * | |
64 * 1. There is a change in JVM_* functions. | |
65 * | |
66 * 2. There is a change in the contract between VM and Java classes. | |
67 * For example, if the VM relies on a new private field in Thread | |
68 * class. | |
69 */ | |
70 | |
71 #define JVM_INTERFACE_VERSION 4 | |
72 | |
73 | |
74 JNIEXPORT jint JNICALL | |
75 JVM_GetInterfaceVersion(void); | |
76 | |
77 /************************************************************************* | |
78 PART 1: Functions for Native Libraries | |
79 ************************************************************************/ | |
80 /* | |
81 * java.lang.Object | |
82 */ | |
83 JNIEXPORT jint JNICALL | |
84 JVM_IHashCode(JNIEnv *env, jobject obj); | |
85 | |
86 JNIEXPORT void JNICALL | |
87 JVM_MonitorWait(JNIEnv *env, jobject obj, jlong ms); | |
88 | |
89 JNIEXPORT void JNICALL | |
90 JVM_MonitorNotify(JNIEnv *env, jobject obj); | |
91 | |
92 JNIEXPORT void JNICALL | |
93 JVM_MonitorNotifyAll(JNIEnv *env, jobject obj); | |
94 | |
95 JNIEXPORT jobject JNICALL | |
96 JVM_Clone(JNIEnv *env, jobject obj); | |
97 | |
98 /* | |
99 * java.lang.String | |
100 */ | |
101 JNIEXPORT jstring JNICALL | |
102 JVM_InternString(JNIEnv *env, jstring str); | |
103 | |
104 /* | |
105 * java.lang.System | |
106 */ | |
107 JNIEXPORT jlong JNICALL | |
108 JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored); | |
109 | |
110 JNIEXPORT jlong JNICALL | |
111 JVM_NanoTime(JNIEnv *env, jclass ignored); | |
112 | |
113 JNIEXPORT void JNICALL | |
114 JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos, | |
115 jobject dst, jint dst_pos, jint length); | |
116 | |
117 JNIEXPORT jobject JNICALL | |
118 JVM_InitProperties(JNIEnv *env, jobject p); | |
119 | |
120 /* | |
121 * java.io.File | |
122 */ | |
123 JNIEXPORT void JNICALL | |
124 JVM_OnExit(void (*func)(void)); | |
125 | |
126 /* | |
127 * java.lang.Runtime | |
128 */ | |
129 JNIEXPORT void JNICALL | |
130 JVM_Exit(jint code); | |
131 | |
132 JNIEXPORT void JNICALL | |
133 JVM_Halt(jint code); | |
134 | |
135 JNIEXPORT void JNICALL | |
136 JVM_GC(void); | |
137 | |
138 /* Returns the number of real-time milliseconds that have elapsed since the | |
139 * least-recently-inspected heap object was last inspected by the garbage | |
140 * collector. | |
141 * | |
142 * For simple stop-the-world collectors this value is just the time | |
143 * since the most recent collection. For generational collectors it is the | |
144 * time since the oldest generation was most recently collected. Other | |
145 * collectors are free to return a pessimistic estimate of the elapsed time, or | |
146 * simply the time since the last full collection was performed. | |
147 * | |
148 * Note that in the presence of reference objects, a given object that is no | |
149 * longer strongly reachable may have to be inspected multiple times before it | |
150 * can be reclaimed. | |
151 */ | |
152 JNIEXPORT jlong JNICALL | |
153 JVM_MaxObjectInspectionAge(void); | |
154 | |
155 JNIEXPORT void JNICALL | |
156 JVM_TraceInstructions(jboolean on); | |
157 | |
158 JNIEXPORT void JNICALL | |
159 JVM_TraceMethodCalls(jboolean on); | |
160 | |
161 JNIEXPORT jlong JNICALL | |
162 JVM_TotalMemory(void); | |
163 | |
164 JNIEXPORT jlong JNICALL | |
165 JVM_FreeMemory(void); | |
166 | |
167 JNIEXPORT jlong JNICALL | |
168 JVM_MaxMemory(void); | |
169 | |
170 JNIEXPORT jint JNICALL | |
171 JVM_ActiveProcessorCount(void); | |
172 | |
173 JNIEXPORT void * JNICALL | |
174 JVM_LoadLibrary(const char *name); | |
175 | |
176 JNIEXPORT void JNICALL | |
177 JVM_UnloadLibrary(void * handle); | |
178 | |
179 JNIEXPORT void * JNICALL | |
180 JVM_FindLibraryEntry(void *handle, const char *name); | |
181 | |
182 JNIEXPORT jboolean JNICALL | |
183 JVM_IsSupportedJNIVersion(jint version); | |
184 | |
185 /* | |
186 * java.lang.Float and java.lang.Double | |
187 */ | |
188 JNIEXPORT jboolean JNICALL | |
189 JVM_IsNaN(jdouble d); | |
190 | |
191 /* | |
192 * java.lang.Throwable | |
193 */ | |
194 JNIEXPORT void JNICALL | |
195 JVM_FillInStackTrace(JNIEnv *env, jobject throwable); | |
196 | |
197 JNIEXPORT void JNICALL | |
198 JVM_PrintStackTrace(JNIEnv *env, jobject throwable, jobject printable); | |
199 | |
200 JNIEXPORT jint JNICALL | |
201 JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable); | |
202 | |
203 JNIEXPORT jobject JNICALL | |
204 JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index); | |
205 | |
206 /* | |
207 * java.lang.Compiler | |
208 */ | |
209 JNIEXPORT void JNICALL | |
210 JVM_InitializeCompiler (JNIEnv *env, jclass compCls); | |
211 | |
212 JNIEXPORT jboolean JNICALL | |
213 JVM_IsSilentCompiler(JNIEnv *env, jclass compCls); | |
214 | |
215 JNIEXPORT jboolean JNICALL | |
216 JVM_CompileClass(JNIEnv *env, jclass compCls, jclass cls); | |
217 | |
218 JNIEXPORT jboolean JNICALL | |
219 JVM_CompileClasses(JNIEnv *env, jclass cls, jstring jname); | |
220 | |
221 JNIEXPORT jobject JNICALL | |
222 JVM_CompilerCommand(JNIEnv *env, jclass compCls, jobject arg); | |
223 | |
224 JNIEXPORT void JNICALL | |
225 JVM_EnableCompiler(JNIEnv *env, jclass compCls); | |
226 | |
227 JNIEXPORT void JNICALL | |
228 JVM_DisableCompiler(JNIEnv *env, jclass compCls); | |
229 | |
230 /* | |
231 * java.lang.Thread | |
232 */ | |
233 JNIEXPORT void JNICALL | |
234 JVM_StartThread(JNIEnv *env, jobject thread); | |
235 | |
236 JNIEXPORT void JNICALL | |
237 JVM_StopThread(JNIEnv *env, jobject thread, jobject exception); | |
238 | |
239 JNIEXPORT jboolean JNICALL | |
240 JVM_IsThreadAlive(JNIEnv *env, jobject thread); | |
241 | |
242 JNIEXPORT void JNICALL | |
243 JVM_SuspendThread(JNIEnv *env, jobject thread); | |
244 | |
245 JNIEXPORT void JNICALL | |
246 JVM_ResumeThread(JNIEnv *env, jobject thread); | |
247 | |
248 JNIEXPORT void JNICALL | |
249 JVM_SetThreadPriority(JNIEnv *env, jobject thread, jint prio); | |
250 | |
251 JNIEXPORT void JNICALL | |
252 JVM_Yield(JNIEnv *env, jclass threadClass); | |
253 | |
254 JNIEXPORT void JNICALL | |
255 JVM_Sleep(JNIEnv *env, jclass threadClass, jlong millis); | |
256 | |
257 JNIEXPORT jobject JNICALL | |
258 JVM_CurrentThread(JNIEnv *env, jclass threadClass); | |
259 | |
260 JNIEXPORT jint JNICALL | |
261 JVM_CountStackFrames(JNIEnv *env, jobject thread); | |
262 | |
263 JNIEXPORT void JNICALL | |
264 JVM_Interrupt(JNIEnv *env, jobject thread); | |
265 | |
266 JNIEXPORT jboolean JNICALL | |
267 JVM_IsInterrupted(JNIEnv *env, jobject thread, jboolean clearInterrupted); | |
268 | |
269 JNIEXPORT jboolean JNICALL | |
270 JVM_HoldsLock(JNIEnv *env, jclass threadClass, jobject obj); | |
271 | |
272 JNIEXPORT void JNICALL | |
273 JVM_DumpAllStacks(JNIEnv *env, jclass unused); | |
274 | |
275 JNIEXPORT jobjectArray JNICALL | |
276 JVM_GetAllThreads(JNIEnv *env, jclass dummy); | |
277 | |
278 /* getStackTrace() and getAllStackTraces() method */ | |
279 JNIEXPORT jobjectArray JNICALL | |
280 JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads); | |
281 | |
282 /* | |
283 * java.lang.SecurityManager | |
284 */ | |
285 JNIEXPORT jclass JNICALL | |
286 JVM_CurrentLoadedClass(JNIEnv *env); | |
287 | |
288 JNIEXPORT jobject JNICALL | |
289 JVM_CurrentClassLoader(JNIEnv *env); | |
290 | |
291 JNIEXPORT jobjectArray JNICALL | |
292 JVM_GetClassContext(JNIEnv *env); | |
293 | |
294 JNIEXPORT jint JNICALL | |
295 JVM_ClassDepth(JNIEnv *env, jstring name); | |
296 | |
297 JNIEXPORT jint JNICALL | |
298 JVM_ClassLoaderDepth(JNIEnv *env); | |
299 | |
300 /* | |
301 * java.lang.Package | |
302 */ | |
303 JNIEXPORT jstring JNICALL | |
304 JVM_GetSystemPackage(JNIEnv *env, jstring name); | |
305 | |
306 JNIEXPORT jobjectArray JNICALL | |
307 JVM_GetSystemPackages(JNIEnv *env); | |
308 | |
309 /* | |
310 * java.io.ObjectInputStream | |
311 */ | |
312 JNIEXPORT jobject JNICALL | |
313 JVM_AllocateNewObject(JNIEnv *env, jobject obj, jclass currClass, | |
314 jclass initClass); | |
315 | |
316 JNIEXPORT jobject JNICALL | |
317 JVM_AllocateNewArray(JNIEnv *env, jobject obj, jclass currClass, | |
318 jint length); | |
319 | |
320 JNIEXPORT jobject JNICALL | |
321 JVM_LatestUserDefinedLoader(JNIEnv *env); | |
322 | |
323 /* | |
324 * This function has been deprecated and should not be considered | |
325 * part of the specified JVM interface. | |
326 */ | |
327 JNIEXPORT jclass JNICALL | |
328 JVM_LoadClass0(JNIEnv *env, jobject obj, jclass currClass, | |
329 jstring currClassName); | |
330 | |
331 /* | |
332 * java.lang.reflect.Array | |
333 */ | |
334 JNIEXPORT jint JNICALL | |
335 JVM_GetArrayLength(JNIEnv *env, jobject arr); | |
336 | |
337 JNIEXPORT jobject JNICALL | |
338 JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index); | |
339 | |
340 JNIEXPORT jvalue JNICALL | |
341 JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode); | |
342 | |
343 JNIEXPORT void JNICALL | |
344 JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val); | |
345 | |
346 JNIEXPORT void JNICALL | |
347 JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v, | |
348 unsigned char vCode); | |
349 | |
350 JNIEXPORT jobject JNICALL | |
351 JVM_NewArray(JNIEnv *env, jclass eltClass, jint length); | |
352 | |
353 JNIEXPORT jobject JNICALL | |
354 JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim); | |
355 | |
356 /* | |
357 * java.lang.Class and java.lang.ClassLoader | |
358 */ | |
359 /* | |
360 * Returns the class in which the code invoking the native method | |
361 * belongs. | |
362 * | |
363 * Note that in JDK 1.1, native methods did not create a frame. | |
364 * In 1.2, they do. Therefore native methods like Class.forName | |
365 * can no longer look at the current frame for the caller class. | |
366 */ | |
367 JNIEXPORT jclass JNICALL | |
368 JVM_GetCallerClass(JNIEnv *env, int n); | |
369 | |
370 /* | |
371 * Find primitive classes | |
372 * utf: class name | |
373 */ | |
374 JNIEXPORT jclass JNICALL | |
375 JVM_FindPrimitiveClass(JNIEnv *env, const char *utf); | |
376 | |
377 /* | |
378 * Link the class | |
379 */ | |
380 JNIEXPORT void JNICALL | |
381 JVM_ResolveClass(JNIEnv *env, jclass cls); | |
382 | |
383 /* | |
384 * Find a class from a given class loader. Throw ClassNotFoundException | |
385 * or NoClassDefFoundError depending on the value of the last | |
386 * argument. | |
387 */ | |
388 JNIEXPORT jclass JNICALL | |
389 JVM_FindClassFromClassLoader(JNIEnv *env, const char *name, jboolean init, | |
390 jobject loader, jboolean throwError); | |
391 | |
392 /* | |
878
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
431
diff
changeset
|
393 * Find a class from a boot class loader. Returns NULL if class not found. |
226
d5ba4f8aa38a
6714758: hotspot: provide an entry point to the BootStrap Class loader[dholmes,acorn]
ksrini
parents:
116
diff
changeset
|
394 */ |
d5ba4f8aa38a
6714758: hotspot: provide an entry point to the BootStrap Class loader[dholmes,acorn]
ksrini
parents:
116
diff
changeset
|
395 JNIEXPORT jclass JNICALL |
878
abe076e3636f
6864003: Modify JVM_FindClassFromBootLoader to return null if class not found
mchung
parents:
431
diff
changeset
|
396 JVM_FindClassFromBootLoader(JNIEnv *env, const char *name); |
226
d5ba4f8aa38a
6714758: hotspot: provide an entry point to the BootStrap Class loader[dholmes,acorn]
ksrini
parents:
116
diff
changeset
|
397 |
d5ba4f8aa38a
6714758: hotspot: provide an entry point to the BootStrap Class loader[dholmes,acorn]
ksrini
parents:
116
diff
changeset
|
398 /* |
0 | 399 * Find a class from a given class. |
400 */ | |
401 JNIEXPORT jclass JNICALL | |
402 JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init, | |
403 jclass from); | |
404 | |
405 /* Find a loaded class cached by the VM */ | |
406 JNIEXPORT jclass JNICALL | |
407 JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name); | |
408 | |
409 /* Define a class */ | |
410 JNIEXPORT jclass JNICALL | |
411 JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, | |
412 jsize len, jobject pd); | |
413 | |
414 /* Define a class with a source (added in JDK1.5) */ | |
415 JNIEXPORT jclass JNICALL | |
416 JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, | |
417 const jbyte *buf, jsize len, jobject pd, | |
418 const char *source); | |
419 | |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
235
diff
changeset
|
420 /* Define a class with a source (MLVM) */ |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
235
diff
changeset
|
421 JNIEXPORT jclass JNICALL |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
235
diff
changeset
|
422 JVM_DefineClassWithCP(JNIEnv *env, const char *name, jobject loader, |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
235
diff
changeset
|
423 const jbyte *buf, jsize len, jobject pd, |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
235
diff
changeset
|
424 const char *source, |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
235
diff
changeset
|
425 // same args as JVM_DefineClassWithSource to this point |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
235
diff
changeset
|
426 jobjectArray constants); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
235
diff
changeset
|
427 |
0 | 428 /* |
429 * Reflection support functions | |
430 */ | |
431 | |
432 JNIEXPORT jstring JNICALL | |
433 JVM_GetClassName(JNIEnv *env, jclass cls); | |
434 | |
435 JNIEXPORT jobjectArray JNICALL | |
436 JVM_GetClassInterfaces(JNIEnv *env, jclass cls); | |
437 | |
438 JNIEXPORT jobject JNICALL | |
439 JVM_GetClassLoader(JNIEnv *env, jclass cls); | |
440 | |
441 JNIEXPORT jboolean JNICALL | |
442 JVM_IsInterface(JNIEnv *env, jclass cls); | |
443 | |
444 JNIEXPORT jobjectArray JNICALL | |
445 JVM_GetClassSigners(JNIEnv *env, jclass cls); | |
446 | |
447 JNIEXPORT void JNICALL | |
448 JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers); | |
449 | |
450 JNIEXPORT jobject JNICALL | |
451 JVM_GetProtectionDomain(JNIEnv *env, jclass cls); | |
452 | |
453 JNIEXPORT void JNICALL | |
454 JVM_SetProtectionDomain(JNIEnv *env, jclass cls, jobject protection_domain); | |
455 | |
456 JNIEXPORT jboolean JNICALL | |
457 JVM_IsArrayClass(JNIEnv *env, jclass cls); | |
458 | |
459 JNIEXPORT jboolean JNICALL | |
460 JVM_IsPrimitiveClass(JNIEnv *env, jclass cls); | |
461 | |
462 JNIEXPORT jclass JNICALL | |
463 JVM_GetComponentType(JNIEnv *env, jclass cls); | |
464 | |
465 JNIEXPORT jint JNICALL | |
466 JVM_GetClassModifiers(JNIEnv *env, jclass cls); | |
467 | |
468 JNIEXPORT jobjectArray JNICALL | |
469 JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass); | |
470 | |
471 JNIEXPORT jclass JNICALL | |
472 JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass); | |
473 | |
474 /* Generics support (JDK 1.5) */ | |
475 JNIEXPORT jstring JNICALL | |
476 JVM_GetClassSignature(JNIEnv *env, jclass cls); | |
477 | |
478 /* Annotations support (JDK 1.5) */ | |
479 JNIEXPORT jbyteArray JNICALL | |
480 JVM_GetClassAnnotations(JNIEnv *env, jclass cls); | |
481 | |
482 /* Annotations support (JDK 1.6) */ | |
483 | |
484 // field is a handle to a java.lang.reflect.Field object | |
485 JNIEXPORT jbyteArray JNICALL | |
486 JVM_GetFieldAnnotations(JNIEnv *env, jobject field); | |
487 | |
488 // method is a handle to a java.lang.reflect.Method object | |
489 JNIEXPORT jbyteArray JNICALL | |
490 JVM_GetMethodAnnotations(JNIEnv *env, jobject method); | |
491 | |
492 // method is a handle to a java.lang.reflect.Method object | |
493 JNIEXPORT jbyteArray JNICALL | |
494 JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method); | |
495 | |
496 // method is a handle to a java.lang.reflect.Method object | |
497 JNIEXPORT jbyteArray JNICALL | |
498 JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method); | |
499 | |
500 | |
501 /* | |
502 * New (JDK 1.4) reflection implementation | |
503 */ | |
504 | |
505 JNIEXPORT jobjectArray JNICALL | |
506 JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly); | |
507 | |
508 JNIEXPORT jobjectArray JNICALL | |
509 JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly); | |
510 | |
511 JNIEXPORT jobjectArray JNICALL | |
512 JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly); | |
513 | |
514 /* Differs from JVM_GetClassModifiers in treatment of inner classes. | |
515 This returns the access flags for the class as specified in the | |
516 class file rather than searching the InnerClasses attribute (if | |
517 present) to find the source-level access flags. Only the values of | |
518 the low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be | |
519 valid. */ | |
520 JNIEXPORT jint JNICALL | |
521 JVM_GetClassAccessFlags(JNIEnv *env, jclass cls); | |
522 | |
523 /* | |
524 * Constant pool access; currently used to implement reflective access to annotations (JDK 1.5) | |
525 */ | |
526 | |
527 JNIEXPORT jobject JNICALL | |
528 JVM_GetClassConstantPool(JNIEnv *env, jclass cls); | |
529 | |
530 JNIEXPORT jint JNICALL JVM_ConstantPoolGetSize | |
531 (JNIEnv *env, jobject unused, jobject jcpool); | |
532 | |
533 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAt | |
534 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
535 | |
536 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAtIfLoaded | |
537 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
538 | |
539 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAt | |
540 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
541 | |
542 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAtIfLoaded | |
543 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
544 | |
545 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAt | |
546 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
547 | |
548 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAtIfLoaded | |
549 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
550 | |
551 JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetMemberRefInfoAt | |
552 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
553 | |
554 JNIEXPORT jint JNICALL JVM_ConstantPoolGetIntAt | |
555 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
556 | |
557 JNIEXPORT jlong JNICALL JVM_ConstantPoolGetLongAt | |
558 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
559 | |
560 JNIEXPORT jfloat JNICALL JVM_ConstantPoolGetFloatAt | |
561 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
562 | |
563 JNIEXPORT jdouble JNICALL JVM_ConstantPoolGetDoubleAt | |
564 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
565 | |
566 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetStringAt | |
567 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
568 | |
569 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetUTF8At | |
570 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
571 | |
572 /* | |
573 * java.security.* | |
574 */ | |
575 | |
576 JNIEXPORT jobject JNICALL | |
577 JVM_DoPrivileged(JNIEnv *env, jclass cls, | |
578 jobject action, jobject context, jboolean wrapException); | |
579 | |
580 JNIEXPORT jobject JNICALL | |
581 JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls); | |
582 | |
583 JNIEXPORT jobject JNICALL | |
584 JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls); | |
585 | |
586 /* | |
587 * Signal support, used to implement the shutdown sequence. Every VM must | |
588 * support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts | |
589 * (^C) and the latter for external termination (kill, system shutdown, etc.). | |
590 * Other platform-dependent signal values may also be supported. | |
591 */ | |
592 | |
593 JNIEXPORT void * JNICALL | |
594 JVM_RegisterSignal(jint sig, void *handler); | |
595 | |
596 JNIEXPORT jboolean JNICALL | |
597 JVM_RaiseSignal(jint sig); | |
598 | |
599 JNIEXPORT jint JNICALL | |
600 JVM_FindSignal(const char *name); | |
601 | |
602 /* | |
603 * Retrieve the assertion directives for the specified class. | |
604 */ | |
605 JNIEXPORT jboolean JNICALL | |
606 JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls); | |
607 | |
608 /* | |
609 * Retrieve the assertion directives from the VM. | |
610 */ | |
611 JNIEXPORT jobject JNICALL | |
612 JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused); | |
613 | |
614 /* | |
615 * sun.misc.AtomicLong | |
616 */ | |
617 JNIEXPORT jboolean JNICALL | |
618 JVM_SupportsCX8(void); | |
619 | |
620 JNIEXPORT jboolean JNICALL | |
621 JVM_CX8Field(JNIEnv *env, jobject obj, jfieldID fldID, jlong oldVal, jlong newVal); | |
622 | |
116
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
623 /* |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
624 * com.sun.dtrace.jsdt support |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
625 */ |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
626 |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
627 #define JVM_TRACING_DTRACE_VERSION 1 |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
628 |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
629 /* |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
630 * Structure to pass one probe description to JVM. |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
631 * |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
632 * The VM will overwrite the definition of the referenced method with |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
633 * code that will fire the probe. |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
634 */ |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
635 typedef struct { |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
636 jmethodID method; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
637 jstring function; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
638 jstring name; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
639 void* reserved[4]; // for future use |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
640 } JVM_DTraceProbe; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
641 |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
642 /** |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
643 * Encapsulates the stability ratings for a DTrace provider field |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
644 */ |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
645 typedef struct { |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
646 jint nameStability; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
647 jint dataStability; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
648 jint dependencyClass; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
649 } JVM_DTraceInterfaceAttributes; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
650 |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
651 /* |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
652 * Structure to pass one provider description to JVM |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
653 */ |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
654 typedef struct { |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
655 jstring name; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
656 JVM_DTraceProbe* probes; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
657 jint probe_count; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
658 JVM_DTraceInterfaceAttributes providerAttributes; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
659 JVM_DTraceInterfaceAttributes moduleAttributes; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
660 JVM_DTraceInterfaceAttributes functionAttributes; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
661 JVM_DTraceInterfaceAttributes nameAttributes; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
662 JVM_DTraceInterfaceAttributes argsAttributes; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
663 void* reserved[4]; // for future use |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
664 } JVM_DTraceProvider; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
665 |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
666 /* |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
667 * Get the version number the JVM was built with |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
668 */ |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
669 JNIEXPORT jint JNICALL |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
670 JVM_DTraceGetVersion(JNIEnv* env); |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
671 |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
672 /* |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
673 * Register new probe with given signature, return global handle |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
674 * |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
675 * The version passed in is the version that the library code was |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
676 * built with. |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
677 */ |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
678 JNIEXPORT jlong JNICALL |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
679 JVM_DTraceActivate(JNIEnv* env, jint version, jstring module_name, |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
680 jint providers_count, JVM_DTraceProvider* providers); |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
681 |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
682 /* |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
683 * Check JSDT probe |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
684 */ |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
685 JNIEXPORT jboolean JNICALL |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
686 JVM_DTraceIsProbeEnabled(JNIEnv* env, jmethodID method); |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
687 |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
688 /* |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
689 * Destroy custom DOF |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
690 */ |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
691 JNIEXPORT void JNICALL |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
692 JVM_DTraceDispose(JNIEnv* env, jlong handle); |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
693 |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
694 /* |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
695 * Check to see if DTrace is supported by OS |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
696 */ |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
697 JNIEXPORT jboolean JNICALL |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
698 JVM_DTraceIsSupported(JNIEnv* env); |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
699 |
0 | 700 /************************************************************************* |
701 PART 2: Support for the Verifier and Class File Format Checker | |
702 ************************************************************************/ | |
703 /* | |
704 * Return the class name in UTF format. The result is valid | |
705 * until JVM_ReleaseUTf is called. | |
706 * | |
707 * The caller must treat the string as a constant and not modify it | |
708 * in any way. | |
709 */ | |
710 JNIEXPORT const char * JNICALL | |
711 JVM_GetClassNameUTF(JNIEnv *env, jclass cb); | |
712 | |
713 /* | |
714 * Returns the constant pool types in the buffer provided by "types." | |
715 */ | |
716 JNIEXPORT void JNICALL | |
717 JVM_GetClassCPTypes(JNIEnv *env, jclass cb, unsigned char *types); | |
718 | |
719 /* | |
720 * Returns the number of Constant Pool entries. | |
721 */ | |
722 JNIEXPORT jint JNICALL | |
723 JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cb); | |
724 | |
725 /* | |
726 * Returns the number of *declared* fields or methods. | |
727 */ | |
728 JNIEXPORT jint JNICALL | |
729 JVM_GetClassFieldsCount(JNIEnv *env, jclass cb); | |
730 | |
731 JNIEXPORT jint JNICALL | |
732 JVM_GetClassMethodsCount(JNIEnv *env, jclass cb); | |
733 | |
734 /* | |
735 * Returns the CP indexes of exceptions raised by a given method. | |
736 * Places the result in the given buffer. | |
737 * | |
738 * The method is identified by method_index. | |
739 */ | |
740 JNIEXPORT void JNICALL | |
741 JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cb, jint method_index, | |
742 unsigned short *exceptions); | |
743 /* | |
744 * Returns the number of exceptions raised by a given method. | |
745 * The method is identified by method_index. | |
746 */ | |
747 JNIEXPORT jint JNICALL | |
748 JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cb, jint method_index); | |
749 | |
750 /* | |
751 * Returns the byte code sequence of a given method. | |
752 * Places the result in the given buffer. | |
753 * | |
754 * The method is identified by method_index. | |
755 */ | |
756 JNIEXPORT void JNICALL | |
757 JVM_GetMethodIxByteCode(JNIEnv *env, jclass cb, jint method_index, | |
758 unsigned char *code); | |
759 | |
760 /* | |
761 * Returns the length of the byte code sequence of a given method. | |
762 * The method is identified by method_index. | |
763 */ | |
764 JNIEXPORT jint JNICALL | |
765 JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cb, jint method_index); | |
766 | |
767 /* | |
768 * A structure used to a capture exception table entry in a Java method. | |
769 */ | |
770 typedef struct { | |
771 jint start_pc; | |
772 jint end_pc; | |
773 jint handler_pc; | |
774 jint catchType; | |
775 } JVM_ExceptionTableEntryType; | |
776 | |
777 /* | |
778 * Returns the exception table entry at entry_index of a given method. | |
779 * Places the result in the given buffer. | |
780 * | |
781 * The method is identified by method_index. | |
782 */ | |
783 JNIEXPORT void JNICALL | |
784 JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cb, jint method_index, | |
785 jint entry_index, | |
786 JVM_ExceptionTableEntryType *entry); | |
787 | |
788 /* | |
789 * Returns the length of the exception table of a given method. | |
790 * The method is identified by method_index. | |
791 */ | |
792 JNIEXPORT jint JNICALL | |
793 JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cb, int index); | |
794 | |
795 /* | |
796 * Returns the modifiers of a given field. | |
797 * The field is identified by field_index. | |
798 */ | |
799 JNIEXPORT jint JNICALL | |
800 JVM_GetFieldIxModifiers(JNIEnv *env, jclass cb, int index); | |
801 | |
802 /* | |
803 * Returns the modifiers of a given method. | |
804 * The method is identified by method_index. | |
805 */ | |
806 JNIEXPORT jint JNICALL | |
807 JVM_GetMethodIxModifiers(JNIEnv *env, jclass cb, int index); | |
808 | |
809 /* | |
810 * Returns the number of local variables of a given method. | |
811 * The method is identified by method_index. | |
812 */ | |
813 JNIEXPORT jint JNICALL | |
814 JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cb, int index); | |
815 | |
816 /* | |
817 * Returns the number of arguments (including this pointer) of a given method. | |
818 * The method is identified by method_index. | |
819 */ | |
820 JNIEXPORT jint JNICALL | |
821 JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cb, int index); | |
822 | |
823 /* | |
824 * Returns the maximum amount of stack (in words) used by a given method. | |
825 * The method is identified by method_index. | |
826 */ | |
827 JNIEXPORT jint JNICALL | |
828 JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cb, int index); | |
829 | |
830 /* | |
831 * Is a given method a constructor. | |
832 * The method is identified by method_index. | |
833 */ | |
834 JNIEXPORT jboolean JNICALL | |
835 JVM_IsConstructorIx(JNIEnv *env, jclass cb, int index); | |
836 | |
837 /* | |
838 * Returns the name of a given method in UTF format. | |
839 * The result remains valid until JVM_ReleaseUTF is called. | |
840 * | |
841 * The caller must treat the string as a constant and not modify it | |
842 * in any way. | |
843 */ | |
844 JNIEXPORT const char * JNICALL | |
845 JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cb, jint index); | |
846 | |
847 /* | |
848 * Returns the signature of a given method in UTF format. | |
849 * The result remains valid until JVM_ReleaseUTF is called. | |
850 * | |
851 * The caller must treat the string as a constant and not modify it | |
852 * in any way. | |
853 */ | |
854 JNIEXPORT const char * JNICALL | |
855 JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cb, jint index); | |
856 | |
857 /* | |
858 * Returns the name of the field refered to at a given constant pool | |
859 * index. | |
860 * | |
861 * The result is in UTF format and remains valid until JVM_ReleaseUTF | |
862 * is called. | |
863 * | |
864 * The caller must treat the string as a constant and not modify it | |
865 * in any way. | |
866 */ | |
867 JNIEXPORT const char * JNICALL | |
868 JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cb, jint index); | |
869 | |
870 /* | |
871 * Returns the name of the method refered to at a given constant pool | |
872 * index. | |
873 * | |
874 * The result is in UTF format and remains valid until JVM_ReleaseUTF | |
875 * is called. | |
876 * | |
877 * The caller must treat the string as a constant and not modify it | |
878 * in any way. | |
879 */ | |
880 JNIEXPORT const char * JNICALL | |
881 JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cb, jint index); | |
882 | |
883 /* | |
884 * Returns the signature of the method refered to at a given constant pool | |
885 * index. | |
886 * | |
887 * The result is in UTF format and remains valid until JVM_ReleaseUTF | |
888 * is called. | |
889 * | |
890 * The caller must treat the string as a constant and not modify it | |
891 * in any way. | |
892 */ | |
893 JNIEXPORT const char * JNICALL | |
894 JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cb, jint index); | |
895 | |
896 /* | |
897 * Returns the signature of the field refered to at a given constant pool | |
898 * index. | |
899 * | |
900 * The result is in UTF format and remains valid until JVM_ReleaseUTF | |
901 * is called. | |
902 * | |
903 * The caller must treat the string as a constant and not modify it | |
904 * in any way. | |
905 */ | |
906 JNIEXPORT const char * JNICALL | |
907 JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cb, jint index); | |
908 | |
909 /* | |
910 * Returns the class name refered to at a given constant pool index. | |
911 * | |
912 * The result is in UTF format and remains valid until JVM_ReleaseUTF | |
913 * is called. | |
914 * | |
915 * The caller must treat the string as a constant and not modify it | |
916 * in any way. | |
917 */ | |
918 JNIEXPORT const char * JNICALL | |
919 JVM_GetCPClassNameUTF(JNIEnv *env, jclass cb, jint index); | |
920 | |
921 /* | |
922 * Returns the class name refered to at a given constant pool index. | |
923 * | |
924 * The constant pool entry must refer to a CONSTANT_Fieldref. | |
925 * | |
926 * The result is in UTF format and remains valid until JVM_ReleaseUTF | |
927 * is called. | |
928 * | |
929 * The caller must treat the string as a constant and not modify it | |
930 * in any way. | |
931 */ | |
932 JNIEXPORT const char * JNICALL | |
933 JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cb, jint index); | |
934 | |
935 /* | |
936 * Returns the class name refered to at a given constant pool index. | |
937 * | |
938 * The constant pool entry must refer to CONSTANT_Methodref or | |
939 * CONSTANT_InterfaceMethodref. | |
940 * | |
941 * The result is in UTF format and remains valid until JVM_ReleaseUTF | |
942 * is called. | |
943 * | |
944 * The caller must treat the string as a constant and not modify it | |
945 * in any way. | |
946 */ | |
947 JNIEXPORT const char * JNICALL | |
948 JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cb, jint index); | |
949 | |
950 /* | |
951 * Returns the modifiers of a field in calledClass. The field is | |
952 * referred to in class cb at constant pool entry index. | |
953 * | |
954 * The caller must treat the string as a constant and not modify it | |
955 * in any way. | |
956 * | |
957 * Returns -1 if the field does not exist in calledClass. | |
958 */ | |
959 JNIEXPORT jint JNICALL | |
960 JVM_GetCPFieldModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass); | |
961 | |
962 /* | |
963 * Returns the modifiers of a method in calledClass. The method is | |
964 * referred to in class cb at constant pool entry index. | |
965 * | |
966 * Returns -1 if the method does not exist in calledClass. | |
967 */ | |
968 JNIEXPORT jint JNICALL | |
969 JVM_GetCPMethodModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass); | |
970 | |
971 /* | |
972 * Releases the UTF string obtained from the VM. | |
973 */ | |
974 JNIEXPORT void JNICALL | |
975 JVM_ReleaseUTF(const char *utf); | |
976 | |
977 /* | |
978 * Compare if two classes are in the same package. | |
979 */ | |
980 JNIEXPORT jboolean JNICALL | |
981 JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2); | |
982 | |
983 /* Constants in class files */ | |
984 | |
985 #define JVM_ACC_PUBLIC 0x0001 /* visible to everyone */ | |
986 #define JVM_ACC_PRIVATE 0x0002 /* visible only to the defining class */ | |
987 #define JVM_ACC_PROTECTED 0x0004 /* visible to subclasses */ | |
988 #define JVM_ACC_STATIC 0x0008 /* instance variable is static */ | |
989 #define JVM_ACC_FINAL 0x0010 /* no further subclassing, overriding */ | |
990 #define JVM_ACC_SYNCHRONIZED 0x0020 /* wrap method call in monitor lock */ | |
991 #define JVM_ACC_SUPER 0x0020 /* funky handling of invokespecial */ | |
992 #define JVM_ACC_VOLATILE 0x0040 /* can not cache in registers */ | |
993 #define JVM_ACC_BRIDGE 0x0040 /* bridge method generated by compiler */ | |
994 #define JVM_ACC_TRANSIENT 0x0080 /* not persistent */ | |
995 #define JVM_ACC_VARARGS 0x0080 /* method declared with variable number of args */ | |
996 #define JVM_ACC_NATIVE 0x0100 /* implemented in C */ | |
997 #define JVM_ACC_INTERFACE 0x0200 /* class is an interface */ | |
998 #define JVM_ACC_ABSTRACT 0x0400 /* no definition provided */ | |
999 #define JVM_ACC_STRICT 0x0800 /* strict floating point */ | |
1000 #define JVM_ACC_SYNTHETIC 0x1000 /* compiler-generated class, method or field */ | |
1001 #define JVM_ACC_ANNOTATION 0x2000 /* annotation type */ | |
1002 #define JVM_ACC_ENUM 0x4000 /* field is declared as element of enum */ | |
1003 | |
1004 #define JVM_ACC_PUBLIC_BIT 0 | |
1005 #define JVM_ACC_PRIVATE_BIT 1 | |
1006 #define JVM_ACC_PROTECTED_BIT 2 | |
1007 #define JVM_ACC_STATIC_BIT 3 | |
1008 #define JVM_ACC_FINAL_BIT 4 | |
1009 #define JVM_ACC_SYNCHRONIZED_BIT 5 | |
1010 #define JVM_ACC_SUPER_BIT 5 | |
1011 #define JVM_ACC_VOLATILE_BIT 6 | |
1012 #define JVM_ACC_BRIDGE_BIT 6 | |
1013 #define JVM_ACC_TRANSIENT_BIT 7 | |
1014 #define JVM_ACC_VARARGS_BIT 7 | |
1015 #define JVM_ACC_NATIVE_BIT 8 | |
1016 #define JVM_ACC_INTERFACE_BIT 9 | |
1017 #define JVM_ACC_ABSTRACT_BIT 10 | |
1018 #define JVM_ACC_STRICT_BIT 11 | |
1019 #define JVM_ACC_SYNTHETIC_BIT 12 | |
1020 #define JVM_ACC_ANNOTATION_BIT 13 | |
1021 #define JVM_ACC_ENUM_BIT 14 | |
1022 | |
1023 // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/utilities/ConstantTag.java | |
1024 enum { | |
1025 JVM_CONSTANT_Utf8 = 1, | |
1026 JVM_CONSTANT_Unicode, /* unused */ | |
1027 JVM_CONSTANT_Integer, | |
1028 JVM_CONSTANT_Float, | |
1029 JVM_CONSTANT_Long, | |
1030 JVM_CONSTANT_Double, | |
1031 JVM_CONSTANT_Class, | |
1032 JVM_CONSTANT_String, | |
1033 JVM_CONSTANT_Fieldref, | |
1034 JVM_CONSTANT_Methodref, | |
1035 JVM_CONSTANT_InterfaceMethodref, | |
1036 JVM_CONSTANT_NameAndType | |
1037 }; | |
1038 | |
1039 /* Used in the newarray instruction. */ | |
1040 | |
1041 #define JVM_T_BOOLEAN 4 | |
1042 #define JVM_T_CHAR 5 | |
1043 #define JVM_T_FLOAT 6 | |
1044 #define JVM_T_DOUBLE 7 | |
1045 #define JVM_T_BYTE 8 | |
1046 #define JVM_T_SHORT 9 | |
1047 #define JVM_T_INT 10 | |
1048 #define JVM_T_LONG 11 | |
1049 | |
1050 /* JVM method signatures */ | |
1051 | |
1052 #define JVM_SIGNATURE_ARRAY '[' | |
1053 #define JVM_SIGNATURE_BYTE 'B' | |
1054 #define JVM_SIGNATURE_CHAR 'C' | |
1055 #define JVM_SIGNATURE_CLASS 'L' | |
1056 #define JVM_SIGNATURE_ENDCLASS ';' | |
1057 #define JVM_SIGNATURE_ENUM 'E' | |
1058 #define JVM_SIGNATURE_FLOAT 'F' | |
1059 #define JVM_SIGNATURE_DOUBLE 'D' | |
1060 #define JVM_SIGNATURE_FUNC '(' | |
1061 #define JVM_SIGNATURE_ENDFUNC ')' | |
1062 #define JVM_SIGNATURE_INT 'I' | |
1063 #define JVM_SIGNATURE_LONG 'J' | |
1064 #define JVM_SIGNATURE_SHORT 'S' | |
1065 #define JVM_SIGNATURE_VOID 'V' | |
1066 #define JVM_SIGNATURE_BOOLEAN 'Z' | |
1067 | |
1068 /* | |
1069 * A function defined by the byte-code verifier and called by the VM. | |
1070 * This is not a function implemented in the VM. | |
1071 * | |
1072 * Returns JNI_FALSE if verification fails. A detailed error message | |
1073 * will be places in msg_buf, whose length is specified by buf_len. | |
1074 */ | |
1075 typedef jboolean (*verifier_fn_t)(JNIEnv *env, | |
1076 jclass cb, | |
1077 char * msg_buf, | |
1078 jint buf_len); | |
1079 | |
1080 | |
1081 /* | |
1082 * Support for a VM-independent class format checker. | |
1083 */ | |
1084 typedef struct { | |
1085 unsigned long code; /* byte code */ | |
1086 unsigned long excs; /* exceptions */ | |
1087 unsigned long etab; /* catch table */ | |
1088 unsigned long lnum; /* line number */ | |
1089 unsigned long lvar; /* local vars */ | |
1090 } method_size_info; | |
1091 | |
1092 typedef struct { | |
1093 unsigned int constants; /* constant pool */ | |
1094 unsigned int fields; | |
1095 unsigned int methods; | |
1096 unsigned int interfaces; | |
1097 unsigned int fields2; /* number of static 2-word fields */ | |
1098 unsigned int innerclasses; /* # of records in InnerClasses attr */ | |
1099 | |
1100 method_size_info clinit; /* memory used in clinit */ | |
1101 method_size_info main; /* used everywhere else */ | |
1102 } class_size_info; | |
1103 | |
1104 /* | |
1105 * Functions defined in libjava.so to perform string conversions. | |
1106 * | |
1107 */ | |
1108 | |
1109 typedef jstring (*to_java_string_fn_t)(JNIEnv *env, char *str); | |
1110 | |
1111 typedef char *(*to_c_string_fn_t)(JNIEnv *env, jstring s, jboolean *b); | |
1112 | |
1113 /* This is the function defined in libjava.so that performs class | |
1114 * format checks. This functions fills in size information about | |
1115 * the class file and returns: | |
1116 * | |
1117 * 0: good | |
1118 * -1: out of memory | |
1119 * -2: bad format | |
1120 * -3: unsupported version | |
1121 * -4: bad class name | |
1122 */ | |
1123 | |
1124 typedef jint (*check_format_fn_t)(char *class_name, | |
1125 unsigned char *data, | |
1126 unsigned int data_size, | |
1127 class_size_info *class_size, | |
1128 char *message_buffer, | |
1129 jint buffer_length, | |
1130 jboolean measure_only, | |
1131 jboolean check_relaxed); | |
1132 | |
1133 #define JVM_RECOGNIZED_CLASS_MODIFIERS (JVM_ACC_PUBLIC | \ | |
1134 JVM_ACC_FINAL | \ | |
1135 JVM_ACC_SUPER | \ | |
1136 JVM_ACC_INTERFACE | \ | |
1137 JVM_ACC_ABSTRACT | \ | |
1138 JVM_ACC_ANNOTATION | \ | |
1139 JVM_ACC_ENUM | \ | |
1140 JVM_ACC_SYNTHETIC) | |
1141 | |
1142 #define JVM_RECOGNIZED_FIELD_MODIFIERS (JVM_ACC_PUBLIC | \ | |
1143 JVM_ACC_PRIVATE | \ | |
1144 JVM_ACC_PROTECTED | \ | |
1145 JVM_ACC_STATIC | \ | |
1146 JVM_ACC_FINAL | \ | |
1147 JVM_ACC_VOLATILE | \ | |
1148 JVM_ACC_TRANSIENT | \ | |
1149 JVM_ACC_ENUM | \ | |
1150 JVM_ACC_SYNTHETIC) | |
1151 | |
1152 #define JVM_RECOGNIZED_METHOD_MODIFIERS (JVM_ACC_PUBLIC | \ | |
1153 JVM_ACC_PRIVATE | \ | |
1154 JVM_ACC_PROTECTED | \ | |
1155 JVM_ACC_STATIC | \ | |
1156 JVM_ACC_FINAL | \ | |
1157 JVM_ACC_SYNCHRONIZED | \ | |
1158 JVM_ACC_BRIDGE | \ | |
1159 JVM_ACC_VARARGS | \ | |
1160 JVM_ACC_NATIVE | \ | |
1161 JVM_ACC_ABSTRACT | \ | |
1162 JVM_ACC_STRICT | \ | |
1163 JVM_ACC_SYNTHETIC) | |
1164 | |
1165 /* | |
1166 * This is the function defined in libjava.so to perform path | |
1167 * canonicalization. VM call this function before opening jar files | |
1168 * to load system classes. | |
1169 * | |
1170 */ | |
1171 | |
1172 typedef int (*canonicalize_fn_t)(JNIEnv *env, char *orig, char *out, int len); | |
1173 | |
1174 /************************************************************************* | |
1175 PART 3: I/O and Network Support | |
1176 ************************************************************************/ | |
1177 | |
1178 /* Note that the JVM IO functions are expected to return JVM_IO_ERR | |
1179 * when there is any kind of error. The caller can then use the | |
1180 * platform specific support (e.g., errno) to get the detailed | |
1181 * error info. The JVM_GetLastErrorString procedure may also be used | |
1182 * to obtain a descriptive error string. | |
1183 */ | |
1184 #define JVM_IO_ERR (-1) | |
1185 | |
1186 /* For interruptible IO. Returning JVM_IO_INTR indicates that an IO | |
1187 * operation has been disrupted by Thread.interrupt. There are a | |
1188 * number of technical difficulties related to interruptible IO that | |
1189 * need to be solved. For example, most existing programs do not handle | |
1190 * InterruptedIOExceptions specially, they simply treat those as any | |
1191 * IOExceptions, which typically indicate fatal errors. | |
1192 * | |
1193 * There are also two modes of operation for interruptible IO. In the | |
1194 * resumption mode, an interrupted IO operation is guaranteed not to | |
1195 * have any side-effects, and can be restarted. In the termination mode, | |
1196 * an interrupted IO operation corrupts the underlying IO stream, so | |
1197 * that the only reasonable operation on an interrupted stream is to | |
1198 * close that stream. The resumption mode seems to be impossible to | |
1199 * implement on Win32 and Solaris. Implementing the termination mode is | |
1200 * easier, but it's not clear that's the right semantics. | |
1201 * | |
1202 * Interruptible IO is not supported on Win32.It can be enabled/disabled | |
1203 * using a compile-time flag on Solaris. Third-party JVM ports do not | |
1204 * need to implement interruptible IO. | |
1205 */ | |
1206 #define JVM_IO_INTR (-2) | |
1207 | |
1208 /* Write a string into the given buffer, in the platform's local encoding, | |
1209 * that describes the most recent system-level error to occur in this thread. | |
1210 * Return the length of the string or zero if no error occurred. | |
1211 */ | |
1212 JNIEXPORT jint JNICALL | |
1213 JVM_GetLastErrorString(char *buf, int len); | |
1214 | |
1215 /* | |
1216 * Convert a pathname into native format. This function does syntactic | |
1217 * cleanup, such as removing redundant separator characters. It modifies | |
1218 * the given pathname string in place. | |
1219 */ | |
1220 JNIEXPORT char * JNICALL | |
1221 JVM_NativePath(char *); | |
1222 | |
1223 /* | |
1224 * JVM I/O error codes | |
1225 */ | |
1226 #define JVM_EEXIST -100 | |
1227 | |
1228 /* | |
1229 * Open a file descriptor. This function returns a negative error code | |
1230 * on error, and a non-negative integer that is the file descriptor on | |
1231 * success. | |
1232 */ | |
1233 JNIEXPORT jint JNICALL | |
1234 JVM_Open(const char *fname, jint flags, jint mode); | |
1235 | |
1236 /* | |
1237 * Close a file descriptor. This function returns -1 on error, and 0 | |
1238 * on success. | |
1239 * | |
1240 * fd the file descriptor to close. | |
1241 */ | |
1242 JNIEXPORT jint JNICALL | |
1243 JVM_Close(jint fd); | |
1244 | |
1245 /* | |
1246 * Read data from a file decriptor into a char array. | |
1247 * | |
1248 * fd the file descriptor to read from. | |
1249 * buf the buffer where to put the read data. | |
1250 * nbytes the number of bytes to read. | |
1251 * | |
1252 * This function returns -1 on error, and 0 on success. | |
1253 */ | |
1254 JNIEXPORT jint JNICALL | |
1255 JVM_Read(jint fd, char *buf, jint nbytes); | |
1256 | |
1257 /* | |
1258 * Write data from a char array to a file decriptor. | |
1259 * | |
1260 * fd the file descriptor to read from. | |
1261 * buf the buffer from which to fetch the data. | |
1262 * nbytes the number of bytes to write. | |
1263 * | |
1264 * This function returns -1 on error, and 0 on success. | |
1265 */ | |
1266 JNIEXPORT jint JNICALL | |
1267 JVM_Write(jint fd, char *buf, jint nbytes); | |
1268 | |
1269 /* | |
1270 * Returns the number of bytes available for reading from a given file | |
1271 * descriptor | |
1272 */ | |
1273 JNIEXPORT jint JNICALL | |
1274 JVM_Available(jint fd, jlong *pbytes); | |
1275 | |
1276 /* | |
1277 * Move the file descriptor pointer from whence by offset. | |
1278 * | |
1279 * fd the file descriptor to move. | |
1280 * offset the number of bytes to move it by. | |
1281 * whence the start from where to move it. | |
1282 * | |
1283 * This function returns the resulting pointer location. | |
1284 */ | |
1285 JNIEXPORT jlong JNICALL | |
1286 JVM_Lseek(jint fd, jlong offset, jint whence); | |
1287 | |
1288 /* | |
1289 * Set the length of the file associated with the given descriptor to the given | |
1290 * length. If the new length is longer than the current length then the file | |
1291 * is extended; the contents of the extended portion are not defined. The | |
1292 * value of the file pointer is undefined after this procedure returns. | |
1293 */ | |
1294 JNIEXPORT jint JNICALL | |
1295 JVM_SetLength(jint fd, jlong length); | |
1296 | |
1297 /* | |
1298 * Synchronize the file descriptor's in memory state with that of the | |
1299 * physical device. Return of -1 is an error, 0 is OK. | |
1300 */ | |
1301 JNIEXPORT jint JNICALL | |
1302 JVM_Sync(jint fd); | |
1303 | |
1304 /* | |
1305 * Networking library support | |
1306 */ | |
1307 | |
1308 JNIEXPORT jint JNICALL | |
1309 JVM_InitializeSocketLibrary(void); | |
1310 | |
1311 struct sockaddr; | |
1312 | |
1313 JNIEXPORT jint JNICALL | |
1314 JVM_Socket(jint domain, jint type, jint protocol); | |
1315 | |
1316 JNIEXPORT jint JNICALL | |
1317 JVM_SocketClose(jint fd); | |
1318 | |
1319 JNIEXPORT jint JNICALL | |
1320 JVM_SocketShutdown(jint fd, jint howto); | |
1321 | |
1322 JNIEXPORT jint JNICALL | |
1323 JVM_Recv(jint fd, char *buf, jint nBytes, jint flags); | |
1324 | |
1325 JNIEXPORT jint JNICALL | |
1326 JVM_Send(jint fd, char *buf, jint nBytes, jint flags); | |
1327 | |
1328 JNIEXPORT jint JNICALL | |
1329 JVM_Timeout(int fd, long timeout); | |
1330 | |
1331 JNIEXPORT jint JNICALL | |
1332 JVM_Listen(jint fd, jint count); | |
1333 | |
1334 JNIEXPORT jint JNICALL | |
1335 JVM_Connect(jint fd, struct sockaddr *him, jint len); | |
1336 | |
1337 JNIEXPORT jint JNICALL | |
1338 JVM_Bind(jint fd, struct sockaddr *him, jint len); | |
1339 | |
1340 JNIEXPORT jint JNICALL | |
1341 JVM_Accept(jint fd, struct sockaddr *him, jint *len); | |
1342 | |
1343 JNIEXPORT jint JNICALL | |
1344 JVM_RecvFrom(jint fd, char *buf, int nBytes, | |
1345 int flags, struct sockaddr *from, int *fromlen); | |
1346 | |
1347 JNIEXPORT jint JNICALL | |
1348 JVM_SendTo(jint fd, char *buf, int len, | |
1349 int flags, struct sockaddr *to, int tolen); | |
1350 | |
1351 JNIEXPORT jint JNICALL | |
1352 JVM_SocketAvailable(jint fd, jint *result); | |
1353 | |
1354 | |
1355 JNIEXPORT jint JNICALL | |
1356 JVM_GetSockName(jint fd, struct sockaddr *him, int *len); | |
1357 | |
1358 JNIEXPORT jint JNICALL | |
1359 JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen); | |
1360 | |
1361 JNIEXPORT jint JNICALL | |
1362 JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen); | |
1363 | |
1364 /* | |
1365 * These routines are only reentrant on Windows | |
1366 */ | |
1367 | |
1368 #ifdef _WINDOWS | |
1369 | |
1370 JNIEXPORT struct protoent * JNICALL | |
1371 JVM_GetProtoByName(char* name); | |
1372 | |
1373 JNIEXPORT struct hostent* JNICALL | |
1374 JVM_GetHostByAddr(const char* name, int len, int type); | |
1375 | |
1376 JNIEXPORT struct hostent* JNICALL | |
1377 JVM_GetHostByName(char* name); | |
1378 | |
1379 #endif /* _WINDOWS */ | |
1380 | |
1381 JNIEXPORT int JNICALL | |
1382 JVM_GetHostName(char* name, int namelen); | |
1383 | |
1384 /* | |
1385 * The standard printing functions supported by the Java VM. (Should they | |
1386 * be renamed to JVM_* in the future? | |
1387 */ | |
1388 | |
1389 /* | |
1390 * BE CAREFUL! The following functions do not implement the | |
1391 * full feature set of standard C printf formats. | |
1392 */ | |
1393 int | |
1394 jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args); | |
1395 | |
1396 int | |
1397 jio_snprintf(char *str, size_t count, const char *fmt, ...); | |
1398 | |
1399 int | |
1400 jio_fprintf(FILE *, const char *fmt, ...); | |
1401 | |
1402 int | |
1403 jio_vfprintf(FILE *, const char *fmt, va_list args); | |
1404 | |
1405 | |
1406 JNIEXPORT void * JNICALL | |
1407 JVM_RawMonitorCreate(void); | |
1408 | |
1409 JNIEXPORT void JNICALL | |
1410 JVM_RawMonitorDestroy(void *mon); | |
1411 | |
1412 JNIEXPORT jint JNICALL | |
1413 JVM_RawMonitorEnter(void *mon); | |
1414 | |
1415 JNIEXPORT void JNICALL | |
1416 JVM_RawMonitorExit(void *mon); | |
1417 | |
1418 | |
1419 #ifdef SUPPORT_OLD_REFLECTION | |
1420 | |
1421 /* | |
1422 * Support for old native code-based (pre-JDK 1.4) reflection implementation. | |
1423 * Disabled by default in the product build. | |
1424 * | |
1425 * See reflection.hpp for information on SUPPORT_OLD_REFLECTION | |
1426 */ | |
1427 | |
1428 /* | |
1429 * reflecting fields and methods. | |
1430 * which: 0 --- MEMBER_PUBLIC | |
1431 * 1 --- MEMBER_DECLARED | |
1432 * NOTE: absent in product build by default | |
1433 */ | |
1434 | |
1435 JNIEXPORT jobjectArray JNICALL | |
1436 JVM_GetClassFields(JNIEnv *env, jclass cls, jint which); | |
1437 | |
1438 JNIEXPORT jobjectArray JNICALL | |
1439 JVM_GetClassMethods(JNIEnv *env, jclass cls, jint which); | |
1440 | |
1441 JNIEXPORT jobjectArray JNICALL | |
1442 JVM_GetClassConstructors(JNIEnv *env, jclass cls, jint which); | |
1443 | |
1444 JNIEXPORT jobject JNICALL | |
1445 JVM_GetClassField(JNIEnv *env, jclass cls, jstring name, jint which); | |
1446 | |
1447 JNIEXPORT jobject JNICALL | |
1448 JVM_GetClassMethod(JNIEnv *env, jclass cls, jstring name, jobjectArray types, | |
1449 jint which); | |
1450 JNIEXPORT jobject JNICALL | |
1451 JVM_GetClassConstructor(JNIEnv *env, jclass cls, jobjectArray types, | |
1452 jint which); | |
1453 | |
1454 /* | |
1455 * Implements Class.newInstance | |
1456 */ | |
1457 JNIEXPORT jobject JNICALL | |
1458 JVM_NewInstance(JNIEnv *env, jclass cls); | |
1459 | |
1460 /* | |
1461 * java.lang.reflect.Field | |
1462 */ | |
1463 JNIEXPORT jobject JNICALL | |
1464 JVM_GetField(JNIEnv *env, jobject field, jobject obj); | |
1465 | |
1466 JNIEXPORT jvalue JNICALL | |
1467 JVM_GetPrimitiveField(JNIEnv *env, jobject field, jobject obj, | |
1468 unsigned char wCode); | |
1469 | |
1470 JNIEXPORT void JNICALL | |
1471 JVM_SetField(JNIEnv *env, jobject field, jobject obj, jobject val); | |
1472 | |
1473 JNIEXPORT void JNICALL | |
1474 JVM_SetPrimitiveField(JNIEnv *env, jobject field, jobject obj, jvalue v, | |
1475 unsigned char vCode); | |
1476 | |
1477 /* | |
1478 * java.lang.reflect.Method | |
1479 */ | |
1480 JNIEXPORT jobject JNICALL | |
1481 JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0); | |
1482 | |
1483 /* | |
1484 * java.lang.reflect.Constructor | |
1485 */ | |
1486 JNIEXPORT jobject JNICALL | |
1487 JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0); | |
1488 | |
1489 #endif /* SUPPORT_OLD_REFLECTION */ | |
1490 | |
1491 /* | |
1492 * java.lang.management support | |
1493 */ | |
1494 JNIEXPORT void* JNICALL | |
1495 JVM_GetManagement(jint version); | |
1496 | |
1497 /* | |
1498 * com.sun.tools.attach.VirtualMachine support | |
1499 * | |
1500 * Initialize the agent properties with the properties maintained in the VM. | |
1501 */ | |
1502 JNIEXPORT jobject JNICALL | |
1503 JVM_InitAgentProperties(JNIEnv *env, jobject agent_props); | |
1504 | |
1505 /* Generics reflection support. | |
1506 * | |
1507 * Returns information about the given class's EnclosingMethod | |
1508 * attribute, if present, or null if the class had no enclosing | |
1509 * method. | |
1510 * | |
1511 * If non-null, the returned array contains three elements. Element 0 | |
1512 * is the java.lang.Class of which the enclosing method is a member, | |
1513 * and elements 1 and 2 are the java.lang.Strings for the enclosing | |
1514 * method's name and descriptor, respectively. | |
1515 */ | |
1516 JNIEXPORT jobjectArray JNICALL | |
1517 JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass); | |
1518 | |
1519 /* | |
1520 * Java thread state support | |
1521 */ | |
1522 enum { | |
1523 JAVA_THREAD_STATE_NEW = 0, | |
1524 JAVA_THREAD_STATE_RUNNABLE = 1, | |
1525 JAVA_THREAD_STATE_BLOCKED = 2, | |
1526 JAVA_THREAD_STATE_WAITING = 3, | |
1527 JAVA_THREAD_STATE_TIMED_WAITING = 4, | |
1528 JAVA_THREAD_STATE_TERMINATED = 5, | |
1529 JAVA_THREAD_STATE_COUNT = 6 | |
1530 }; | |
1531 | |
1532 /* | |
1533 * Returns an array of the threadStatus values representing the | |
1534 * given Java thread state. Returns NULL if the VM version is | |
1535 * incompatible with the JDK or doesn't support the given | |
1536 * Java thread state. | |
1537 */ | |
1538 JNIEXPORT jintArray JNICALL | |
1539 JVM_GetThreadStateValues(JNIEnv* env, jint javaThreadState); | |
1540 | |
1541 /* | |
1542 * Returns an array of the substate names representing the | |
1543 * given Java thread state. Returns NULL if the VM version is | |
1544 * incompatible with the JDK or the VM doesn't support | |
1545 * the given Java thread state. | |
1546 * values must be the jintArray returned from JVM_GetThreadStateValues | |
1547 * and javaThreadState. | |
1548 */ | |
1549 JNIEXPORT jobjectArray JNICALL | |
1550 JVM_GetThreadStateNames(JNIEnv* env, jint javaThreadState, jintArray values); | |
1551 | |
1552 /* ========================================================================= | |
1553 * The following defines a private JVM interface that the JDK can query | |
1554 * for the JVM version and capabilities. sun.misc.Version defines | |
1555 * the methods for getting the VM version and its capabilities. | |
1556 * | |
1557 * When a new bit is added, the following should be updated to provide | |
1558 * access to the new capability: | |
1559 * HS: JVM_GetVersionInfo and Abstract_VM_Version class | |
1560 * SDK: Version class | |
1561 * | |
1562 * Similary, a private JDK interface JDK_GetVersionInfo0 is defined for | |
1563 * JVM to query for the JDK version and capabilities. | |
1564 * | |
1565 * When a new bit is added, the following should be updated to provide | |
1566 * access to the new capability: | |
1567 * HS: JDK_Version class | |
1568 * SDK: JDK_GetVersionInfo0 | |
1569 * | |
1570 * ========================================================================== | |
1571 */ | |
1572 typedef struct { | |
1573 /* HotSpot Express VM version string: | |
1574 * <major>.<minor>-bxx[-<identifier>][-<debug_flavor>] | |
1575 */ | |
1576 unsigned int jvm_version; /* Consists of major.minor.0.build */ | |
1577 unsigned int update_version : 8; /* 0 in HotSpot Express VM */ | |
1578 unsigned int special_update_version : 8; /* 0 in HotSpot Express VM */ | |
1579 unsigned int reserved1 : 16; | |
1580 unsigned int reserved2; | |
1581 | |
1582 /* The following bits represents JVM supports that JDK has dependency on. | |
1583 * JDK can use these bits to determine which JVM version | |
1584 * and support it has to maintain runtime compatibility. | |
1585 * | |
1586 * When a new bit is added in a minor or update release, make sure | |
1587 * the new bit is also added in the main/baseline. | |
1588 */ | |
1589 unsigned int is_attachable : 1; | |
1590 unsigned int is_kernel_jvm : 1; | |
1591 unsigned int : 30; | |
1592 unsigned int : 32; | |
1593 unsigned int : 32; | |
1594 } jvm_version_info; | |
1595 | |
1596 #define JVM_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24) | |
1597 #define JVM_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16) | |
1598 // Micro version is 0 in HotSpot Express VM (set in jvm.cpp). | |
1599 #define JVM_VERSION_MICRO(version) ((version & 0x0000FF00) >> 8) | |
1600 /* Build number is available in all HotSpot Express VM builds. | |
1601 * It is defined in make/hotspot_version file. | |
1602 */ | |
1603 #define JVM_VERSION_BUILD(version) ((version & 0x000000FF)) | |
1604 | |
1605 JNIEXPORT void JNICALL | |
1606 JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size); | |
1607 | |
1608 typedef struct { | |
1609 // Naming convention of RE build version string: n.n.n[_uu[c]][-<identifier>]-bxx | |
1610 unsigned int jdk_version; /* Consists of major, minor, micro (n.n.n) */ | |
1611 /* and build number (xx) */ | |
1612 unsigned int update_version : 8; /* Update release version (uu) */ | |
1613 unsigned int special_update_version : 8; /* Special update release version (c)*/ | |
1614 unsigned int reserved1 : 16; | |
1615 unsigned int reserved2; | |
1616 | |
1617 /* The following bits represents new JDK supports that VM has dependency on. | |
1618 * VM implementation can use these bits to determine which JDK version | |
1619 * and support it has to maintain runtime compatibility. | |
1620 * | |
1621 * When a new bit is added in a minor or update release, make sure | |
1622 * the new bit is also added in the main/baseline. | |
1623 */ | |
1624 unsigned int thread_park_blocker : 1; | |
1625 unsigned int : 31; | |
1626 unsigned int : 32; | |
1627 unsigned int : 32; | |
1628 } jdk_version_info; | |
1629 | |
1630 #define JDK_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24) | |
1631 #define JDK_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16) | |
1632 #define JDK_VERSION_MICRO(version) ((version & 0x0000FF00) >> 8) | |
1633 | |
1634 /* Build number is available only for RE build (i.e. JDK_BUILD_NUMBER is set to bNN) | |
1635 * It will be zero for internal builds. | |
1636 */ | |
1637 #define JDK_VERSION_BUILD(version) ((version & 0x000000FF)) | |
1638 | |
1639 /* | |
1640 * This is the function JDK_GetVersionInfo0 defined in libjava.so | |
1641 * that is dynamically looked up by JVM. | |
1642 */ | |
1643 typedef void (*jdk_version_info_fn_t)(jdk_version_info* info, size_t info_size); | |
1644 | |
1645 /* | |
1646 * This structure is used by the launcher to get the default thread | |
1647 * stack size from the VM using JNI_GetDefaultJavaVMInitArgs() with a | |
1648 * version of 1.1. As it is not supported otherwise, it has been removed | |
1649 * from jni.h | |
1650 */ | |
1651 typedef struct JDK1_1InitArgs { | |
1652 jint version; | |
1653 | |
1654 char **properties; | |
1655 jint checkSource; | |
1656 jint nativeStackSize; | |
1657 jint javaStackSize; | |
1658 jint minHeapSize; | |
1659 jint maxHeapSize; | |
1660 jint verifyMode; | |
1661 char *classpath; | |
1662 | |
1663 jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args); | |
1664 void (JNICALL *exit)(jint code); | |
1665 void (JNICALL *abort)(void); | |
1666 | |
1667 jint enableClassGC; | |
1668 jint enableVerboseGC; | |
1669 jint disableAsyncGC; | |
1670 jint verbose; | |
1671 jboolean debugging; | |
1672 jint debugPort; | |
1673 } JDK1_1InitArgs; | |
1674 | |
1675 #ifdef __cplusplus | |
1676 } /* extern "C" */ | |
1677 #endif /* __cplusplus */ | |
1678 | |
1679 #endif /* !_JAVASOFT_JVM_H_ */ |