Fri, 11 Jul 2008 01:14:44 -0700
Merge
1 /*
2 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
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 */
25 #ifndef _JAVASOFT_JVM_H_
26 #define _JAVASOFT_JVM_H_
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.
34 // #include <sys/stat.h>
35 // #include "jni.h"
36 // #include "jvm_md.h"
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
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 */
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 */
71 #define JVM_INTERFACE_VERSION 4
74 JNIEXPORT jint JNICALL
75 JVM_GetInterfaceVersion(void);
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);
86 JNIEXPORT void JNICALL
87 JVM_MonitorWait(JNIEnv *env, jobject obj, jlong ms);
89 JNIEXPORT void JNICALL
90 JVM_MonitorNotify(JNIEnv *env, jobject obj);
92 JNIEXPORT void JNICALL
93 JVM_MonitorNotifyAll(JNIEnv *env, jobject obj);
95 JNIEXPORT jobject JNICALL
96 JVM_Clone(JNIEnv *env, jobject obj);
98 /*
99 * java.lang.String
100 */
101 JNIEXPORT jstring JNICALL
102 JVM_InternString(JNIEnv *env, jstring str);
104 /*
105 * java.lang.System
106 */
107 JNIEXPORT jlong JNICALL
108 JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored);
110 JNIEXPORT jlong JNICALL
111 JVM_NanoTime(JNIEnv *env, jclass ignored);
113 JNIEXPORT void JNICALL
114 JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos,
115 jobject dst, jint dst_pos, jint length);
117 JNIEXPORT jobject JNICALL
118 JVM_InitProperties(JNIEnv *env, jobject p);
120 /*
121 * java.io.File
122 */
123 JNIEXPORT void JNICALL
124 JVM_OnExit(void (*func)(void));
126 /*
127 * java.lang.Runtime
128 */
129 JNIEXPORT void JNICALL
130 JVM_Exit(jint code);
132 JNIEXPORT void JNICALL
133 JVM_Halt(jint code);
135 JNIEXPORT void JNICALL
136 JVM_GC(void);
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);
155 JNIEXPORT void JNICALL
156 JVM_TraceInstructions(jboolean on);
158 JNIEXPORT void JNICALL
159 JVM_TraceMethodCalls(jboolean on);
161 JNIEXPORT jlong JNICALL
162 JVM_TotalMemory(void);
164 JNIEXPORT jlong JNICALL
165 JVM_FreeMemory(void);
167 JNIEXPORT jlong JNICALL
168 JVM_MaxMemory(void);
170 JNIEXPORT jint JNICALL
171 JVM_ActiveProcessorCount(void);
173 JNIEXPORT void * JNICALL
174 JVM_LoadLibrary(const char *name);
176 JNIEXPORT void JNICALL
177 JVM_UnloadLibrary(void * handle);
179 JNIEXPORT void * JNICALL
180 JVM_FindLibraryEntry(void *handle, const char *name);
182 JNIEXPORT jboolean JNICALL
183 JVM_IsSupportedJNIVersion(jint version);
185 /*
186 * java.lang.Float and java.lang.Double
187 */
188 JNIEXPORT jboolean JNICALL
189 JVM_IsNaN(jdouble d);
191 /*
192 * java.lang.Throwable
193 */
194 JNIEXPORT void JNICALL
195 JVM_FillInStackTrace(JNIEnv *env, jobject throwable);
197 JNIEXPORT void JNICALL
198 JVM_PrintStackTrace(JNIEnv *env, jobject throwable, jobject printable);
200 JNIEXPORT jint JNICALL
201 JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable);
203 JNIEXPORT jobject JNICALL
204 JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index);
206 /*
207 * java.lang.Compiler
208 */
209 JNIEXPORT void JNICALL
210 JVM_InitializeCompiler (JNIEnv *env, jclass compCls);
212 JNIEXPORT jboolean JNICALL
213 JVM_IsSilentCompiler(JNIEnv *env, jclass compCls);
215 JNIEXPORT jboolean JNICALL
216 JVM_CompileClass(JNIEnv *env, jclass compCls, jclass cls);
218 JNIEXPORT jboolean JNICALL
219 JVM_CompileClasses(JNIEnv *env, jclass cls, jstring jname);
221 JNIEXPORT jobject JNICALL
222 JVM_CompilerCommand(JNIEnv *env, jclass compCls, jobject arg);
224 JNIEXPORT void JNICALL
225 JVM_EnableCompiler(JNIEnv *env, jclass compCls);
227 JNIEXPORT void JNICALL
228 JVM_DisableCompiler(JNIEnv *env, jclass compCls);
230 /*
231 * java.lang.Thread
232 */
233 JNIEXPORT void JNICALL
234 JVM_StartThread(JNIEnv *env, jobject thread);
236 JNIEXPORT void JNICALL
237 JVM_StopThread(JNIEnv *env, jobject thread, jobject exception);
239 JNIEXPORT jboolean JNICALL
240 JVM_IsThreadAlive(JNIEnv *env, jobject thread);
242 JNIEXPORT void JNICALL
243 JVM_SuspendThread(JNIEnv *env, jobject thread);
245 JNIEXPORT void JNICALL
246 JVM_ResumeThread(JNIEnv *env, jobject thread);
248 JNIEXPORT void JNICALL
249 JVM_SetThreadPriority(JNIEnv *env, jobject thread, jint prio);
251 JNIEXPORT void JNICALL
252 JVM_Yield(JNIEnv *env, jclass threadClass);
254 JNIEXPORT void JNICALL
255 JVM_Sleep(JNIEnv *env, jclass threadClass, jlong millis);
257 JNIEXPORT jobject JNICALL
258 JVM_CurrentThread(JNIEnv *env, jclass threadClass);
260 JNIEXPORT jint JNICALL
261 JVM_CountStackFrames(JNIEnv *env, jobject thread);
263 JNIEXPORT void JNICALL
264 JVM_Interrupt(JNIEnv *env, jobject thread);
266 JNIEXPORT jboolean JNICALL
267 JVM_IsInterrupted(JNIEnv *env, jobject thread, jboolean clearInterrupted);
269 JNIEXPORT jboolean JNICALL
270 JVM_HoldsLock(JNIEnv *env, jclass threadClass, jobject obj);
272 JNIEXPORT void JNICALL
273 JVM_DumpAllStacks(JNIEnv *env, jclass unused);
275 JNIEXPORT jobjectArray JNICALL
276 JVM_GetAllThreads(JNIEnv *env, jclass dummy);
278 /* getStackTrace() and getAllStackTraces() method */
279 JNIEXPORT jobjectArray JNICALL
280 JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads);
282 /*
283 * java.lang.SecurityManager
284 */
285 JNIEXPORT jclass JNICALL
286 JVM_CurrentLoadedClass(JNIEnv *env);
288 JNIEXPORT jobject JNICALL
289 JVM_CurrentClassLoader(JNIEnv *env);
291 JNIEXPORT jobjectArray JNICALL
292 JVM_GetClassContext(JNIEnv *env);
294 JNIEXPORT jint JNICALL
295 JVM_ClassDepth(JNIEnv *env, jstring name);
297 JNIEXPORT jint JNICALL
298 JVM_ClassLoaderDepth(JNIEnv *env);
300 /*
301 * java.lang.Package
302 */
303 JNIEXPORT jstring JNICALL
304 JVM_GetSystemPackage(JNIEnv *env, jstring name);
306 JNIEXPORT jobjectArray JNICALL
307 JVM_GetSystemPackages(JNIEnv *env);
309 /*
310 * java.io.ObjectInputStream
311 */
312 JNIEXPORT jobject JNICALL
313 JVM_AllocateNewObject(JNIEnv *env, jobject obj, jclass currClass,
314 jclass initClass);
316 JNIEXPORT jobject JNICALL
317 JVM_AllocateNewArray(JNIEnv *env, jobject obj, jclass currClass,
318 jint length);
320 JNIEXPORT jobject JNICALL
321 JVM_LatestUserDefinedLoader(JNIEnv *env);
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);
331 /*
332 * java.lang.reflect.Array
333 */
334 JNIEXPORT jint JNICALL
335 JVM_GetArrayLength(JNIEnv *env, jobject arr);
337 JNIEXPORT jobject JNICALL
338 JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index);
340 JNIEXPORT jvalue JNICALL
341 JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode);
343 JNIEXPORT void JNICALL
344 JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val);
346 JNIEXPORT void JNICALL
347 JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v,
348 unsigned char vCode);
350 JNIEXPORT jobject JNICALL
351 JVM_NewArray(JNIEnv *env, jclass eltClass, jint length);
353 JNIEXPORT jobject JNICALL
354 JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim);
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);
370 /*
371 * Find primitive classes
372 * utf: class name
373 */
374 JNIEXPORT jclass JNICALL
375 JVM_FindPrimitiveClass(JNIEnv *env, const char *utf);
377 /*
378 * Link the class
379 */
380 JNIEXPORT void JNICALL
381 JVM_ResolveClass(JNIEnv *env, jclass cls);
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);
392 /*
393 * Find a class from a boot class loader. Throw ClassNotFoundException
394 * or NoClassDefFoundError depending on the value of the last
395 * argument. This is the same as FindClassFromClassLoader but provided
396 * as a convenience method exported correctly on all platforms for
397 * JSR 277 launcher class loading.
398 */
399 JNIEXPORT jclass JNICALL
400 JVM_FindClassFromBootLoader(JNIEnv *env, const char *name,
401 jboolean throwError);
403 /*
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);
410 /* Find a loaded class cached by the VM */
411 JNIEXPORT jclass JNICALL
412 JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name);
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);
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);
425 /*
426 * Reflection support functions
427 */
429 JNIEXPORT jstring JNICALL
430 JVM_GetClassName(JNIEnv *env, jclass cls);
432 JNIEXPORT jobjectArray JNICALL
433 JVM_GetClassInterfaces(JNIEnv *env, jclass cls);
435 JNIEXPORT jobject JNICALL
436 JVM_GetClassLoader(JNIEnv *env, jclass cls);
438 JNIEXPORT jboolean JNICALL
439 JVM_IsInterface(JNIEnv *env, jclass cls);
441 JNIEXPORT jobjectArray JNICALL
442 JVM_GetClassSigners(JNIEnv *env, jclass cls);
444 JNIEXPORT void JNICALL
445 JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers);
447 JNIEXPORT jobject JNICALL
448 JVM_GetProtectionDomain(JNIEnv *env, jclass cls);
450 JNIEXPORT void JNICALL
451 JVM_SetProtectionDomain(JNIEnv *env, jclass cls, jobject protection_domain);
453 JNIEXPORT jboolean JNICALL
454 JVM_IsArrayClass(JNIEnv *env, jclass cls);
456 JNIEXPORT jboolean JNICALL
457 JVM_IsPrimitiveClass(JNIEnv *env, jclass cls);
459 JNIEXPORT jclass JNICALL
460 JVM_GetComponentType(JNIEnv *env, jclass cls);
462 JNIEXPORT jint JNICALL
463 JVM_GetClassModifiers(JNIEnv *env, jclass cls);
465 JNIEXPORT jobjectArray JNICALL
466 JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass);
468 JNIEXPORT jclass JNICALL
469 JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass);
471 /* Generics support (JDK 1.5) */
472 JNIEXPORT jstring JNICALL
473 JVM_GetClassSignature(JNIEnv *env, jclass cls);
475 /* Annotations support (JDK 1.5) */
476 JNIEXPORT jbyteArray JNICALL
477 JVM_GetClassAnnotations(JNIEnv *env, jclass cls);
479 /* Annotations support (JDK 1.6) */
481 // field is a handle to a java.lang.reflect.Field object
482 JNIEXPORT jbyteArray JNICALL
483 JVM_GetFieldAnnotations(JNIEnv *env, jobject field);
485 // method is a handle to a java.lang.reflect.Method object
486 JNIEXPORT jbyteArray JNICALL
487 JVM_GetMethodAnnotations(JNIEnv *env, jobject method);
489 // method is a handle to a java.lang.reflect.Method object
490 JNIEXPORT jbyteArray JNICALL
491 JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method);
493 // method is a handle to a java.lang.reflect.Method object
494 JNIEXPORT jbyteArray JNICALL
495 JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method);
498 /*
499 * New (JDK 1.4) reflection implementation
500 */
502 JNIEXPORT jobjectArray JNICALL
503 JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly);
505 JNIEXPORT jobjectArray JNICALL
506 JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly);
508 JNIEXPORT jobjectArray JNICALL
509 JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly);
511 /* Differs from JVM_GetClassModifiers in treatment of inner classes.
512 This returns the access flags for the class as specified in the
513 class file rather than searching the InnerClasses attribute (if
514 present) to find the source-level access flags. Only the values of
515 the low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be
516 valid. */
517 JNIEXPORT jint JNICALL
518 JVM_GetClassAccessFlags(JNIEnv *env, jclass cls);
520 /*
521 * Constant pool access; currently used to implement reflective access to annotations (JDK 1.5)
522 */
524 JNIEXPORT jobject JNICALL
525 JVM_GetClassConstantPool(JNIEnv *env, jclass cls);
527 JNIEXPORT jint JNICALL JVM_ConstantPoolGetSize
528 (JNIEnv *env, jobject unused, jobject jcpool);
530 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAt
531 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
533 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAtIfLoaded
534 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
536 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAt
537 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
539 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAtIfLoaded
540 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
542 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAt
543 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
545 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAtIfLoaded
546 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
548 JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetMemberRefInfoAt
549 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
551 JNIEXPORT jint JNICALL JVM_ConstantPoolGetIntAt
552 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
554 JNIEXPORT jlong JNICALL JVM_ConstantPoolGetLongAt
555 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
557 JNIEXPORT jfloat JNICALL JVM_ConstantPoolGetFloatAt
558 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
560 JNIEXPORT jdouble JNICALL JVM_ConstantPoolGetDoubleAt
561 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
563 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetStringAt
564 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
566 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetUTF8At
567 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
569 /*
570 * java.security.*
571 */
573 JNIEXPORT jobject JNICALL
574 JVM_DoPrivileged(JNIEnv *env, jclass cls,
575 jobject action, jobject context, jboolean wrapException);
577 JNIEXPORT jobject JNICALL
578 JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls);
580 JNIEXPORT jobject JNICALL
581 JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls);
583 /*
584 * Signal support, used to implement the shutdown sequence. Every VM must
585 * support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts
586 * (^C) and the latter for external termination (kill, system shutdown, etc.).
587 * Other platform-dependent signal values may also be supported.
588 */
590 JNIEXPORT void * JNICALL
591 JVM_RegisterSignal(jint sig, void *handler);
593 JNIEXPORT jboolean JNICALL
594 JVM_RaiseSignal(jint sig);
596 JNIEXPORT jint JNICALL
597 JVM_FindSignal(const char *name);
599 /*
600 * Retrieve the assertion directives for the specified class.
601 */
602 JNIEXPORT jboolean JNICALL
603 JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls);
605 /*
606 * Retrieve the assertion directives from the VM.
607 */
608 JNIEXPORT jobject JNICALL
609 JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused);
611 /*
612 * sun.misc.AtomicLong
613 */
614 JNIEXPORT jboolean JNICALL
615 JVM_SupportsCX8(void);
617 JNIEXPORT jboolean JNICALL
618 JVM_CX8Field(JNIEnv *env, jobject obj, jfieldID fldID, jlong oldVal, jlong newVal);
620 /*
621 * com.sun.dtrace.jsdt support
622 */
624 #define JVM_TRACING_DTRACE_VERSION 1
626 /*
627 * Structure to pass one probe description to JVM.
628 *
629 * The VM will overwrite the definition of the referenced method with
630 * code that will fire the probe.
631 */
632 typedef struct {
633 jmethodID method;
634 jstring function;
635 jstring name;
636 void* reserved[4]; // for future use
637 } JVM_DTraceProbe;
639 /**
640 * Encapsulates the stability ratings for a DTrace provider field
641 */
642 typedef struct {
643 jint nameStability;
644 jint dataStability;
645 jint dependencyClass;
646 } JVM_DTraceInterfaceAttributes;
648 /*
649 * Structure to pass one provider description to JVM
650 */
651 typedef struct {
652 jstring name;
653 JVM_DTraceProbe* probes;
654 jint probe_count;
655 JVM_DTraceInterfaceAttributes providerAttributes;
656 JVM_DTraceInterfaceAttributes moduleAttributes;
657 JVM_DTraceInterfaceAttributes functionAttributes;
658 JVM_DTraceInterfaceAttributes nameAttributes;
659 JVM_DTraceInterfaceAttributes argsAttributes;
660 void* reserved[4]; // for future use
661 } JVM_DTraceProvider;
663 /*
664 * Get the version number the JVM was built with
665 */
666 JNIEXPORT jint JNICALL
667 JVM_DTraceGetVersion(JNIEnv* env);
669 /*
670 * Register new probe with given signature, return global handle
671 *
672 * The version passed in is the version that the library code was
673 * built with.
674 */
675 JNIEXPORT jlong JNICALL
676 JVM_DTraceActivate(JNIEnv* env, jint version, jstring module_name,
677 jint providers_count, JVM_DTraceProvider* providers);
679 /*
680 * Check JSDT probe
681 */
682 JNIEXPORT jboolean JNICALL
683 JVM_DTraceIsProbeEnabled(JNIEnv* env, jmethodID method);
685 /*
686 * Destroy custom DOF
687 */
688 JNIEXPORT void JNICALL
689 JVM_DTraceDispose(JNIEnv* env, jlong handle);
691 /*
692 * Check to see if DTrace is supported by OS
693 */
694 JNIEXPORT jboolean JNICALL
695 JVM_DTraceIsSupported(JNIEnv* env);
697 /*************************************************************************
698 PART 2: Support for the Verifier and Class File Format Checker
699 ************************************************************************/
700 /*
701 * Return the class name in UTF format. The result is valid
702 * until JVM_ReleaseUTf is called.
703 *
704 * The caller must treat the string as a constant and not modify it
705 * in any way.
706 */
707 JNIEXPORT const char * JNICALL
708 JVM_GetClassNameUTF(JNIEnv *env, jclass cb);
710 /*
711 * Returns the constant pool types in the buffer provided by "types."
712 */
713 JNIEXPORT void JNICALL
714 JVM_GetClassCPTypes(JNIEnv *env, jclass cb, unsigned char *types);
716 /*
717 * Returns the number of Constant Pool entries.
718 */
719 JNIEXPORT jint JNICALL
720 JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cb);
722 /*
723 * Returns the number of *declared* fields or methods.
724 */
725 JNIEXPORT jint JNICALL
726 JVM_GetClassFieldsCount(JNIEnv *env, jclass cb);
728 JNIEXPORT jint JNICALL
729 JVM_GetClassMethodsCount(JNIEnv *env, jclass cb);
731 /*
732 * Returns the CP indexes of exceptions raised by a given method.
733 * Places the result in the given buffer.
734 *
735 * The method is identified by method_index.
736 */
737 JNIEXPORT void JNICALL
738 JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cb, jint method_index,
739 unsigned short *exceptions);
740 /*
741 * Returns the number of exceptions raised by a given method.
742 * The method is identified by method_index.
743 */
744 JNIEXPORT jint JNICALL
745 JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cb, jint method_index);
747 /*
748 * Returns the byte code sequence of a given method.
749 * Places the result in the given buffer.
750 *
751 * The method is identified by method_index.
752 */
753 JNIEXPORT void JNICALL
754 JVM_GetMethodIxByteCode(JNIEnv *env, jclass cb, jint method_index,
755 unsigned char *code);
757 /*
758 * Returns the length of the byte code sequence of a given method.
759 * The method is identified by method_index.
760 */
761 JNIEXPORT jint JNICALL
762 JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cb, jint method_index);
764 /*
765 * A structure used to a capture exception table entry in a Java method.
766 */
767 typedef struct {
768 jint start_pc;
769 jint end_pc;
770 jint handler_pc;
771 jint catchType;
772 } JVM_ExceptionTableEntryType;
774 /*
775 * Returns the exception table entry at entry_index of a given method.
776 * Places the result in the given buffer.
777 *
778 * The method is identified by method_index.
779 */
780 JNIEXPORT void JNICALL
781 JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cb, jint method_index,
782 jint entry_index,
783 JVM_ExceptionTableEntryType *entry);
785 /*
786 * Returns the length of the exception table of a given method.
787 * The method is identified by method_index.
788 */
789 JNIEXPORT jint JNICALL
790 JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cb, int index);
792 /*
793 * Returns the modifiers of a given field.
794 * The field is identified by field_index.
795 */
796 JNIEXPORT jint JNICALL
797 JVM_GetFieldIxModifiers(JNIEnv *env, jclass cb, int index);
799 /*
800 * Returns the modifiers of a given method.
801 * The method is identified by method_index.
802 */
803 JNIEXPORT jint JNICALL
804 JVM_GetMethodIxModifiers(JNIEnv *env, jclass cb, int index);
806 /*
807 * Returns the number of local variables of a given method.
808 * The method is identified by method_index.
809 */
810 JNIEXPORT jint JNICALL
811 JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cb, int index);
813 /*
814 * Returns the number of arguments (including this pointer) of a given method.
815 * The method is identified by method_index.
816 */
817 JNIEXPORT jint JNICALL
818 JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cb, int index);
820 /*
821 * Returns the maximum amount of stack (in words) used by a given method.
822 * The method is identified by method_index.
823 */
824 JNIEXPORT jint JNICALL
825 JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cb, int index);
827 /*
828 * Is a given method a constructor.
829 * The method is identified by method_index.
830 */
831 JNIEXPORT jboolean JNICALL
832 JVM_IsConstructorIx(JNIEnv *env, jclass cb, int index);
834 /*
835 * Returns the name of a given method in UTF format.
836 * The result remains valid until JVM_ReleaseUTF is called.
837 *
838 * The caller must treat the string as a constant and not modify it
839 * in any way.
840 */
841 JNIEXPORT const char * JNICALL
842 JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cb, jint index);
844 /*
845 * Returns the signature of a given method in UTF format.
846 * The result remains valid until JVM_ReleaseUTF is called.
847 *
848 * The caller must treat the string as a constant and not modify it
849 * in any way.
850 */
851 JNIEXPORT const char * JNICALL
852 JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cb, jint index);
854 /*
855 * Returns the name of the field refered to at a given constant pool
856 * index.
857 *
858 * The result is in UTF format and remains valid until JVM_ReleaseUTF
859 * is called.
860 *
861 * The caller must treat the string as a constant and not modify it
862 * in any way.
863 */
864 JNIEXPORT const char * JNICALL
865 JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cb, jint index);
867 /*
868 * Returns the name of the method refered to at a given constant pool
869 * index.
870 *
871 * The result is in UTF format and remains valid until JVM_ReleaseUTF
872 * is called.
873 *
874 * The caller must treat the string as a constant and not modify it
875 * in any way.
876 */
877 JNIEXPORT const char * JNICALL
878 JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cb, jint index);
880 /*
881 * Returns the signature of the method refered to at a given constant pool
882 * index.
883 *
884 * The result is in UTF format and remains valid until JVM_ReleaseUTF
885 * is called.
886 *
887 * The caller must treat the string as a constant and not modify it
888 * in any way.
889 */
890 JNIEXPORT const char * JNICALL
891 JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cb, jint index);
893 /*
894 * Returns the signature of the field refered to at a given constant pool
895 * index.
896 *
897 * The result is in UTF format and remains valid until JVM_ReleaseUTF
898 * is called.
899 *
900 * The caller must treat the string as a constant and not modify it
901 * in any way.
902 */
903 JNIEXPORT const char * JNICALL
904 JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cb, jint index);
906 /*
907 * Returns the class name refered to at a given constant pool index.
908 *
909 * The result is in UTF format and remains valid until JVM_ReleaseUTF
910 * is called.
911 *
912 * The caller must treat the string as a constant and not modify it
913 * in any way.
914 */
915 JNIEXPORT const char * JNICALL
916 JVM_GetCPClassNameUTF(JNIEnv *env, jclass cb, jint index);
918 /*
919 * Returns the class name refered to at a given constant pool index.
920 *
921 * The constant pool entry must refer to a CONSTANT_Fieldref.
922 *
923 * The result is in UTF format and remains valid until JVM_ReleaseUTF
924 * is called.
925 *
926 * The caller must treat the string as a constant and not modify it
927 * in any way.
928 */
929 JNIEXPORT const char * JNICALL
930 JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cb, jint index);
932 /*
933 * Returns the class name refered to at a given constant pool index.
934 *
935 * The constant pool entry must refer to CONSTANT_Methodref or
936 * CONSTANT_InterfaceMethodref.
937 *
938 * The result is in UTF format and remains valid until JVM_ReleaseUTF
939 * is called.
940 *
941 * The caller must treat the string as a constant and not modify it
942 * in any way.
943 */
944 JNIEXPORT const char * JNICALL
945 JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cb, jint index);
947 /*
948 * Returns the modifiers of a field in calledClass. The field is
949 * referred to in class cb at constant pool entry index.
950 *
951 * The caller must treat the string as a constant and not modify it
952 * in any way.
953 *
954 * Returns -1 if the field does not exist in calledClass.
955 */
956 JNIEXPORT jint JNICALL
957 JVM_GetCPFieldModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
959 /*
960 * Returns the modifiers of a method in calledClass. The method is
961 * referred to in class cb at constant pool entry index.
962 *
963 * Returns -1 if the method does not exist in calledClass.
964 */
965 JNIEXPORT jint JNICALL
966 JVM_GetCPMethodModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
968 /*
969 * Releases the UTF string obtained from the VM.
970 */
971 JNIEXPORT void JNICALL
972 JVM_ReleaseUTF(const char *utf);
974 /*
975 * Compare if two classes are in the same package.
976 */
977 JNIEXPORT jboolean JNICALL
978 JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2);
980 /* Constants in class files */
982 #define JVM_ACC_PUBLIC 0x0001 /* visible to everyone */
983 #define JVM_ACC_PRIVATE 0x0002 /* visible only to the defining class */
984 #define JVM_ACC_PROTECTED 0x0004 /* visible to subclasses */
985 #define JVM_ACC_STATIC 0x0008 /* instance variable is static */
986 #define JVM_ACC_FINAL 0x0010 /* no further subclassing, overriding */
987 #define JVM_ACC_SYNCHRONIZED 0x0020 /* wrap method call in monitor lock */
988 #define JVM_ACC_SUPER 0x0020 /* funky handling of invokespecial */
989 #define JVM_ACC_VOLATILE 0x0040 /* can not cache in registers */
990 #define JVM_ACC_BRIDGE 0x0040 /* bridge method generated by compiler */
991 #define JVM_ACC_TRANSIENT 0x0080 /* not persistent */
992 #define JVM_ACC_VARARGS 0x0080 /* method declared with variable number of args */
993 #define JVM_ACC_NATIVE 0x0100 /* implemented in C */
994 #define JVM_ACC_INTERFACE 0x0200 /* class is an interface */
995 #define JVM_ACC_ABSTRACT 0x0400 /* no definition provided */
996 #define JVM_ACC_STRICT 0x0800 /* strict floating point */
997 #define JVM_ACC_SYNTHETIC 0x1000 /* compiler-generated class, method or field */
998 #define JVM_ACC_ANNOTATION 0x2000 /* annotation type */
999 #define JVM_ACC_ENUM 0x4000 /* field is declared as element of enum */
1001 #define JVM_ACC_PUBLIC_BIT 0
1002 #define JVM_ACC_PRIVATE_BIT 1
1003 #define JVM_ACC_PROTECTED_BIT 2
1004 #define JVM_ACC_STATIC_BIT 3
1005 #define JVM_ACC_FINAL_BIT 4
1006 #define JVM_ACC_SYNCHRONIZED_BIT 5
1007 #define JVM_ACC_SUPER_BIT 5
1008 #define JVM_ACC_VOLATILE_BIT 6
1009 #define JVM_ACC_BRIDGE_BIT 6
1010 #define JVM_ACC_TRANSIENT_BIT 7
1011 #define JVM_ACC_VARARGS_BIT 7
1012 #define JVM_ACC_NATIVE_BIT 8
1013 #define JVM_ACC_INTERFACE_BIT 9
1014 #define JVM_ACC_ABSTRACT_BIT 10
1015 #define JVM_ACC_STRICT_BIT 11
1016 #define JVM_ACC_SYNTHETIC_BIT 12
1017 #define JVM_ACC_ANNOTATION_BIT 13
1018 #define JVM_ACC_ENUM_BIT 14
1020 // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/utilities/ConstantTag.java
1021 enum {
1022 JVM_CONSTANT_Utf8 = 1,
1023 JVM_CONSTANT_Unicode, /* unused */
1024 JVM_CONSTANT_Integer,
1025 JVM_CONSTANT_Float,
1026 JVM_CONSTANT_Long,
1027 JVM_CONSTANT_Double,
1028 JVM_CONSTANT_Class,
1029 JVM_CONSTANT_String,
1030 JVM_CONSTANT_Fieldref,
1031 JVM_CONSTANT_Methodref,
1032 JVM_CONSTANT_InterfaceMethodref,
1033 JVM_CONSTANT_NameAndType
1034 };
1036 /* Used in the newarray instruction. */
1038 #define JVM_T_BOOLEAN 4
1039 #define JVM_T_CHAR 5
1040 #define JVM_T_FLOAT 6
1041 #define JVM_T_DOUBLE 7
1042 #define JVM_T_BYTE 8
1043 #define JVM_T_SHORT 9
1044 #define JVM_T_INT 10
1045 #define JVM_T_LONG 11
1047 /* JVM method signatures */
1049 #define JVM_SIGNATURE_ARRAY '['
1050 #define JVM_SIGNATURE_BYTE 'B'
1051 #define JVM_SIGNATURE_CHAR 'C'
1052 #define JVM_SIGNATURE_CLASS 'L'
1053 #define JVM_SIGNATURE_ENDCLASS ';'
1054 #define JVM_SIGNATURE_ENUM 'E'
1055 #define JVM_SIGNATURE_FLOAT 'F'
1056 #define JVM_SIGNATURE_DOUBLE 'D'
1057 #define JVM_SIGNATURE_FUNC '('
1058 #define JVM_SIGNATURE_ENDFUNC ')'
1059 #define JVM_SIGNATURE_INT 'I'
1060 #define JVM_SIGNATURE_LONG 'J'
1061 #define JVM_SIGNATURE_SHORT 'S'
1062 #define JVM_SIGNATURE_VOID 'V'
1063 #define JVM_SIGNATURE_BOOLEAN 'Z'
1065 /*
1066 * A function defined by the byte-code verifier and called by the VM.
1067 * This is not a function implemented in the VM.
1068 *
1069 * Returns JNI_FALSE if verification fails. A detailed error message
1070 * will be places in msg_buf, whose length is specified by buf_len.
1071 */
1072 typedef jboolean (*verifier_fn_t)(JNIEnv *env,
1073 jclass cb,
1074 char * msg_buf,
1075 jint buf_len);
1078 /*
1079 * Support for a VM-independent class format checker.
1080 */
1081 typedef struct {
1082 unsigned long code; /* byte code */
1083 unsigned long excs; /* exceptions */
1084 unsigned long etab; /* catch table */
1085 unsigned long lnum; /* line number */
1086 unsigned long lvar; /* local vars */
1087 } method_size_info;
1089 typedef struct {
1090 unsigned int constants; /* constant pool */
1091 unsigned int fields;
1092 unsigned int methods;
1093 unsigned int interfaces;
1094 unsigned int fields2; /* number of static 2-word fields */
1095 unsigned int innerclasses; /* # of records in InnerClasses attr */
1097 method_size_info clinit; /* memory used in clinit */
1098 method_size_info main; /* used everywhere else */
1099 } class_size_info;
1101 /*
1102 * Functions defined in libjava.so to perform string conversions.
1103 *
1104 */
1106 typedef jstring (*to_java_string_fn_t)(JNIEnv *env, char *str);
1108 typedef char *(*to_c_string_fn_t)(JNIEnv *env, jstring s, jboolean *b);
1110 /* This is the function defined in libjava.so that performs class
1111 * format checks. This functions fills in size information about
1112 * the class file and returns:
1113 *
1114 * 0: good
1115 * -1: out of memory
1116 * -2: bad format
1117 * -3: unsupported version
1118 * -4: bad class name
1119 */
1121 typedef jint (*check_format_fn_t)(char *class_name,
1122 unsigned char *data,
1123 unsigned int data_size,
1124 class_size_info *class_size,
1125 char *message_buffer,
1126 jint buffer_length,
1127 jboolean measure_only,
1128 jboolean check_relaxed);
1130 #define JVM_RECOGNIZED_CLASS_MODIFIERS (JVM_ACC_PUBLIC | \
1131 JVM_ACC_FINAL | \
1132 JVM_ACC_SUPER | \
1133 JVM_ACC_INTERFACE | \
1134 JVM_ACC_ABSTRACT | \
1135 JVM_ACC_ANNOTATION | \
1136 JVM_ACC_ENUM | \
1137 JVM_ACC_SYNTHETIC)
1139 #define JVM_RECOGNIZED_FIELD_MODIFIERS (JVM_ACC_PUBLIC | \
1140 JVM_ACC_PRIVATE | \
1141 JVM_ACC_PROTECTED | \
1142 JVM_ACC_STATIC | \
1143 JVM_ACC_FINAL | \
1144 JVM_ACC_VOLATILE | \
1145 JVM_ACC_TRANSIENT | \
1146 JVM_ACC_ENUM | \
1147 JVM_ACC_SYNTHETIC)
1149 #define JVM_RECOGNIZED_METHOD_MODIFIERS (JVM_ACC_PUBLIC | \
1150 JVM_ACC_PRIVATE | \
1151 JVM_ACC_PROTECTED | \
1152 JVM_ACC_STATIC | \
1153 JVM_ACC_FINAL | \
1154 JVM_ACC_SYNCHRONIZED | \
1155 JVM_ACC_BRIDGE | \
1156 JVM_ACC_VARARGS | \
1157 JVM_ACC_NATIVE | \
1158 JVM_ACC_ABSTRACT | \
1159 JVM_ACC_STRICT | \
1160 JVM_ACC_SYNTHETIC)
1162 /*
1163 * This is the function defined in libjava.so to perform path
1164 * canonicalization. VM call this function before opening jar files
1165 * to load system classes.
1166 *
1167 */
1169 typedef int (*canonicalize_fn_t)(JNIEnv *env, char *orig, char *out, int len);
1171 /*************************************************************************
1172 PART 3: I/O and Network Support
1173 ************************************************************************/
1175 /* Note that the JVM IO functions are expected to return JVM_IO_ERR
1176 * when there is any kind of error. The caller can then use the
1177 * platform specific support (e.g., errno) to get the detailed
1178 * error info. The JVM_GetLastErrorString procedure may also be used
1179 * to obtain a descriptive error string.
1180 */
1181 #define JVM_IO_ERR (-1)
1183 /* For interruptible IO. Returning JVM_IO_INTR indicates that an IO
1184 * operation has been disrupted by Thread.interrupt. There are a
1185 * number of technical difficulties related to interruptible IO that
1186 * need to be solved. For example, most existing programs do not handle
1187 * InterruptedIOExceptions specially, they simply treat those as any
1188 * IOExceptions, which typically indicate fatal errors.
1189 *
1190 * There are also two modes of operation for interruptible IO. In the
1191 * resumption mode, an interrupted IO operation is guaranteed not to
1192 * have any side-effects, and can be restarted. In the termination mode,
1193 * an interrupted IO operation corrupts the underlying IO stream, so
1194 * that the only reasonable operation on an interrupted stream is to
1195 * close that stream. The resumption mode seems to be impossible to
1196 * implement on Win32 and Solaris. Implementing the termination mode is
1197 * easier, but it's not clear that's the right semantics.
1198 *
1199 * Interruptible IO is not supported on Win32.It can be enabled/disabled
1200 * using a compile-time flag on Solaris. Third-party JVM ports do not
1201 * need to implement interruptible IO.
1202 */
1203 #define JVM_IO_INTR (-2)
1205 /* Write a string into the given buffer, in the platform's local encoding,
1206 * that describes the most recent system-level error to occur in this thread.
1207 * Return the length of the string or zero if no error occurred.
1208 */
1209 JNIEXPORT jint JNICALL
1210 JVM_GetLastErrorString(char *buf, int len);
1212 /*
1213 * Convert a pathname into native format. This function does syntactic
1214 * cleanup, such as removing redundant separator characters. It modifies
1215 * the given pathname string in place.
1216 */
1217 JNIEXPORT char * JNICALL
1218 JVM_NativePath(char *);
1220 /*
1221 * JVM I/O error codes
1222 */
1223 #define JVM_EEXIST -100
1225 /*
1226 * Open a file descriptor. This function returns a negative error code
1227 * on error, and a non-negative integer that is the file descriptor on
1228 * success.
1229 */
1230 JNIEXPORT jint JNICALL
1231 JVM_Open(const char *fname, jint flags, jint mode);
1233 /*
1234 * Close a file descriptor. This function returns -1 on error, and 0
1235 * on success.
1236 *
1237 * fd the file descriptor to close.
1238 */
1239 JNIEXPORT jint JNICALL
1240 JVM_Close(jint fd);
1242 /*
1243 * Read data from a file decriptor into a char array.
1244 *
1245 * fd the file descriptor to read from.
1246 * buf the buffer where to put the read data.
1247 * nbytes the number of bytes to read.
1248 *
1249 * This function returns -1 on error, and 0 on success.
1250 */
1251 JNIEXPORT jint JNICALL
1252 JVM_Read(jint fd, char *buf, jint nbytes);
1254 /*
1255 * Write data from a char array to a file decriptor.
1256 *
1257 * fd the file descriptor to read from.
1258 * buf the buffer from which to fetch the data.
1259 * nbytes the number of bytes to write.
1260 *
1261 * This function returns -1 on error, and 0 on success.
1262 */
1263 JNIEXPORT jint JNICALL
1264 JVM_Write(jint fd, char *buf, jint nbytes);
1266 /*
1267 * Returns the number of bytes available for reading from a given file
1268 * descriptor
1269 */
1270 JNIEXPORT jint JNICALL
1271 JVM_Available(jint fd, jlong *pbytes);
1273 /*
1274 * Move the file descriptor pointer from whence by offset.
1275 *
1276 * fd the file descriptor to move.
1277 * offset the number of bytes to move it by.
1278 * whence the start from where to move it.
1279 *
1280 * This function returns the resulting pointer location.
1281 */
1282 JNIEXPORT jlong JNICALL
1283 JVM_Lseek(jint fd, jlong offset, jint whence);
1285 /*
1286 * Set the length of the file associated with the given descriptor to the given
1287 * length. If the new length is longer than the current length then the file
1288 * is extended; the contents of the extended portion are not defined. The
1289 * value of the file pointer is undefined after this procedure returns.
1290 */
1291 JNIEXPORT jint JNICALL
1292 JVM_SetLength(jint fd, jlong length);
1294 /*
1295 * Synchronize the file descriptor's in memory state with that of the
1296 * physical device. Return of -1 is an error, 0 is OK.
1297 */
1298 JNIEXPORT jint JNICALL
1299 JVM_Sync(jint fd);
1301 /*
1302 * Networking library support
1303 */
1305 JNIEXPORT jint JNICALL
1306 JVM_InitializeSocketLibrary(void);
1308 struct sockaddr;
1310 JNIEXPORT jint JNICALL
1311 JVM_Socket(jint domain, jint type, jint protocol);
1313 JNIEXPORT jint JNICALL
1314 JVM_SocketClose(jint fd);
1316 JNIEXPORT jint JNICALL
1317 JVM_SocketShutdown(jint fd, jint howto);
1319 JNIEXPORT jint JNICALL
1320 JVM_Recv(jint fd, char *buf, jint nBytes, jint flags);
1322 JNIEXPORT jint JNICALL
1323 JVM_Send(jint fd, char *buf, jint nBytes, jint flags);
1325 JNIEXPORT jint JNICALL
1326 JVM_Timeout(int fd, long timeout);
1328 JNIEXPORT jint JNICALL
1329 JVM_Listen(jint fd, jint count);
1331 JNIEXPORT jint JNICALL
1332 JVM_Connect(jint fd, struct sockaddr *him, jint len);
1334 JNIEXPORT jint JNICALL
1335 JVM_Bind(jint fd, struct sockaddr *him, jint len);
1337 JNIEXPORT jint JNICALL
1338 JVM_Accept(jint fd, struct sockaddr *him, jint *len);
1340 JNIEXPORT jint JNICALL
1341 JVM_RecvFrom(jint fd, char *buf, int nBytes,
1342 int flags, struct sockaddr *from, int *fromlen);
1344 JNIEXPORT jint JNICALL
1345 JVM_SendTo(jint fd, char *buf, int len,
1346 int flags, struct sockaddr *to, int tolen);
1348 JNIEXPORT jint JNICALL
1349 JVM_SocketAvailable(jint fd, jint *result);
1352 JNIEXPORT jint JNICALL
1353 JVM_GetSockName(jint fd, struct sockaddr *him, int *len);
1355 JNIEXPORT jint JNICALL
1356 JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen);
1358 JNIEXPORT jint JNICALL
1359 JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen);
1361 /*
1362 * These routines are only reentrant on Windows
1363 */
1365 #ifdef _WINDOWS
1367 JNIEXPORT struct protoent * JNICALL
1368 JVM_GetProtoByName(char* name);
1370 JNIEXPORT struct hostent* JNICALL
1371 JVM_GetHostByAddr(const char* name, int len, int type);
1373 JNIEXPORT struct hostent* JNICALL
1374 JVM_GetHostByName(char* name);
1376 #endif /* _WINDOWS */
1378 JNIEXPORT int JNICALL
1379 JVM_GetHostName(char* name, int namelen);
1381 /*
1382 * The standard printing functions supported by the Java VM. (Should they
1383 * be renamed to JVM_* in the future?
1384 */
1386 /*
1387 * BE CAREFUL! The following functions do not implement the
1388 * full feature set of standard C printf formats.
1389 */
1390 int
1391 jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
1393 int
1394 jio_snprintf(char *str, size_t count, const char *fmt, ...);
1396 int
1397 jio_fprintf(FILE *, const char *fmt, ...);
1399 int
1400 jio_vfprintf(FILE *, const char *fmt, va_list args);
1403 JNIEXPORT void * JNICALL
1404 JVM_RawMonitorCreate(void);
1406 JNIEXPORT void JNICALL
1407 JVM_RawMonitorDestroy(void *mon);
1409 JNIEXPORT jint JNICALL
1410 JVM_RawMonitorEnter(void *mon);
1412 JNIEXPORT void JNICALL
1413 JVM_RawMonitorExit(void *mon);
1416 #ifdef SUPPORT_OLD_REFLECTION
1418 /*
1419 * Support for old native code-based (pre-JDK 1.4) reflection implementation.
1420 * Disabled by default in the product build.
1421 *
1422 * See reflection.hpp for information on SUPPORT_OLD_REFLECTION
1423 */
1425 /*
1426 * reflecting fields and methods.
1427 * which: 0 --- MEMBER_PUBLIC
1428 * 1 --- MEMBER_DECLARED
1429 * NOTE: absent in product build by default
1430 */
1432 JNIEXPORT jobjectArray JNICALL
1433 JVM_GetClassFields(JNIEnv *env, jclass cls, jint which);
1435 JNIEXPORT jobjectArray JNICALL
1436 JVM_GetClassMethods(JNIEnv *env, jclass cls, jint which);
1438 JNIEXPORT jobjectArray JNICALL
1439 JVM_GetClassConstructors(JNIEnv *env, jclass cls, jint which);
1441 JNIEXPORT jobject JNICALL
1442 JVM_GetClassField(JNIEnv *env, jclass cls, jstring name, jint which);
1444 JNIEXPORT jobject JNICALL
1445 JVM_GetClassMethod(JNIEnv *env, jclass cls, jstring name, jobjectArray types,
1446 jint which);
1447 JNIEXPORT jobject JNICALL
1448 JVM_GetClassConstructor(JNIEnv *env, jclass cls, jobjectArray types,
1449 jint which);
1451 /*
1452 * Implements Class.newInstance
1453 */
1454 JNIEXPORT jobject JNICALL
1455 JVM_NewInstance(JNIEnv *env, jclass cls);
1457 /*
1458 * java.lang.reflect.Field
1459 */
1460 JNIEXPORT jobject JNICALL
1461 JVM_GetField(JNIEnv *env, jobject field, jobject obj);
1463 JNIEXPORT jvalue JNICALL
1464 JVM_GetPrimitiveField(JNIEnv *env, jobject field, jobject obj,
1465 unsigned char wCode);
1467 JNIEXPORT void JNICALL
1468 JVM_SetField(JNIEnv *env, jobject field, jobject obj, jobject val);
1470 JNIEXPORT void JNICALL
1471 JVM_SetPrimitiveField(JNIEnv *env, jobject field, jobject obj, jvalue v,
1472 unsigned char vCode);
1474 /*
1475 * java.lang.reflect.Method
1476 */
1477 JNIEXPORT jobject JNICALL
1478 JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0);
1480 /*
1481 * java.lang.reflect.Constructor
1482 */
1483 JNIEXPORT jobject JNICALL
1484 JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0);
1486 #endif /* SUPPORT_OLD_REFLECTION */
1488 /*
1489 * java.lang.management support
1490 */
1491 JNIEXPORT void* JNICALL
1492 JVM_GetManagement(jint version);
1494 /*
1495 * com.sun.tools.attach.VirtualMachine support
1496 *
1497 * Initialize the agent properties with the properties maintained in the VM.
1498 */
1499 JNIEXPORT jobject JNICALL
1500 JVM_InitAgentProperties(JNIEnv *env, jobject agent_props);
1502 /* Generics reflection support.
1503 *
1504 * Returns information about the given class's EnclosingMethod
1505 * attribute, if present, or null if the class had no enclosing
1506 * method.
1507 *
1508 * If non-null, the returned array contains three elements. Element 0
1509 * is the java.lang.Class of which the enclosing method is a member,
1510 * and elements 1 and 2 are the java.lang.Strings for the enclosing
1511 * method's name and descriptor, respectively.
1512 */
1513 JNIEXPORT jobjectArray JNICALL
1514 JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass);
1516 /*
1517 * Java thread state support
1518 */
1519 enum {
1520 JAVA_THREAD_STATE_NEW = 0,
1521 JAVA_THREAD_STATE_RUNNABLE = 1,
1522 JAVA_THREAD_STATE_BLOCKED = 2,
1523 JAVA_THREAD_STATE_WAITING = 3,
1524 JAVA_THREAD_STATE_TIMED_WAITING = 4,
1525 JAVA_THREAD_STATE_TERMINATED = 5,
1526 JAVA_THREAD_STATE_COUNT = 6
1527 };
1529 /*
1530 * Returns an array of the threadStatus values representing the
1531 * given Java thread state. Returns NULL if the VM version is
1532 * incompatible with the JDK or doesn't support the given
1533 * Java thread state.
1534 */
1535 JNIEXPORT jintArray JNICALL
1536 JVM_GetThreadStateValues(JNIEnv* env, jint javaThreadState);
1538 /*
1539 * Returns an array of the substate names representing the
1540 * given Java thread state. Returns NULL if the VM version is
1541 * incompatible with the JDK or the VM doesn't support
1542 * the given Java thread state.
1543 * values must be the jintArray returned from JVM_GetThreadStateValues
1544 * and javaThreadState.
1545 */
1546 JNIEXPORT jobjectArray JNICALL
1547 JVM_GetThreadStateNames(JNIEnv* env, jint javaThreadState, jintArray values);
1549 /* =========================================================================
1550 * The following defines a private JVM interface that the JDK can query
1551 * for the JVM version and capabilities. sun.misc.Version defines
1552 * the methods for getting the VM version and its capabilities.
1553 *
1554 * When a new bit is added, the following should be updated to provide
1555 * access to the new capability:
1556 * HS: JVM_GetVersionInfo and Abstract_VM_Version class
1557 * SDK: Version class
1558 *
1559 * Similary, a private JDK interface JDK_GetVersionInfo0 is defined for
1560 * JVM to query for the JDK version and capabilities.
1561 *
1562 * When a new bit is added, the following should be updated to provide
1563 * access to the new capability:
1564 * HS: JDK_Version class
1565 * SDK: JDK_GetVersionInfo0
1566 *
1567 * ==========================================================================
1568 */
1569 typedef struct {
1570 /* HotSpot Express VM version string:
1571 * <major>.<minor>-bxx[-<identifier>][-<debug_flavor>]
1572 */
1573 unsigned int jvm_version; /* Consists of major.minor.0.build */
1574 unsigned int update_version : 8; /* 0 in HotSpot Express VM */
1575 unsigned int special_update_version : 8; /* 0 in HotSpot Express VM */
1576 unsigned int reserved1 : 16;
1577 unsigned int reserved2;
1579 /* The following bits represents JVM supports that JDK has dependency on.
1580 * JDK can use these bits to determine which JVM version
1581 * and support it has to maintain runtime compatibility.
1582 *
1583 * When a new bit is added in a minor or update release, make sure
1584 * the new bit is also added in the main/baseline.
1585 */
1586 unsigned int is_attachable : 1;
1587 unsigned int is_kernel_jvm : 1;
1588 unsigned int : 30;
1589 unsigned int : 32;
1590 unsigned int : 32;
1591 } jvm_version_info;
1593 #define JVM_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24)
1594 #define JVM_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16)
1595 // Micro version is 0 in HotSpot Express VM (set in jvm.cpp).
1596 #define JVM_VERSION_MICRO(version) ((version & 0x0000FF00) >> 8)
1597 /* Build number is available in all HotSpot Express VM builds.
1598 * It is defined in make/hotspot_version file.
1599 */
1600 #define JVM_VERSION_BUILD(version) ((version & 0x000000FF))
1602 JNIEXPORT void JNICALL
1603 JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size);
1605 typedef struct {
1606 // Naming convention of RE build version string: n.n.n[_uu[c]][-<identifier>]-bxx
1607 unsigned int jdk_version; /* Consists of major, minor, micro (n.n.n) */
1608 /* and build number (xx) */
1609 unsigned int update_version : 8; /* Update release version (uu) */
1610 unsigned int special_update_version : 8; /* Special update release version (c)*/
1611 unsigned int reserved1 : 16;
1612 unsigned int reserved2;
1614 /* The following bits represents new JDK supports that VM has dependency on.
1615 * VM implementation can use these bits to determine which JDK version
1616 * and support it has to maintain runtime compatibility.
1617 *
1618 * When a new bit is added in a minor or update release, make sure
1619 * the new bit is also added in the main/baseline.
1620 */
1621 unsigned int thread_park_blocker : 1;
1622 unsigned int : 31;
1623 unsigned int : 32;
1624 unsigned int : 32;
1625 } jdk_version_info;
1627 #define JDK_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24)
1628 #define JDK_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16)
1629 #define JDK_VERSION_MICRO(version) ((version & 0x0000FF00) >> 8)
1631 /* Build number is available only for RE build (i.e. JDK_BUILD_NUMBER is set to bNN)
1632 * It will be zero for internal builds.
1633 */
1634 #define JDK_VERSION_BUILD(version) ((version & 0x000000FF))
1636 /*
1637 * This is the function JDK_GetVersionInfo0 defined in libjava.so
1638 * that is dynamically looked up by JVM.
1639 */
1640 typedef void (*jdk_version_info_fn_t)(jdk_version_info* info, size_t info_size);
1642 /*
1643 * This structure is used by the launcher to get the default thread
1644 * stack size from the VM using JNI_GetDefaultJavaVMInitArgs() with a
1645 * version of 1.1. As it is not supported otherwise, it has been removed
1646 * from jni.h
1647 */
1648 typedef struct JDK1_1InitArgs {
1649 jint version;
1651 char **properties;
1652 jint checkSource;
1653 jint nativeStackSize;
1654 jint javaStackSize;
1655 jint minHeapSize;
1656 jint maxHeapSize;
1657 jint verifyMode;
1658 char *classpath;
1660 jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args);
1661 void (JNICALL *exit)(jint code);
1662 void (JNICALL *abort)(void);
1664 jint enableClassGC;
1665 jint enableVerboseGC;
1666 jint disableAsyncGC;
1667 jint verbose;
1668 jboolean debugging;
1669 jint debugPort;
1670 } JDK1_1InitArgs;
1672 #ifdef __cplusplus
1673 } /* extern "C" */
1674 #endif /* __cplusplus */
1676 #endif /* !_JAVASOFT_JVM_H_ */