Mercurial > hg > graal-jvmci-8
annotate src/share/vm/prims/jvm.h @ 431:a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
Summary: low-level privileged sun.misc.Unsafe.defineAnonymousClass
Reviewed-by: kvn
author | jrose |
---|---|
date | Wed, 12 Nov 2008 22:33:26 -0800 |
parents | 9c2ecc2ffb12 |
children | abe076e3636f |
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 /* | |
226
d5ba4f8aa38a
6714758: hotspot: provide an entry point to the BootStrap Class loader[dholmes,acorn]
ksrini
parents:
116
diff
changeset
|
393 * Find a class from a boot class loader. Throw ClassNotFoundException |
d5ba4f8aa38a
6714758: hotspot: provide an entry point to the BootStrap Class loader[dholmes,acorn]
ksrini
parents:
116
diff
changeset
|
394 * or NoClassDefFoundError depending on the value of the last |
d5ba4f8aa38a
6714758: hotspot: provide an entry point to the BootStrap Class loader[dholmes,acorn]
ksrini
parents:
116
diff
changeset
|
395 * argument. This is the same as FindClassFromClassLoader but provided |
d5ba4f8aa38a
6714758: hotspot: provide an entry point to the BootStrap Class loader[dholmes,acorn]
ksrini
parents:
116
diff
changeset
|
396 * as a convenience method exported correctly on all platforms for |
d5ba4f8aa38a
6714758: hotspot: provide an entry point to the BootStrap Class loader[dholmes,acorn]
ksrini
parents:
116
diff
changeset
|
397 * JSR 277 launcher class loading. |
d5ba4f8aa38a
6714758: hotspot: provide an entry point to the BootStrap Class loader[dholmes,acorn]
ksrini
parents:
116
diff
changeset
|
398 */ |
d5ba4f8aa38a
6714758: hotspot: provide an entry point to the BootStrap Class loader[dholmes,acorn]
ksrini
parents:
116
diff
changeset
|
399 JNIEXPORT jclass JNICALL |
d5ba4f8aa38a
6714758: hotspot: provide an entry point to the BootStrap Class loader[dholmes,acorn]
ksrini
parents:
116
diff
changeset
|
400 JVM_FindClassFromBootLoader(JNIEnv *env, const char *name, |
d5ba4f8aa38a
6714758: hotspot: provide an entry point to the BootStrap Class loader[dholmes,acorn]
ksrini
parents:
116
diff
changeset
|
401 jboolean throwError); |
d5ba4f8aa38a
6714758: hotspot: provide an entry point to the BootStrap Class loader[dholmes,acorn]
ksrini
parents:
116
diff
changeset
|
402 |
d5ba4f8aa38a
6714758: hotspot: provide an entry point to the BootStrap Class loader[dholmes,acorn]
ksrini
parents:
116
diff
changeset
|
403 /* |
0 | 404 * Find a class from a given class. |
405 */ | |
406 JNIEXPORT jclass JNICALL | |
407 JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init, | |
408 jclass from); | |
409 | |
410 /* Find a loaded class cached by the VM */ | |
411 JNIEXPORT jclass JNICALL | |
412 JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name); | |
413 | |
414 /* Define a class */ | |
415 JNIEXPORT jclass JNICALL | |
416 JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, | |
417 jsize len, jobject pd); | |
418 | |
419 /* Define a class with a source (added in JDK1.5) */ | |
420 JNIEXPORT jclass JNICALL | |
421 JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, | |
422 const jbyte *buf, jsize len, jobject pd, | |
423 const char *source); | |
424 | |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
235
diff
changeset
|
425 /* Define a class with a source (MLVM) */ |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
235
diff
changeset
|
426 JNIEXPORT jclass JNICALL |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
235
diff
changeset
|
427 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
|
428 const jbyte *buf, jsize len, jobject pd, |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
235
diff
changeset
|
429 const char *source, |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
235
diff
changeset
|
430 // 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
|
431 jobjectArray constants); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
235
diff
changeset
|
432 |
0 | 433 /* |
434 * Reflection support functions | |
435 */ | |
436 | |
437 JNIEXPORT jstring JNICALL | |
438 JVM_GetClassName(JNIEnv *env, jclass cls); | |
439 | |
440 JNIEXPORT jobjectArray JNICALL | |
441 JVM_GetClassInterfaces(JNIEnv *env, jclass cls); | |
442 | |
443 JNIEXPORT jobject JNICALL | |
444 JVM_GetClassLoader(JNIEnv *env, jclass cls); | |
445 | |
446 JNIEXPORT jboolean JNICALL | |
447 JVM_IsInterface(JNIEnv *env, jclass cls); | |
448 | |
449 JNIEXPORT jobjectArray JNICALL | |
450 JVM_GetClassSigners(JNIEnv *env, jclass cls); | |
451 | |
452 JNIEXPORT void JNICALL | |
453 JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers); | |
454 | |
455 JNIEXPORT jobject JNICALL | |
456 JVM_GetProtectionDomain(JNIEnv *env, jclass cls); | |
457 | |
458 JNIEXPORT void JNICALL | |
459 JVM_SetProtectionDomain(JNIEnv *env, jclass cls, jobject protection_domain); | |
460 | |
461 JNIEXPORT jboolean JNICALL | |
462 JVM_IsArrayClass(JNIEnv *env, jclass cls); | |
463 | |
464 JNIEXPORT jboolean JNICALL | |
465 JVM_IsPrimitiveClass(JNIEnv *env, jclass cls); | |
466 | |
467 JNIEXPORT jclass JNICALL | |
468 JVM_GetComponentType(JNIEnv *env, jclass cls); | |
469 | |
470 JNIEXPORT jint JNICALL | |
471 JVM_GetClassModifiers(JNIEnv *env, jclass cls); | |
472 | |
473 JNIEXPORT jobjectArray JNICALL | |
474 JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass); | |
475 | |
476 JNIEXPORT jclass JNICALL | |
477 JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass); | |
478 | |
479 /* Generics support (JDK 1.5) */ | |
480 JNIEXPORT jstring JNICALL | |
481 JVM_GetClassSignature(JNIEnv *env, jclass cls); | |
482 | |
483 /* Annotations support (JDK 1.5) */ | |
484 JNIEXPORT jbyteArray JNICALL | |
485 JVM_GetClassAnnotations(JNIEnv *env, jclass cls); | |
486 | |
487 /* Annotations support (JDK 1.6) */ | |
488 | |
489 // field is a handle to a java.lang.reflect.Field object | |
490 JNIEXPORT jbyteArray JNICALL | |
491 JVM_GetFieldAnnotations(JNIEnv *env, jobject field); | |
492 | |
493 // method is a handle to a java.lang.reflect.Method object | |
494 JNIEXPORT jbyteArray JNICALL | |
495 JVM_GetMethodAnnotations(JNIEnv *env, jobject method); | |
496 | |
497 // method is a handle to a java.lang.reflect.Method object | |
498 JNIEXPORT jbyteArray JNICALL | |
499 JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method); | |
500 | |
501 // method is a handle to a java.lang.reflect.Method object | |
502 JNIEXPORT jbyteArray JNICALL | |
503 JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method); | |
504 | |
505 | |
506 /* | |
507 * New (JDK 1.4) reflection implementation | |
508 */ | |
509 | |
510 JNIEXPORT jobjectArray JNICALL | |
511 JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly); | |
512 | |
513 JNIEXPORT jobjectArray JNICALL | |
514 JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly); | |
515 | |
516 JNIEXPORT jobjectArray JNICALL | |
517 JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly); | |
518 | |
519 /* Differs from JVM_GetClassModifiers in treatment of inner classes. | |
520 This returns the access flags for the class as specified in the | |
521 class file rather than searching the InnerClasses attribute (if | |
522 present) to find the source-level access flags. Only the values of | |
523 the low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be | |
524 valid. */ | |
525 JNIEXPORT jint JNICALL | |
526 JVM_GetClassAccessFlags(JNIEnv *env, jclass cls); | |
527 | |
528 /* | |
529 * Constant pool access; currently used to implement reflective access to annotations (JDK 1.5) | |
530 */ | |
531 | |
532 JNIEXPORT jobject JNICALL | |
533 JVM_GetClassConstantPool(JNIEnv *env, jclass cls); | |
534 | |
535 JNIEXPORT jint JNICALL JVM_ConstantPoolGetSize | |
536 (JNIEnv *env, jobject unused, jobject jcpool); | |
537 | |
538 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAt | |
539 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
540 | |
541 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAtIfLoaded | |
542 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
543 | |
544 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAt | |
545 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
546 | |
547 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAtIfLoaded | |
548 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
549 | |
550 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAt | |
551 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
552 | |
553 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAtIfLoaded | |
554 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
555 | |
556 JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetMemberRefInfoAt | |
557 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
558 | |
559 JNIEXPORT jint JNICALL JVM_ConstantPoolGetIntAt | |
560 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
561 | |
562 JNIEXPORT jlong JNICALL JVM_ConstantPoolGetLongAt | |
563 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
564 | |
565 JNIEXPORT jfloat JNICALL JVM_ConstantPoolGetFloatAt | |
566 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
567 | |
568 JNIEXPORT jdouble JNICALL JVM_ConstantPoolGetDoubleAt | |
569 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
570 | |
571 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetStringAt | |
572 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
573 | |
574 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetUTF8At | |
575 (JNIEnv *env, jobject unused, jobject jcpool, jint index); | |
576 | |
577 /* | |
578 * java.security.* | |
579 */ | |
580 | |
581 JNIEXPORT jobject JNICALL | |
582 JVM_DoPrivileged(JNIEnv *env, jclass cls, | |
583 jobject action, jobject context, jboolean wrapException); | |
584 | |
585 JNIEXPORT jobject JNICALL | |
586 JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls); | |
587 | |
588 JNIEXPORT jobject JNICALL | |
589 JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls); | |
590 | |
591 /* | |
592 * Signal support, used to implement the shutdown sequence. Every VM must | |
593 * support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts | |
594 * (^C) and the latter for external termination (kill, system shutdown, etc.). | |
595 * Other platform-dependent signal values may also be supported. | |
596 */ | |
597 | |
598 JNIEXPORT void * JNICALL | |
599 JVM_RegisterSignal(jint sig, void *handler); | |
600 | |
601 JNIEXPORT jboolean JNICALL | |
602 JVM_RaiseSignal(jint sig); | |
603 | |
604 JNIEXPORT jint JNICALL | |
605 JVM_FindSignal(const char *name); | |
606 | |
607 /* | |
608 * Retrieve the assertion directives for the specified class. | |
609 */ | |
610 JNIEXPORT jboolean JNICALL | |
611 JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls); | |
612 | |
613 /* | |
614 * Retrieve the assertion directives from the VM. | |
615 */ | |
616 JNIEXPORT jobject JNICALL | |
617 JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused); | |
618 | |
619 /* | |
620 * sun.misc.AtomicLong | |
621 */ | |
622 JNIEXPORT jboolean JNICALL | |
623 JVM_SupportsCX8(void); | |
624 | |
625 JNIEXPORT jboolean JNICALL | |
626 JVM_CX8Field(JNIEnv *env, jobject obj, jfieldID fldID, jlong oldVal, jlong newVal); | |
627 | |
116
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 * com.sun.dtrace.jsdt support |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
630 */ |
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 #define JVM_TRACING_DTRACE_VERSION 1 |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
633 |
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 * 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
|
636 * |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
637 * 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
|
638 * code that will fire the probe. |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
639 */ |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
640 typedef struct { |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
641 jmethodID method; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
642 jstring function; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
643 jstring name; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
644 void* reserved[4]; // for future use |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
645 } JVM_DTraceProbe; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
646 |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
647 /** |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
648 * 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
|
649 */ |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
650 typedef struct { |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
651 jint nameStability; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
652 jint dataStability; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
653 jint dependencyClass; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
654 } JVM_DTraceInterfaceAttributes; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
655 |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
656 /* |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
657 * 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
|
658 */ |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
659 typedef struct { |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
660 jstring name; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
661 JVM_DTraceProbe* probes; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
662 jint probe_count; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
663 JVM_DTraceInterfaceAttributes providerAttributes; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
664 JVM_DTraceInterfaceAttributes moduleAttributes; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
665 JVM_DTraceInterfaceAttributes functionAttributes; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
666 JVM_DTraceInterfaceAttributes nameAttributes; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
667 JVM_DTraceInterfaceAttributes argsAttributes; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
668 void* reserved[4]; // for future use |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
669 } JVM_DTraceProvider; |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
670 |
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 * 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
|
673 */ |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
674 JNIEXPORT jint JNICALL |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
675 JVM_DTraceGetVersion(JNIEnv* env); |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
676 |
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 * 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
|
679 * |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
680 * 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
|
681 * built with. |
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 JNIEXPORT jlong JNICALL |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
684 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
|
685 jint providers_count, JVM_DTraceProvider* providers); |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
686 |
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 * Check JSDT probe |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
689 */ |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
690 JNIEXPORT jboolean JNICALL |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
691 JVM_DTraceIsProbeEnabled(JNIEnv* env, jmethodID method); |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
692 |
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 * Destroy custom DOF |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
695 */ |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
696 JNIEXPORT void JNICALL |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
697 JVM_DTraceDispose(JNIEnv* env, jlong handle); |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
698 |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
699 /* |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
700 * 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
|
701 */ |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
702 JNIEXPORT jboolean JNICALL |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
703 JVM_DTraceIsSupported(JNIEnv* env); |
018d5b58dd4f
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
0
diff
changeset
|
704 |
0 | 705 /************************************************************************* |
706 PART 2: Support for the Verifier and Class File Format Checker | |
707 ************************************************************************/ | |
708 /* | |
709 * Return the class name in UTF format. The result is valid | |
710 * until JVM_ReleaseUTf is called. | |
711 * | |
712 * The caller must treat the string as a constant and not modify it | |
713 * in any way. | |
714 */ | |
715 JNIEXPORT const char * JNICALL | |
716 JVM_GetClassNameUTF(JNIEnv *env, jclass cb); | |
717 | |
718 /* | |
719 * Returns the constant pool types in the buffer provided by "types." | |
720 */ | |
721 JNIEXPORT void JNICALL | |
722 JVM_GetClassCPTypes(JNIEnv *env, jclass cb, unsigned char *types); | |
723 | |
724 /* | |
725 * Returns the number of Constant Pool entries. | |
726 */ | |
727 JNIEXPORT jint JNICALL | |
728 JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cb); | |
729 | |
730 /* | |
731 * Returns the number of *declared* fields or methods. | |
732 */ | |
733 JNIEXPORT jint JNICALL | |
734 JVM_GetClassFieldsCount(JNIEnv *env, jclass cb); | |
735 | |
736 JNIEXPORT jint JNICALL | |
737 JVM_GetClassMethodsCount(JNIEnv *env, jclass cb); | |
738 | |
739 /* | |
740 * Returns the CP indexes of exceptions raised by a given method. | |
741 * Places the result in the given buffer. | |
742 * | |
743 * The method is identified by method_index. | |
744 */ | |
745 JNIEXPORT void JNICALL | |
746 JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cb, jint method_index, | |
747 unsigned short *exceptions); | |
748 /* | |
749 * Returns the number of exceptions raised by a given method. | |
750 * The method is identified by method_index. | |
751 */ | |
752 JNIEXPORT jint JNICALL | |
753 JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cb, jint method_index); | |
754 | |
755 /* | |
756 * Returns the byte code sequence of a given method. | |
757 * Places the result in the given buffer. | |
758 * | |
759 * The method is identified by method_index. | |
760 */ | |
761 JNIEXPORT void JNICALL | |
762 JVM_GetMethodIxByteCode(JNIEnv *env, jclass cb, jint method_index, | |
763 unsigned char *code); | |
764 | |
765 /* | |
766 * Returns the length of the byte code sequence of a given method. | |
767 * The method is identified by method_index. | |
768 */ | |
769 JNIEXPORT jint JNICALL | |
770 JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cb, jint method_index); | |
771 | |
772 /* | |
773 * A structure used to a capture exception table entry in a Java method. | |
774 */ | |
775 typedef struct { | |
776 jint start_pc; | |
777 jint end_pc; | |
778 jint handler_pc; | |
779 jint catchType; | |
780 } JVM_ExceptionTableEntryType; | |
781 | |
782 /* | |
783 * Returns the exception table entry at entry_index of a given method. | |
784 * Places the result in the given buffer. | |
785 * | |
786 * The method is identified by method_index. | |
787 */ | |
788 JNIEXPORT void JNICALL | |
789 JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cb, jint method_index, | |
790 jint entry_index, | |
791 JVM_ExceptionTableEntryType *entry); | |
792 | |
793 /* | |
794 * Returns the length of the exception table of a given method. | |
795 * The method is identified by method_index. | |
796 */ | |
797 JNIEXPORT jint JNICALL | |
798 JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cb, int index); | |
799 | |
800 /* | |
801 * Returns the modifiers of a given field. | |
802 * The field is identified by field_index. | |
803 */ | |
804 JNIEXPORT jint JNICALL | |
805 JVM_GetFieldIxModifiers(JNIEnv *env, jclass cb, int index); | |
806 | |
807 /* | |
808 * Returns the modifiers of a given method. | |
809 * The method is identified by method_index. | |
810 */ | |
811 JNIEXPORT jint JNICALL | |
812 JVM_GetMethodIxModifiers(JNIEnv *env, jclass cb, int index); | |
813 | |
814 /* | |
815 * Returns the number of local variables of a given method. | |
816 * The method is identified by method_index. | |
817 */ | |
818 JNIEXPORT jint JNICALL | |
819 JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cb, int index); | |
820 | |
821 /* | |
822 * Returns the number of arguments (including this pointer) of a given method. | |
823 * The method is identified by method_index. | |
824 */ | |
825 JNIEXPORT jint JNICALL | |
826 JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cb, int index); | |
827 | |
828 /* | |
829 * Returns the maximum amount of stack (in words) used by a given method. | |
830 * The method is identified by method_index. | |
831 */ | |
832 JNIEXPORT jint JNICALL | |
833 JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cb, int index); | |
834 | |
835 /* | |
836 * Is a given method a constructor. | |
837 * The method is identified by method_index. | |
838 */ | |
839 JNIEXPORT jboolean JNICALL | |
840 JVM_IsConstructorIx(JNIEnv *env, jclass cb, int index); | |
841 | |
842 /* | |
843 * Returns the name of a given method in UTF format. | |
844 * The result remains valid until JVM_ReleaseUTF is called. | |
845 * | |
846 * The caller must treat the string as a constant and not modify it | |
847 * in any way. | |
848 */ | |
849 JNIEXPORT const char * JNICALL | |
850 JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cb, jint index); | |
851 | |
852 /* | |
853 * Returns the signature of a given method in UTF format. | |
854 * The result remains valid until JVM_ReleaseUTF is called. | |
855 * | |
856 * The caller must treat the string as a constant and not modify it | |
857 * in any way. | |
858 */ | |
859 JNIEXPORT const char * JNICALL | |
860 JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cb, jint index); | |
861 | |
862 /* | |
863 * Returns the name of the field refered to at a given constant pool | |
864 * index. | |
865 * | |
866 * The result is in UTF format and remains valid until JVM_ReleaseUTF | |
867 * is called. | |
868 * | |
869 * The caller must treat the string as a constant and not modify it | |
870 * in any way. | |
871 */ | |
872 JNIEXPORT const char * JNICALL | |
873 JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cb, jint index); | |
874 | |
875 /* | |
876 * Returns the name of the method refered to at a given constant pool | |
877 * index. | |
878 * | |
879 * The result is in UTF format and remains valid until JVM_ReleaseUTF | |
880 * is called. | |
881 * | |
882 * The caller must treat the string as a constant and not modify it | |
883 * in any way. | |
884 */ | |
885 JNIEXPORT const char * JNICALL | |
886 JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cb, jint index); | |
887 | |
888 /* | |
889 * Returns the signature of the method refered to at a given constant pool | |
890 * index. | |
891 * | |
892 * The result is in UTF format and remains valid until JVM_ReleaseUTF | |
893 * is called. | |
894 * | |
895 * The caller must treat the string as a constant and not modify it | |
896 * in any way. | |
897 */ | |
898 JNIEXPORT const char * JNICALL | |
899 JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cb, jint index); | |
900 | |
901 /* | |
902 * Returns the signature of the field refered to at a given constant pool | |
903 * index. | |
904 * | |
905 * The result is in UTF format and remains valid until JVM_ReleaseUTF | |
906 * is called. | |
907 * | |
908 * The caller must treat the string as a constant and not modify it | |
909 * in any way. | |
910 */ | |
911 JNIEXPORT const char * JNICALL | |
912 JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cb, jint index); | |
913 | |
914 /* | |
915 * Returns the class name refered to at a given constant pool index. | |
916 * | |
917 * The result is in UTF format and remains valid until JVM_ReleaseUTF | |
918 * is called. | |
919 * | |
920 * The caller must treat the string as a constant and not modify it | |
921 * in any way. | |
922 */ | |
923 JNIEXPORT const char * JNICALL | |
924 JVM_GetCPClassNameUTF(JNIEnv *env, jclass cb, jint index); | |
925 | |
926 /* | |
927 * Returns the class name refered to at a given constant pool index. | |
928 * | |
929 * The constant pool entry must refer to a CONSTANT_Fieldref. | |
930 * | |
931 * The result is in UTF format and remains valid until JVM_ReleaseUTF | |
932 * is called. | |
933 * | |
934 * The caller must treat the string as a constant and not modify it | |
935 * in any way. | |
936 */ | |
937 JNIEXPORT const char * JNICALL | |
938 JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cb, jint index); | |
939 | |
940 /* | |
941 * Returns the class name refered to at a given constant pool index. | |
942 * | |
943 * The constant pool entry must refer to CONSTANT_Methodref or | |
944 * CONSTANT_InterfaceMethodref. | |
945 * | |
946 * The result is in UTF format and remains valid until JVM_ReleaseUTF | |
947 * is called. | |
948 * | |
949 * The caller must treat the string as a constant and not modify it | |
950 * in any way. | |
951 */ | |
952 JNIEXPORT const char * JNICALL | |
953 JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cb, jint index); | |
954 | |
955 /* | |
956 * Returns the modifiers of a field in calledClass. The field is | |
957 * referred to in class cb at constant pool entry index. | |
958 * | |
959 * The caller must treat the string as a constant and not modify it | |
960 * in any way. | |
961 * | |
962 * Returns -1 if the field does not exist in calledClass. | |
963 */ | |
964 JNIEXPORT jint JNICALL | |
965 JVM_GetCPFieldModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass); | |
966 | |
967 /* | |
968 * Returns the modifiers of a method in calledClass. The method is | |
969 * referred to in class cb at constant pool entry index. | |
970 * | |
971 * Returns -1 if the method does not exist in calledClass. | |
972 */ | |
973 JNIEXPORT jint JNICALL | |
974 JVM_GetCPMethodModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass); | |
975 | |
976 /* | |
977 * Releases the UTF string obtained from the VM. | |
978 */ | |
979 JNIEXPORT void JNICALL | |
980 JVM_ReleaseUTF(const char *utf); | |
981 | |
982 /* | |
983 * Compare if two classes are in the same package. | |
984 */ | |
985 JNIEXPORT jboolean JNICALL | |
986 JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2); | |
987 | |
988 /* Constants in class files */ | |
989 | |
990 #define JVM_ACC_PUBLIC 0x0001 /* visible to everyone */ | |
991 #define JVM_ACC_PRIVATE 0x0002 /* visible only to the defining class */ | |
992 #define JVM_ACC_PROTECTED 0x0004 /* visible to subclasses */ | |
993 #define JVM_ACC_STATIC 0x0008 /* instance variable is static */ | |
994 #define JVM_ACC_FINAL 0x0010 /* no further subclassing, overriding */ | |
995 #define JVM_ACC_SYNCHRONIZED 0x0020 /* wrap method call in monitor lock */ | |
996 #define JVM_ACC_SUPER 0x0020 /* funky handling of invokespecial */ | |
997 #define JVM_ACC_VOLATILE 0x0040 /* can not cache in registers */ | |
998 #define JVM_ACC_BRIDGE 0x0040 /* bridge method generated by compiler */ | |
999 #define JVM_ACC_TRANSIENT 0x0080 /* not persistent */ | |
1000 #define JVM_ACC_VARARGS 0x0080 /* method declared with variable number of args */ | |
1001 #define JVM_ACC_NATIVE 0x0100 /* implemented in C */ | |
1002 #define JVM_ACC_INTERFACE 0x0200 /* class is an interface */ | |
1003 #define JVM_ACC_ABSTRACT 0x0400 /* no definition provided */ | |
1004 #define JVM_ACC_STRICT 0x0800 /* strict floating point */ | |
1005 #define JVM_ACC_SYNTHETIC 0x1000 /* compiler-generated class, method or field */ | |
1006 #define JVM_ACC_ANNOTATION 0x2000 /* annotation type */ | |
1007 #define JVM_ACC_ENUM 0x4000 /* field is declared as element of enum */ | |
1008 | |
1009 #define JVM_ACC_PUBLIC_BIT 0 | |
1010 #define JVM_ACC_PRIVATE_BIT 1 | |
1011 #define JVM_ACC_PROTECTED_BIT 2 | |
1012 #define JVM_ACC_STATIC_BIT 3 | |
1013 #define JVM_ACC_FINAL_BIT 4 | |
1014 #define JVM_ACC_SYNCHRONIZED_BIT 5 | |
1015 #define JVM_ACC_SUPER_BIT 5 | |
1016 #define JVM_ACC_VOLATILE_BIT 6 | |
1017 #define JVM_ACC_BRIDGE_BIT 6 | |
1018 #define JVM_ACC_TRANSIENT_BIT 7 | |
1019 #define JVM_ACC_VARARGS_BIT 7 | |
1020 #define JVM_ACC_NATIVE_BIT 8 | |
1021 #define JVM_ACC_INTERFACE_BIT 9 | |
1022 #define JVM_ACC_ABSTRACT_BIT 10 | |
1023 #define JVM_ACC_STRICT_BIT 11 | |
1024 #define JVM_ACC_SYNTHETIC_BIT 12 | |
1025 #define JVM_ACC_ANNOTATION_BIT 13 | |
1026 #define JVM_ACC_ENUM_BIT 14 | |
1027 | |
1028 // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/utilities/ConstantTag.java | |
1029 enum { | |
1030 JVM_CONSTANT_Utf8 = 1, | |
1031 JVM_CONSTANT_Unicode, /* unused */ | |
1032 JVM_CONSTANT_Integer, | |
1033 JVM_CONSTANT_Float, | |
1034 JVM_CONSTANT_Long, | |
1035 JVM_CONSTANT_Double, | |
1036 JVM_CONSTANT_Class, | |
1037 JVM_CONSTANT_String, | |
1038 JVM_CONSTANT_Fieldref, | |
1039 JVM_CONSTANT_Methodref, | |
1040 JVM_CONSTANT_InterfaceMethodref, | |
1041 JVM_CONSTANT_NameAndType | |
1042 }; | |
1043 | |
1044 /* Used in the newarray instruction. */ | |
1045 | |
1046 #define JVM_T_BOOLEAN 4 | |
1047 #define JVM_T_CHAR 5 | |
1048 #define JVM_T_FLOAT 6 | |
1049 #define JVM_T_DOUBLE 7 | |
1050 #define JVM_T_BYTE 8 | |
1051 #define JVM_T_SHORT 9 | |
1052 #define JVM_T_INT 10 | |
1053 #define JVM_T_LONG 11 | |
1054 | |
1055 /* JVM method signatures */ | |
1056 | |
1057 #define JVM_SIGNATURE_ARRAY '[' | |
1058 #define JVM_SIGNATURE_BYTE 'B' | |
1059 #define JVM_SIGNATURE_CHAR 'C' | |
1060 #define JVM_SIGNATURE_CLASS 'L' | |
1061 #define JVM_SIGNATURE_ENDCLASS ';' | |
1062 #define JVM_SIGNATURE_ENUM 'E' | |
1063 #define JVM_SIGNATURE_FLOAT 'F' | |
1064 #define JVM_SIGNATURE_DOUBLE 'D' | |
1065 #define JVM_SIGNATURE_FUNC '(' | |
1066 #define JVM_SIGNATURE_ENDFUNC ')' | |
1067 #define JVM_SIGNATURE_INT 'I' | |
1068 #define JVM_SIGNATURE_LONG 'J' | |
1069 #define JVM_SIGNATURE_SHORT 'S' | |
1070 #define JVM_SIGNATURE_VOID 'V' | |
1071 #define JVM_SIGNATURE_BOOLEAN 'Z' | |
1072 | |
1073 /* | |
1074 * A function defined by the byte-code verifier and called by the VM. | |
1075 * This is not a function implemented in the VM. | |
1076 * | |
1077 * Returns JNI_FALSE if verification fails. A detailed error message | |
1078 * will be places in msg_buf, whose length is specified by buf_len. | |
1079 */ | |
1080 typedef jboolean (*verifier_fn_t)(JNIEnv *env, | |
1081 jclass cb, | |
1082 char * msg_buf, | |
1083 jint buf_len); | |
1084 | |
1085 | |
1086 /* | |
1087 * Support for a VM-independent class format checker. | |
1088 */ | |
1089 typedef struct { | |
1090 unsigned long code; /* byte code */ | |
1091 unsigned long excs; /* exceptions */ | |
1092 unsigned long etab; /* catch table */ | |
1093 unsigned long lnum; /* line number */ | |
1094 unsigned long lvar; /* local vars */ | |
1095 } method_size_info; | |
1096 | |
1097 typedef struct { | |
1098 unsigned int constants; /* constant pool */ | |
1099 unsigned int fields; | |
1100 unsigned int methods; | |
1101 unsigned int interfaces; | |
1102 unsigned int fields2; /* number of static 2-word fields */ | |
1103 unsigned int innerclasses; /* # of records in InnerClasses attr */ | |
1104 | |
1105 method_size_info clinit; /* memory used in clinit */ | |
1106 method_size_info main; /* used everywhere else */ | |
1107 } class_size_info; | |
1108 | |
1109 /* | |
1110 * Functions defined in libjava.so to perform string conversions. | |
1111 * | |
1112 */ | |
1113 | |
1114 typedef jstring (*to_java_string_fn_t)(JNIEnv *env, char *str); | |
1115 | |
1116 typedef char *(*to_c_string_fn_t)(JNIEnv *env, jstring s, jboolean *b); | |
1117 | |
1118 /* This is the function defined in libjava.so that performs class | |
1119 * format checks. This functions fills in size information about | |
1120 * the class file and returns: | |
1121 * | |
1122 * 0: good | |
1123 * -1: out of memory | |
1124 * -2: bad format | |
1125 * -3: unsupported version | |
1126 * -4: bad class name | |
1127 */ | |
1128 | |
1129 typedef jint (*check_format_fn_t)(char *class_name, | |
1130 unsigned char *data, | |
1131 unsigned int data_size, | |
1132 class_size_info *class_size, | |
1133 char *message_buffer, | |
1134 jint buffer_length, | |
1135 jboolean measure_only, | |
1136 jboolean check_relaxed); | |
1137 | |
1138 #define JVM_RECOGNIZED_CLASS_MODIFIERS (JVM_ACC_PUBLIC | \ | |
1139 JVM_ACC_FINAL | \ | |
1140 JVM_ACC_SUPER | \ | |
1141 JVM_ACC_INTERFACE | \ | |
1142 JVM_ACC_ABSTRACT | \ | |
1143 JVM_ACC_ANNOTATION | \ | |
1144 JVM_ACC_ENUM | \ | |
1145 JVM_ACC_SYNTHETIC) | |
1146 | |
1147 #define JVM_RECOGNIZED_FIELD_MODIFIERS (JVM_ACC_PUBLIC | \ | |
1148 JVM_ACC_PRIVATE | \ | |
1149 JVM_ACC_PROTECTED | \ | |
1150 JVM_ACC_STATIC | \ | |
1151 JVM_ACC_FINAL | \ | |
1152 JVM_ACC_VOLATILE | \ | |
1153 JVM_ACC_TRANSIENT | \ | |
1154 JVM_ACC_ENUM | \ | |
1155 JVM_ACC_SYNTHETIC) | |
1156 | |
1157 #define JVM_RECOGNIZED_METHOD_MODIFIERS (JVM_ACC_PUBLIC | \ | |
1158 JVM_ACC_PRIVATE | \ | |
1159 JVM_ACC_PROTECTED | \ | |
1160 JVM_ACC_STATIC | \ | |
1161 JVM_ACC_FINAL | \ | |
1162 JVM_ACC_SYNCHRONIZED | \ | |
1163 JVM_ACC_BRIDGE | \ | |
1164 JVM_ACC_VARARGS | \ | |
1165 JVM_ACC_NATIVE | \ | |
1166 JVM_ACC_ABSTRACT | \ | |
1167 JVM_ACC_STRICT | \ | |
1168 JVM_ACC_SYNTHETIC) | |
1169 | |
1170 /* | |
1171 * This is the function defined in libjava.so to perform path | |
1172 * canonicalization. VM call this function before opening jar files | |
1173 * to load system classes. | |
1174 * | |
1175 */ | |
1176 | |
1177 typedef int (*canonicalize_fn_t)(JNIEnv *env, char *orig, char *out, int len); | |
1178 | |
1179 /************************************************************************* | |
1180 PART 3: I/O and Network Support | |
1181 ************************************************************************/ | |
1182 | |
1183 /* Note that the JVM IO functions are expected to return JVM_IO_ERR | |
1184 * when there is any kind of error. The caller can then use the | |
1185 * platform specific support (e.g., errno) to get the detailed | |
1186 * error info. The JVM_GetLastErrorString procedure may also be used | |
1187 * to obtain a descriptive error string. | |
1188 */ | |
1189 #define JVM_IO_ERR (-1) | |
1190 | |
1191 /* For interruptible IO. Returning JVM_IO_INTR indicates that an IO | |
1192 * operation has been disrupted by Thread.interrupt. There are a | |
1193 * number of technical difficulties related to interruptible IO that | |
1194 * need to be solved. For example, most existing programs do not handle | |
1195 * InterruptedIOExceptions specially, they simply treat those as any | |
1196 * IOExceptions, which typically indicate fatal errors. | |
1197 * | |
1198 * There are also two modes of operation for interruptible IO. In the | |
1199 * resumption mode, an interrupted IO operation is guaranteed not to | |
1200 * have any side-effects, and can be restarted. In the termination mode, | |
1201 * an interrupted IO operation corrupts the underlying IO stream, so | |
1202 * that the only reasonable operation on an interrupted stream is to | |
1203 * close that stream. The resumption mode seems to be impossible to | |
1204 * implement on Win32 and Solaris. Implementing the termination mode is | |
1205 * easier, but it's not clear that's the right semantics. | |
1206 * | |
1207 * Interruptible IO is not supported on Win32.It can be enabled/disabled | |
1208 * using a compile-time flag on Solaris. Third-party JVM ports do not | |
1209 * need to implement interruptible IO. | |
1210 */ | |
1211 #define JVM_IO_INTR (-2) | |
1212 | |
1213 /* Write a string into the given buffer, in the platform's local encoding, | |
1214 * that describes the most recent system-level error to occur in this thread. | |
1215 * Return the length of the string or zero if no error occurred. | |
1216 */ | |
1217 JNIEXPORT jint JNICALL | |
1218 JVM_GetLastErrorString(char *buf, int len); | |
1219 | |
1220 /* | |
1221 * Convert a pathname into native format. This function does syntactic | |
1222 * cleanup, such as removing redundant separator characters. It modifies | |
1223 * the given pathname string in place. | |
1224 */ | |
1225 JNIEXPORT char * JNICALL | |
1226 JVM_NativePath(char *); | |
1227 | |
1228 /* | |
1229 * JVM I/O error codes | |
1230 */ | |
1231 #define JVM_EEXIST -100 | |
1232 | |
1233 /* | |
1234 * Open a file descriptor. This function returns a negative error code | |
1235 * on error, and a non-negative integer that is the file descriptor on | |
1236 * success. | |
1237 */ | |
1238 JNIEXPORT jint JNICALL | |
1239 JVM_Open(const char *fname, jint flags, jint mode); | |
1240 | |
1241 /* | |
1242 * Close a file descriptor. This function returns -1 on error, and 0 | |
1243 * on success. | |
1244 * | |
1245 * fd the file descriptor to close. | |
1246 */ | |
1247 JNIEXPORT jint JNICALL | |
1248 JVM_Close(jint fd); | |
1249 | |
1250 /* | |
1251 * Read data from a file decriptor into a char array. | |
1252 * | |
1253 * fd the file descriptor to read from. | |
1254 * buf the buffer where to put the read data. | |
1255 * nbytes the number of bytes to read. | |
1256 * | |
1257 * This function returns -1 on error, and 0 on success. | |
1258 */ | |
1259 JNIEXPORT jint JNICALL | |
1260 JVM_Read(jint fd, char *buf, jint nbytes); | |
1261 | |
1262 /* | |
1263 * Write data from a char array to a file decriptor. | |
1264 * | |
1265 * fd the file descriptor to read from. | |
1266 * buf the buffer from which to fetch the data. | |
1267 * nbytes the number of bytes to write. | |
1268 * | |
1269 * This function returns -1 on error, and 0 on success. | |
1270 */ | |
1271 JNIEXPORT jint JNICALL | |
1272 JVM_Write(jint fd, char *buf, jint nbytes); | |
1273 | |
1274 /* | |
1275 * Returns the number of bytes available for reading from a given file | |
1276 * descriptor | |
1277 */ | |
1278 JNIEXPORT jint JNICALL | |
1279 JVM_Available(jint fd, jlong *pbytes); | |
1280 | |
1281 /* | |
1282 * Move the file descriptor pointer from whence by offset. | |
1283 * | |
1284 * fd the file descriptor to move. | |
1285 * offset the number of bytes to move it by. | |
1286 * whence the start from where to move it. | |
1287 * | |
1288 * This function returns the resulting pointer location. | |
1289 */ | |
1290 JNIEXPORT jlong JNICALL | |
1291 JVM_Lseek(jint fd, jlong offset, jint whence); | |
1292 | |
1293 /* | |
1294 * Set the length of the file associated with the given descriptor to the given | |
1295 * length. If the new length is longer than the current length then the file | |
1296 * is extended; the contents of the extended portion are not defined. The | |
1297 * value of the file pointer is undefined after this procedure returns. | |
1298 */ | |
1299 JNIEXPORT jint JNICALL | |
1300 JVM_SetLength(jint fd, jlong length); | |
1301 | |
1302 /* | |
1303 * Synchronize the file descriptor's in memory state with that of the | |
1304 * physical device. Return of -1 is an error, 0 is OK. | |
1305 */ | |
1306 JNIEXPORT jint JNICALL | |
1307 JVM_Sync(jint fd); | |
1308 | |
1309 /* | |
1310 * Networking library support | |
1311 */ | |
1312 | |
1313 JNIEXPORT jint JNICALL | |
1314 JVM_InitializeSocketLibrary(void); | |
1315 | |
1316 struct sockaddr; | |
1317 | |
1318 JNIEXPORT jint JNICALL | |
1319 JVM_Socket(jint domain, jint type, jint protocol); | |
1320 | |
1321 JNIEXPORT jint JNICALL | |
1322 JVM_SocketClose(jint fd); | |
1323 | |
1324 JNIEXPORT jint JNICALL | |
1325 JVM_SocketShutdown(jint fd, jint howto); | |
1326 | |
1327 JNIEXPORT jint JNICALL | |
1328 JVM_Recv(jint fd, char *buf, jint nBytes, jint flags); | |
1329 | |
1330 JNIEXPORT jint JNICALL | |
1331 JVM_Send(jint fd, char *buf, jint nBytes, jint flags); | |
1332 | |
1333 JNIEXPORT jint JNICALL | |
1334 JVM_Timeout(int fd, long timeout); | |
1335 | |
1336 JNIEXPORT jint JNICALL | |
1337 JVM_Listen(jint fd, jint count); | |
1338 | |
1339 JNIEXPORT jint JNICALL | |
1340 JVM_Connect(jint fd, struct sockaddr *him, jint len); | |
1341 | |
1342 JNIEXPORT jint JNICALL | |
1343 JVM_Bind(jint fd, struct sockaddr *him, jint len); | |
1344 | |
1345 JNIEXPORT jint JNICALL | |
1346 JVM_Accept(jint fd, struct sockaddr *him, jint *len); | |
1347 | |
1348 JNIEXPORT jint JNICALL | |
1349 JVM_RecvFrom(jint fd, char *buf, int nBytes, | |
1350 int flags, struct sockaddr *from, int *fromlen); | |
1351 | |
1352 JNIEXPORT jint JNICALL | |
1353 JVM_SendTo(jint fd, char *buf, int len, | |
1354 int flags, struct sockaddr *to, int tolen); | |
1355 | |
1356 JNIEXPORT jint JNICALL | |
1357 JVM_SocketAvailable(jint fd, jint *result); | |
1358 | |
1359 | |
1360 JNIEXPORT jint JNICALL | |
1361 JVM_GetSockName(jint fd, struct sockaddr *him, int *len); | |
1362 | |
1363 JNIEXPORT jint JNICALL | |
1364 JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen); | |
1365 | |
1366 JNIEXPORT jint JNICALL | |
1367 JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen); | |
1368 | |
1369 /* | |
1370 * These routines are only reentrant on Windows | |
1371 */ | |
1372 | |
1373 #ifdef _WINDOWS | |
1374 | |
1375 JNIEXPORT struct protoent * JNICALL | |
1376 JVM_GetProtoByName(char* name); | |
1377 | |
1378 JNIEXPORT struct hostent* JNICALL | |
1379 JVM_GetHostByAddr(const char* name, int len, int type); | |
1380 | |
1381 JNIEXPORT struct hostent* JNICALL | |
1382 JVM_GetHostByName(char* name); | |
1383 | |
1384 #endif /* _WINDOWS */ | |
1385 | |
1386 JNIEXPORT int JNICALL | |
1387 JVM_GetHostName(char* name, int namelen); | |
1388 | |
1389 /* | |
1390 * The standard printing functions supported by the Java VM. (Should they | |
1391 * be renamed to JVM_* in the future? | |
1392 */ | |
1393 | |
1394 /* | |
1395 * BE CAREFUL! The following functions do not implement the | |
1396 * full feature set of standard C printf formats. | |
1397 */ | |
1398 int | |
1399 jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args); | |
1400 | |
1401 int | |
1402 jio_snprintf(char *str, size_t count, const char *fmt, ...); | |
1403 | |
1404 int | |
1405 jio_fprintf(FILE *, const char *fmt, ...); | |
1406 | |
1407 int | |
1408 jio_vfprintf(FILE *, const char *fmt, va_list args); | |
1409 | |
1410 | |
1411 JNIEXPORT void * JNICALL | |
1412 JVM_RawMonitorCreate(void); | |
1413 | |
1414 JNIEXPORT void JNICALL | |
1415 JVM_RawMonitorDestroy(void *mon); | |
1416 | |
1417 JNIEXPORT jint JNICALL | |
1418 JVM_RawMonitorEnter(void *mon); | |
1419 | |
1420 JNIEXPORT void JNICALL | |
1421 JVM_RawMonitorExit(void *mon); | |
1422 | |
1423 | |
1424 #ifdef SUPPORT_OLD_REFLECTION | |
1425 | |
1426 /* | |
1427 * Support for old native code-based (pre-JDK 1.4) reflection implementation. | |
1428 * Disabled by default in the product build. | |
1429 * | |
1430 * See reflection.hpp for information on SUPPORT_OLD_REFLECTION | |
1431 */ | |
1432 | |
1433 /* | |
1434 * reflecting fields and methods. | |
1435 * which: 0 --- MEMBER_PUBLIC | |
1436 * 1 --- MEMBER_DECLARED | |
1437 * NOTE: absent in product build by default | |
1438 */ | |
1439 | |
1440 JNIEXPORT jobjectArray JNICALL | |
1441 JVM_GetClassFields(JNIEnv *env, jclass cls, jint which); | |
1442 | |
1443 JNIEXPORT jobjectArray JNICALL | |
1444 JVM_GetClassMethods(JNIEnv *env, jclass cls, jint which); | |
1445 | |
1446 JNIEXPORT jobjectArray JNICALL | |
1447 JVM_GetClassConstructors(JNIEnv *env, jclass cls, jint which); | |
1448 | |
1449 JNIEXPORT jobject JNICALL | |
1450 JVM_GetClassField(JNIEnv *env, jclass cls, jstring name, jint which); | |
1451 | |
1452 JNIEXPORT jobject JNICALL | |
1453 JVM_GetClassMethod(JNIEnv *env, jclass cls, jstring name, jobjectArray types, | |
1454 jint which); | |
1455 JNIEXPORT jobject JNICALL | |
1456 JVM_GetClassConstructor(JNIEnv *env, jclass cls, jobjectArray types, | |
1457 jint which); | |
1458 | |
1459 /* | |
1460 * Implements Class.newInstance | |
1461 */ | |
1462 JNIEXPORT jobject JNICALL | |
1463 JVM_NewInstance(JNIEnv *env, jclass cls); | |
1464 | |
1465 /* | |
1466 * java.lang.reflect.Field | |
1467 */ | |
1468 JNIEXPORT jobject JNICALL | |
1469 JVM_GetField(JNIEnv *env, jobject field, jobject obj); | |
1470 | |
1471 JNIEXPORT jvalue JNICALL | |
1472 JVM_GetPrimitiveField(JNIEnv *env, jobject field, jobject obj, | |
1473 unsigned char wCode); | |
1474 | |
1475 JNIEXPORT void JNICALL | |
1476 JVM_SetField(JNIEnv *env, jobject field, jobject obj, jobject val); | |
1477 | |
1478 JNIEXPORT void JNICALL | |
1479 JVM_SetPrimitiveField(JNIEnv *env, jobject field, jobject obj, jvalue v, | |
1480 unsigned char vCode); | |
1481 | |
1482 /* | |
1483 * java.lang.reflect.Method | |
1484 */ | |
1485 JNIEXPORT jobject JNICALL | |
1486 JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0); | |
1487 | |
1488 /* | |
1489 * java.lang.reflect.Constructor | |
1490 */ | |
1491 JNIEXPORT jobject JNICALL | |
1492 JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0); | |
1493 | |
1494 #endif /* SUPPORT_OLD_REFLECTION */ | |
1495 | |
1496 /* | |
1497 * java.lang.management support | |
1498 */ | |
1499 JNIEXPORT void* JNICALL | |
1500 JVM_GetManagement(jint version); | |
1501 | |
1502 /* | |
1503 * com.sun.tools.attach.VirtualMachine support | |
1504 * | |
1505 * Initialize the agent properties with the properties maintained in the VM. | |
1506 */ | |
1507 JNIEXPORT jobject JNICALL | |
1508 JVM_InitAgentProperties(JNIEnv *env, jobject agent_props); | |
1509 | |
1510 /* Generics reflection support. | |
1511 * | |
1512 * Returns information about the given class's EnclosingMethod | |
1513 * attribute, if present, or null if the class had no enclosing | |
1514 * method. | |
1515 * | |
1516 * If non-null, the returned array contains three elements. Element 0 | |
1517 * is the java.lang.Class of which the enclosing method is a member, | |
1518 * and elements 1 and 2 are the java.lang.Strings for the enclosing | |
1519 * method's name and descriptor, respectively. | |
1520 */ | |
1521 JNIEXPORT jobjectArray JNICALL | |
1522 JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass); | |
1523 | |
1524 /* | |
1525 * Java thread state support | |
1526 */ | |
1527 enum { | |
1528 JAVA_THREAD_STATE_NEW = 0, | |
1529 JAVA_THREAD_STATE_RUNNABLE = 1, | |
1530 JAVA_THREAD_STATE_BLOCKED = 2, | |
1531 JAVA_THREAD_STATE_WAITING = 3, | |
1532 JAVA_THREAD_STATE_TIMED_WAITING = 4, | |
1533 JAVA_THREAD_STATE_TERMINATED = 5, | |
1534 JAVA_THREAD_STATE_COUNT = 6 | |
1535 }; | |
1536 | |
1537 /* | |
1538 * Returns an array of the threadStatus values representing the | |
1539 * given Java thread state. Returns NULL if the VM version is | |
1540 * incompatible with the JDK or doesn't support the given | |
1541 * Java thread state. | |
1542 */ | |
1543 JNIEXPORT jintArray JNICALL | |
1544 JVM_GetThreadStateValues(JNIEnv* env, jint javaThreadState); | |
1545 | |
1546 /* | |
1547 * Returns an array of the substate names representing the | |
1548 * given Java thread state. Returns NULL if the VM version is | |
1549 * incompatible with the JDK or the VM doesn't support | |
1550 * the given Java thread state. | |
1551 * values must be the jintArray returned from JVM_GetThreadStateValues | |
1552 * and javaThreadState. | |
1553 */ | |
1554 JNIEXPORT jobjectArray JNICALL | |
1555 JVM_GetThreadStateNames(JNIEnv* env, jint javaThreadState, jintArray values); | |
1556 | |
1557 /* ========================================================================= | |
1558 * The following defines a private JVM interface that the JDK can query | |
1559 * for the JVM version and capabilities. sun.misc.Version defines | |
1560 * the methods for getting the VM version and its capabilities. | |
1561 * | |
1562 * When a new bit is added, the following should be updated to provide | |
1563 * access to the new capability: | |
1564 * HS: JVM_GetVersionInfo and Abstract_VM_Version class | |
1565 * SDK: Version class | |
1566 * | |
1567 * Similary, a private JDK interface JDK_GetVersionInfo0 is defined for | |
1568 * JVM to query for the JDK version and capabilities. | |
1569 * | |
1570 * When a new bit is added, the following should be updated to provide | |
1571 * access to the new capability: | |
1572 * HS: JDK_Version class | |
1573 * SDK: JDK_GetVersionInfo0 | |
1574 * | |
1575 * ========================================================================== | |
1576 */ | |
1577 typedef struct { | |
1578 /* HotSpot Express VM version string: | |
1579 * <major>.<minor>-bxx[-<identifier>][-<debug_flavor>] | |
1580 */ | |
1581 unsigned int jvm_version; /* Consists of major.minor.0.build */ | |
1582 unsigned int update_version : 8; /* 0 in HotSpot Express VM */ | |
1583 unsigned int special_update_version : 8; /* 0 in HotSpot Express VM */ | |
1584 unsigned int reserved1 : 16; | |
1585 unsigned int reserved2; | |
1586 | |
1587 /* The following bits represents JVM supports that JDK has dependency on. | |
1588 * JDK can use these bits to determine which JVM version | |
1589 * and support it has to maintain runtime compatibility. | |
1590 * | |
1591 * When a new bit is added in a minor or update release, make sure | |
1592 * the new bit is also added in the main/baseline. | |
1593 */ | |
1594 unsigned int is_attachable : 1; | |
1595 unsigned int is_kernel_jvm : 1; | |
1596 unsigned int : 30; | |
1597 unsigned int : 32; | |
1598 unsigned int : 32; | |
1599 } jvm_version_info; | |
1600 | |
1601 #define JVM_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24) | |
1602 #define JVM_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16) | |
1603 // Micro version is 0 in HotSpot Express VM (set in jvm.cpp). | |
1604 #define JVM_VERSION_MICRO(version) ((version & 0x0000FF00) >> 8) | |
1605 /* Build number is available in all HotSpot Express VM builds. | |
1606 * It is defined in make/hotspot_version file. | |
1607 */ | |
1608 #define JVM_VERSION_BUILD(version) ((version & 0x000000FF)) | |
1609 | |
1610 JNIEXPORT void JNICALL | |
1611 JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size); | |
1612 | |
1613 typedef struct { | |
1614 // Naming convention of RE build version string: n.n.n[_uu[c]][-<identifier>]-bxx | |
1615 unsigned int jdk_version; /* Consists of major, minor, micro (n.n.n) */ | |
1616 /* and build number (xx) */ | |
1617 unsigned int update_version : 8; /* Update release version (uu) */ | |
1618 unsigned int special_update_version : 8; /* Special update release version (c)*/ | |
1619 unsigned int reserved1 : 16; | |
1620 unsigned int reserved2; | |
1621 | |
1622 /* The following bits represents new JDK supports that VM has dependency on. | |
1623 * VM implementation can use these bits to determine which JDK version | |
1624 * and support it has to maintain runtime compatibility. | |
1625 * | |
1626 * When a new bit is added in a minor or update release, make sure | |
1627 * the new bit is also added in the main/baseline. | |
1628 */ | |
1629 unsigned int thread_park_blocker : 1; | |
1630 unsigned int : 31; | |
1631 unsigned int : 32; | |
1632 unsigned int : 32; | |
1633 } jdk_version_info; | |
1634 | |
1635 #define JDK_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24) | |
1636 #define JDK_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16) | |
1637 #define JDK_VERSION_MICRO(version) ((version & 0x0000FF00) >> 8) | |
1638 | |
1639 /* Build number is available only for RE build (i.e. JDK_BUILD_NUMBER is set to bNN) | |
1640 * It will be zero for internal builds. | |
1641 */ | |
1642 #define JDK_VERSION_BUILD(version) ((version & 0x000000FF)) | |
1643 | |
1644 /* | |
1645 * This is the function JDK_GetVersionInfo0 defined in libjava.so | |
1646 * that is dynamically looked up by JVM. | |
1647 */ | |
1648 typedef void (*jdk_version_info_fn_t)(jdk_version_info* info, size_t info_size); | |
1649 | |
1650 /* | |
1651 * This structure is used by the launcher to get the default thread | |
1652 * stack size from the VM using JNI_GetDefaultJavaVMInitArgs() with a | |
1653 * version of 1.1. As it is not supported otherwise, it has been removed | |
1654 * from jni.h | |
1655 */ | |
1656 typedef struct JDK1_1InitArgs { | |
1657 jint version; | |
1658 | |
1659 char **properties; | |
1660 jint checkSource; | |
1661 jint nativeStackSize; | |
1662 jint javaStackSize; | |
1663 jint minHeapSize; | |
1664 jint maxHeapSize; | |
1665 jint verifyMode; | |
1666 char *classpath; | |
1667 | |
1668 jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args); | |
1669 void (JNICALL *exit)(jint code); | |
1670 void (JNICALL *abort)(void); | |
1671 | |
1672 jint enableClassGC; | |
1673 jint enableVerboseGC; | |
1674 jint disableAsyncGC; | |
1675 jint verbose; | |
1676 jboolean debugging; | |
1677 jint debugPort; | |
1678 } JDK1_1InitArgs; | |
1679 | |
1680 #ifdef __cplusplus | |
1681 } /* extern "C" */ | |
1682 #endif /* __cplusplus */ | |
1683 | |
1684 #endif /* !_JAVASOFT_JVM_H_ */ |