duke@435: /* kevinw@2449: * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #ifndef SHARE_VM_PRIMS_JVM_H stefank@2314: #define SHARE_VM_PRIMS_JVM_H stefank@2314: stefank@2314: #include "prims/jni.h" stefank@2314: #ifdef TARGET_OS_FAMILY_linux stefank@2314: # include "jvm_linux.h" stefank@2314: #endif stefank@2314: #ifdef TARGET_OS_FAMILY_solaris stefank@2314: # include "jvm_solaris.h" stefank@2314: #endif stefank@2314: #ifdef TARGET_OS_FAMILY_windows stefank@2314: # include "jvm_windows.h" stefank@2314: #endif never@3156: #ifdef TARGET_OS_FAMILY_bsd never@3156: # include "jvm_bsd.h" never@3156: #endif stefank@2314: duke@435: #ifndef _JAVASOFT_JVM_H_ duke@435: #define _JAVASOFT_JVM_H_ duke@435: duke@435: // HotSpot integration note: duke@435: // duke@435: // This file and jvm.h used with the JDK are identical, never@3095: // except for the three includes removed below duke@435: duke@435: // #include duke@435: // #include "jni.h" duke@435: // #include "jvm_md.h" duke@435: duke@435: duke@435: #ifdef __cplusplus duke@435: extern "C" { duke@435: #endif duke@435: duke@435: /* duke@435: * This file contains additional functions exported from the VM. duke@435: * These functions are complementary to the standard JNI support. duke@435: * There are three parts to this file: duke@435: * duke@435: * First, this file contains the VM-related functions needed by native duke@435: * libraries in the standard Java API. For example, the java.lang.Object duke@435: * class needs VM-level functions that wait for and notify monitors. duke@435: * duke@435: * Second, this file contains the functions and constant definitions duke@435: * needed by the byte code verifier and class file format checker. duke@435: * These functions allow the verifier and format checker to be written duke@435: * in a VM-independent way. duke@435: * duke@435: * Third, this file contains various I/O and nerwork operations needed duke@435: * by the standard Java I/O and network APIs. duke@435: */ duke@435: duke@435: /* duke@435: * Bump the version number when either of the following happens: duke@435: * duke@435: * 1. There is a change in JVM_* functions. duke@435: * duke@435: * 2. There is a change in the contract between VM and Java classes. duke@435: * For example, if the VM relies on a new private field in Thread duke@435: * class. duke@435: */ duke@435: duke@435: #define JVM_INTERFACE_VERSION 4 duke@435: duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_GetInterfaceVersion(void); duke@435: duke@435: /************************************************************************* duke@435: PART 1: Functions for Native Libraries duke@435: ************************************************************************/ duke@435: /* duke@435: * java.lang.Object duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_IHashCode(JNIEnv *env, jobject obj); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_MonitorWait(JNIEnv *env, jobject obj, jlong ms); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_MonitorNotify(JNIEnv *env, jobject obj); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_MonitorNotifyAll(JNIEnv *env, jobject obj); duke@435: duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_Clone(JNIEnv *env, jobject obj); duke@435: duke@435: /* duke@435: * java.lang.String duke@435: */ duke@435: JNIEXPORT jstring JNICALL duke@435: JVM_InternString(JNIEnv *env, jstring str); duke@435: duke@435: /* duke@435: * java.lang.System duke@435: */ duke@435: JNIEXPORT jlong JNICALL duke@435: JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored); duke@435: duke@435: JNIEXPORT jlong JNICALL duke@435: JVM_NanoTime(JNIEnv *env, jclass ignored); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos, duke@435: jobject dst, jint dst_pos, jint length); duke@435: duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_InitProperties(JNIEnv *env, jobject p); duke@435: duke@435: /* duke@435: * java.io.File duke@435: */ duke@435: JNIEXPORT void JNICALL duke@435: JVM_OnExit(void (*func)(void)); duke@435: duke@435: /* duke@435: * java.lang.Runtime duke@435: */ duke@435: JNIEXPORT void JNICALL duke@435: JVM_Exit(jint code); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_Halt(jint code); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_GC(void); duke@435: duke@435: /* Returns the number of real-time milliseconds that have elapsed since the duke@435: * least-recently-inspected heap object was last inspected by the garbage duke@435: * collector. duke@435: * duke@435: * For simple stop-the-world collectors this value is just the time duke@435: * since the most recent collection. For generational collectors it is the duke@435: * time since the oldest generation was most recently collected. Other duke@435: * collectors are free to return a pessimistic estimate of the elapsed time, or duke@435: * simply the time since the last full collection was performed. duke@435: * duke@435: * Note that in the presence of reference objects, a given object that is no duke@435: * longer strongly reachable may have to be inspected multiple times before it duke@435: * can be reclaimed. duke@435: */ duke@435: JNIEXPORT jlong JNICALL duke@435: JVM_MaxObjectInspectionAge(void); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_TraceInstructions(jboolean on); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_TraceMethodCalls(jboolean on); duke@435: duke@435: JNIEXPORT jlong JNICALL duke@435: JVM_TotalMemory(void); duke@435: duke@435: JNIEXPORT jlong JNICALL duke@435: JVM_FreeMemory(void); duke@435: duke@435: JNIEXPORT jlong JNICALL duke@435: JVM_MaxMemory(void); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_ActiveProcessorCount(void); duke@435: duke@435: JNIEXPORT void * JNICALL duke@435: JVM_LoadLibrary(const char *name); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_UnloadLibrary(void * handle); duke@435: duke@435: JNIEXPORT void * JNICALL duke@435: JVM_FindLibraryEntry(void *handle, const char *name); duke@435: duke@435: JNIEXPORT jboolean JNICALL duke@435: JVM_IsSupportedJNIVersion(jint version); duke@435: duke@435: /* duke@435: * java.lang.Float and java.lang.Double duke@435: */ duke@435: JNIEXPORT jboolean JNICALL duke@435: JVM_IsNaN(jdouble d); duke@435: duke@435: /* duke@435: * java.lang.Throwable duke@435: */ duke@435: JNIEXPORT void JNICALL duke@435: JVM_FillInStackTrace(JNIEnv *env, jobject throwable); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_PrintStackTrace(JNIEnv *env, jobject throwable, jobject printable); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable); duke@435: duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index); duke@435: duke@435: /* duke@435: * java.lang.Compiler duke@435: */ duke@435: JNIEXPORT void JNICALL duke@435: JVM_InitializeCompiler (JNIEnv *env, jclass compCls); duke@435: duke@435: JNIEXPORT jboolean JNICALL duke@435: JVM_IsSilentCompiler(JNIEnv *env, jclass compCls); duke@435: duke@435: JNIEXPORT jboolean JNICALL duke@435: JVM_CompileClass(JNIEnv *env, jclass compCls, jclass cls); duke@435: duke@435: JNIEXPORT jboolean JNICALL duke@435: JVM_CompileClasses(JNIEnv *env, jclass cls, jstring jname); duke@435: duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_CompilerCommand(JNIEnv *env, jclass compCls, jobject arg); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_EnableCompiler(JNIEnv *env, jclass compCls); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_DisableCompiler(JNIEnv *env, jclass compCls); duke@435: duke@435: /* duke@435: * java.lang.Thread duke@435: */ duke@435: JNIEXPORT void JNICALL duke@435: JVM_StartThread(JNIEnv *env, jobject thread); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_StopThread(JNIEnv *env, jobject thread, jobject exception); duke@435: duke@435: JNIEXPORT jboolean JNICALL duke@435: JVM_IsThreadAlive(JNIEnv *env, jobject thread); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_SuspendThread(JNIEnv *env, jobject thread); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_ResumeThread(JNIEnv *env, jobject thread); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_SetThreadPriority(JNIEnv *env, jobject thread, jint prio); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_Yield(JNIEnv *env, jclass threadClass); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_Sleep(JNIEnv *env, jclass threadClass, jlong millis); duke@435: duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_CurrentThread(JNIEnv *env, jclass threadClass); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_CountStackFrames(JNIEnv *env, jobject thread); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_Interrupt(JNIEnv *env, jobject thread); duke@435: duke@435: JNIEXPORT jboolean JNICALL duke@435: JVM_IsInterrupted(JNIEnv *env, jobject thread, jboolean clearInterrupted); duke@435: duke@435: JNIEXPORT jboolean JNICALL duke@435: JVM_HoldsLock(JNIEnv *env, jclass threadClass, jobject obj); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_DumpAllStacks(JNIEnv *env, jclass unused); duke@435: duke@435: JNIEXPORT jobjectArray JNICALL duke@435: JVM_GetAllThreads(JNIEnv *env, jclass dummy); duke@435: dcubed@3202: JNIEXPORT void JNICALL dcubed@3202: JVM_SetNativeThreadName(JNIEnv *env, jobject jthread, jstring name); dcubed@3202: duke@435: /* getStackTrace() and getAllStackTraces() method */ duke@435: JNIEXPORT jobjectArray JNICALL duke@435: JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads); duke@435: duke@435: /* duke@435: * java.lang.SecurityManager duke@435: */ duke@435: JNIEXPORT jclass JNICALL duke@435: JVM_CurrentLoadedClass(JNIEnv *env); duke@435: duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_CurrentClassLoader(JNIEnv *env); duke@435: duke@435: JNIEXPORT jobjectArray JNICALL duke@435: JVM_GetClassContext(JNIEnv *env); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_ClassDepth(JNIEnv *env, jstring name); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_ClassLoaderDepth(JNIEnv *env); duke@435: duke@435: /* duke@435: * java.lang.Package duke@435: */ duke@435: JNIEXPORT jstring JNICALL duke@435: JVM_GetSystemPackage(JNIEnv *env, jstring name); duke@435: duke@435: JNIEXPORT jobjectArray JNICALL duke@435: JVM_GetSystemPackages(JNIEnv *env); duke@435: duke@435: /* duke@435: * java.io.ObjectInputStream duke@435: */ duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_AllocateNewObject(JNIEnv *env, jobject obj, jclass currClass, duke@435: jclass initClass); duke@435: duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_AllocateNewArray(JNIEnv *env, jobject obj, jclass currClass, duke@435: jint length); duke@435: duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_LatestUserDefinedLoader(JNIEnv *env); duke@435: duke@435: /* duke@435: * This function has been deprecated and should not be considered duke@435: * part of the specified JVM interface. duke@435: */ duke@435: JNIEXPORT jclass JNICALL duke@435: JVM_LoadClass0(JNIEnv *env, jobject obj, jclass currClass, duke@435: jstring currClassName); duke@435: duke@435: /* duke@435: * java.lang.reflect.Array duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_GetArrayLength(JNIEnv *env, jobject arr); duke@435: duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index); duke@435: duke@435: JNIEXPORT jvalue JNICALL duke@435: JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v, duke@435: unsigned char vCode); duke@435: duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_NewArray(JNIEnv *env, jclass eltClass, jint length); duke@435: duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim); duke@435: duke@435: /* duke@435: * java.lang.Class and java.lang.ClassLoader duke@435: */ duke@435: /* duke@435: * Returns the class in which the code invoking the native method duke@435: * belongs. duke@435: * duke@435: * Note that in JDK 1.1, native methods did not create a frame. duke@435: * In 1.2, they do. Therefore native methods like Class.forName duke@435: * can no longer look at the current frame for the caller class. duke@435: */ duke@435: JNIEXPORT jclass JNICALL duke@435: JVM_GetCallerClass(JNIEnv *env, int n); duke@435: duke@435: /* duke@435: * Find primitive classes duke@435: * utf: class name duke@435: */ duke@435: JNIEXPORT jclass JNICALL duke@435: JVM_FindPrimitiveClass(JNIEnv *env, const char *utf); duke@435: duke@435: /* duke@435: * Link the class duke@435: */ duke@435: JNIEXPORT void JNICALL duke@435: JVM_ResolveClass(JNIEnv *env, jclass cls); duke@435: duke@435: /* duke@435: * Find a class from a given class loader. Throw ClassNotFoundException duke@435: * or NoClassDefFoundError depending on the value of the last duke@435: * argument. duke@435: */ duke@435: JNIEXPORT jclass JNICALL duke@435: JVM_FindClassFromClassLoader(JNIEnv *env, const char *name, jboolean init, duke@435: jobject loader, jboolean throwError); duke@435: duke@435: /* mchung@1313: * Find a class from a boot class loader. Returns NULL if class not found. ksrini@661: */ ksrini@661: JNIEXPORT jclass JNICALL mchung@1313: JVM_FindClassFromBootLoader(JNIEnv *env, const char *name); ksrini@661: ksrini@661: /* duke@435: * Find a class from a given class. duke@435: */ duke@435: JNIEXPORT jclass JNICALL duke@435: JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init, duke@435: jclass from); duke@435: duke@435: /* Find a loaded class cached by the VM */ duke@435: JNIEXPORT jclass JNICALL duke@435: JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name); duke@435: duke@435: /* Define a class */ duke@435: JNIEXPORT jclass JNICALL duke@435: JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, duke@435: jsize len, jobject pd); duke@435: duke@435: /* Define a class with a source (added in JDK1.5) */ duke@435: JNIEXPORT jclass JNICALL duke@435: JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, duke@435: const jbyte *buf, jsize len, jobject pd, duke@435: const char *source); duke@435: acorn@1408: /* Define a class with a source with conditional verification (added HSX 14) acorn@1408: * -Xverify:all will verify anyway, -Xverify:none will not verify, acorn@1408: * -Xverify:remote (default) will obey this conditional acorn@1408: * i.e. true = should_verify_class acorn@1408: */ acorn@1408: JNIEXPORT jclass JNICALL acorn@1408: JVM_DefineClassWithSourceCond(JNIEnv *env, const char *name, acorn@1408: jobject loader, const jbyte *buf, acorn@1408: jsize len, jobject pd, const char *source, acorn@1408: jboolean verify); acorn@1408: duke@435: /* duke@435: * Reflection support functions duke@435: */ duke@435: duke@435: JNIEXPORT jstring JNICALL duke@435: JVM_GetClassName(JNIEnv *env, jclass cls); duke@435: duke@435: JNIEXPORT jobjectArray JNICALL duke@435: JVM_GetClassInterfaces(JNIEnv *env, jclass cls); duke@435: duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_GetClassLoader(JNIEnv *env, jclass cls); duke@435: duke@435: JNIEXPORT jboolean JNICALL duke@435: JVM_IsInterface(JNIEnv *env, jclass cls); duke@435: duke@435: JNIEXPORT jobjectArray JNICALL duke@435: JVM_GetClassSigners(JNIEnv *env, jclass cls); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers); duke@435: duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_GetProtectionDomain(JNIEnv *env, jclass cls); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_SetProtectionDomain(JNIEnv *env, jclass cls, jobject protection_domain); duke@435: duke@435: JNIEXPORT jboolean JNICALL duke@435: JVM_IsArrayClass(JNIEnv *env, jclass cls); duke@435: duke@435: JNIEXPORT jboolean JNICALL duke@435: JVM_IsPrimitiveClass(JNIEnv *env, jclass cls); duke@435: duke@435: JNIEXPORT jclass JNICALL duke@435: JVM_GetComponentType(JNIEnv *env, jclass cls); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_GetClassModifiers(JNIEnv *env, jclass cls); duke@435: duke@435: JNIEXPORT jobjectArray JNICALL duke@435: JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass); duke@435: duke@435: JNIEXPORT jclass JNICALL duke@435: JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass); duke@435: duke@435: /* Generics support (JDK 1.5) */ duke@435: JNIEXPORT jstring JNICALL duke@435: JVM_GetClassSignature(JNIEnv *env, jclass cls); duke@435: duke@435: /* Annotations support (JDK 1.5) */ duke@435: JNIEXPORT jbyteArray JNICALL duke@435: JVM_GetClassAnnotations(JNIEnv *env, jclass cls); duke@435: duke@435: /* Annotations support (JDK 1.6) */ duke@435: duke@435: // field is a handle to a java.lang.reflect.Field object duke@435: JNIEXPORT jbyteArray JNICALL duke@435: JVM_GetFieldAnnotations(JNIEnv *env, jobject field); duke@435: duke@435: // method is a handle to a java.lang.reflect.Method object duke@435: JNIEXPORT jbyteArray JNICALL duke@435: JVM_GetMethodAnnotations(JNIEnv *env, jobject method); duke@435: duke@435: // method is a handle to a java.lang.reflect.Method object duke@435: JNIEXPORT jbyteArray JNICALL duke@435: JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method); duke@435: duke@435: // method is a handle to a java.lang.reflect.Method object duke@435: JNIEXPORT jbyteArray JNICALL duke@435: JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method); duke@435: duke@435: duke@435: /* duke@435: * New (JDK 1.4) reflection implementation duke@435: */ duke@435: duke@435: JNIEXPORT jobjectArray JNICALL duke@435: JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly); duke@435: duke@435: JNIEXPORT jobjectArray JNICALL duke@435: JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly); duke@435: duke@435: JNIEXPORT jobjectArray JNICALL duke@435: JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly); duke@435: duke@435: /* Differs from JVM_GetClassModifiers in treatment of inner classes. duke@435: This returns the access flags for the class as specified in the duke@435: class file rather than searching the InnerClasses attribute (if duke@435: present) to find the source-level access flags. Only the values of duke@435: the low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be duke@435: valid. */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_GetClassAccessFlags(JNIEnv *env, jclass cls); duke@435: duke@435: /* duke@435: * Constant pool access; currently used to implement reflective access to annotations (JDK 1.5) duke@435: */ duke@435: duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_GetClassConstantPool(JNIEnv *env, jclass cls); duke@435: duke@435: JNIEXPORT jint JNICALL JVM_ConstantPoolGetSize duke@435: (JNIEnv *env, jobject unused, jobject jcpool); duke@435: duke@435: JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAt duke@435: (JNIEnv *env, jobject unused, jobject jcpool, jint index); duke@435: duke@435: JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAtIfLoaded duke@435: (JNIEnv *env, jobject unused, jobject jcpool, jint index); duke@435: duke@435: JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAt duke@435: (JNIEnv *env, jobject unused, jobject jcpool, jint index); duke@435: duke@435: JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAtIfLoaded duke@435: (JNIEnv *env, jobject unused, jobject jcpool, jint index); duke@435: duke@435: JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAt duke@435: (JNIEnv *env, jobject unused, jobject jcpool, jint index); duke@435: duke@435: JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAtIfLoaded duke@435: (JNIEnv *env, jobject unused, jobject jcpool, jint index); duke@435: duke@435: JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetMemberRefInfoAt duke@435: (JNIEnv *env, jobject unused, jobject jcpool, jint index); duke@435: duke@435: JNIEXPORT jint JNICALL JVM_ConstantPoolGetIntAt duke@435: (JNIEnv *env, jobject unused, jobject jcpool, jint index); duke@435: duke@435: JNIEXPORT jlong JNICALL JVM_ConstantPoolGetLongAt duke@435: (JNIEnv *env, jobject unused, jobject jcpool, jint index); duke@435: duke@435: JNIEXPORT jfloat JNICALL JVM_ConstantPoolGetFloatAt duke@435: (JNIEnv *env, jobject unused, jobject jcpool, jint index); duke@435: duke@435: JNIEXPORT jdouble JNICALL JVM_ConstantPoolGetDoubleAt duke@435: (JNIEnv *env, jobject unused, jobject jcpool, jint index); duke@435: duke@435: JNIEXPORT jstring JNICALL JVM_ConstantPoolGetStringAt duke@435: (JNIEnv *env, jobject unused, jobject jcpool, jint index); duke@435: duke@435: JNIEXPORT jstring JNICALL JVM_ConstantPoolGetUTF8At duke@435: (JNIEnv *env, jobject unused, jobject jcpool, jint index); duke@435: duke@435: /* duke@435: * java.security.* duke@435: */ duke@435: duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_DoPrivileged(JNIEnv *env, jclass cls, duke@435: jobject action, jobject context, jboolean wrapException); duke@435: duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls); duke@435: duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls); duke@435: duke@435: /* duke@435: * Signal support, used to implement the shutdown sequence. Every VM must duke@435: * support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts duke@435: * (^C) and the latter for external termination (kill, system shutdown, etc.). duke@435: * Other platform-dependent signal values may also be supported. duke@435: */ duke@435: duke@435: JNIEXPORT void * JNICALL duke@435: JVM_RegisterSignal(jint sig, void *handler); duke@435: duke@435: JNIEXPORT jboolean JNICALL duke@435: JVM_RaiseSignal(jint sig); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_FindSignal(const char *name); duke@435: duke@435: /* duke@435: * Retrieve the assertion directives for the specified class. duke@435: */ duke@435: JNIEXPORT jboolean JNICALL duke@435: JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls); duke@435: duke@435: /* duke@435: * Retrieve the assertion directives from the VM. duke@435: */ duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused); duke@435: duke@435: /* duke@435: * sun.misc.AtomicLong duke@435: */ duke@435: JNIEXPORT jboolean JNICALL duke@435: JVM_SupportsCX8(void); duke@435: duke@435: JNIEXPORT jboolean JNICALL duke@435: JVM_CX8Field(JNIEnv *env, jobject obj, jfieldID fldID, jlong oldVal, jlong newVal); duke@435: kamg@551: /* kamg@551: * com.sun.dtrace.jsdt support kamg@551: */ kamg@551: kamg@551: #define JVM_TRACING_DTRACE_VERSION 1 kamg@551: kamg@551: /* kamg@551: * Structure to pass one probe description to JVM. kamg@551: * kamg@551: * The VM will overwrite the definition of the referenced method with kamg@551: * code that will fire the probe. kamg@551: */ kamg@551: typedef struct { kamg@551: jmethodID method; kamg@551: jstring function; kamg@551: jstring name; kamg@551: void* reserved[4]; // for future use kamg@551: } JVM_DTraceProbe; kamg@551: kamg@551: /** kamg@551: * Encapsulates the stability ratings for a DTrace provider field kamg@551: */ kamg@551: typedef struct { kamg@551: jint nameStability; kamg@551: jint dataStability; kamg@551: jint dependencyClass; kamg@551: } JVM_DTraceInterfaceAttributes; kamg@551: kamg@551: /* kamg@551: * Structure to pass one provider description to JVM kamg@551: */ kamg@551: typedef struct { kamg@551: jstring name; kamg@551: JVM_DTraceProbe* probes; kamg@551: jint probe_count; kamg@551: JVM_DTraceInterfaceAttributes providerAttributes; kamg@551: JVM_DTraceInterfaceAttributes moduleAttributes; kamg@551: JVM_DTraceInterfaceAttributes functionAttributes; kamg@551: JVM_DTraceInterfaceAttributes nameAttributes; kamg@551: JVM_DTraceInterfaceAttributes argsAttributes; kamg@551: void* reserved[4]; // for future use kamg@551: } JVM_DTraceProvider; kamg@551: kamg@551: /* kamg@551: * Get the version number the JVM was built with kamg@551: */ kamg@551: JNIEXPORT jint JNICALL kamg@551: JVM_DTraceGetVersion(JNIEnv* env); kamg@551: kamg@551: /* kamg@551: * Register new probe with given signature, return global handle kamg@551: * kamg@551: * The version passed in is the version that the library code was kamg@551: * built with. kamg@551: */ kamg@551: JNIEXPORT jlong JNICALL kamg@551: JVM_DTraceActivate(JNIEnv* env, jint version, jstring module_name, kamg@551: jint providers_count, JVM_DTraceProvider* providers); kamg@551: kamg@551: /* kamg@551: * Check JSDT probe kamg@551: */ kamg@551: JNIEXPORT jboolean JNICALL kamg@551: JVM_DTraceIsProbeEnabled(JNIEnv* env, jmethodID method); kamg@551: kamg@551: /* kamg@551: * Destroy custom DOF kamg@551: */ kamg@551: JNIEXPORT void JNICALL kamg@551: JVM_DTraceDispose(JNIEnv* env, jlong handle); kamg@551: kamg@551: /* kamg@551: * Check to see if DTrace is supported by OS kamg@551: */ kamg@551: JNIEXPORT jboolean JNICALL kamg@551: JVM_DTraceIsSupported(JNIEnv* env); kamg@551: duke@435: /************************************************************************* duke@435: PART 2: Support for the Verifier and Class File Format Checker duke@435: ************************************************************************/ duke@435: /* duke@435: * Return the class name in UTF format. The result is valid duke@435: * until JVM_ReleaseUTf is called. duke@435: * duke@435: * The caller must treat the string as a constant and not modify it duke@435: * in any way. duke@435: */ duke@435: JNIEXPORT const char * JNICALL duke@435: JVM_GetClassNameUTF(JNIEnv *env, jclass cb); duke@435: duke@435: /* duke@435: * Returns the constant pool types in the buffer provided by "types." duke@435: */ duke@435: JNIEXPORT void JNICALL duke@435: JVM_GetClassCPTypes(JNIEnv *env, jclass cb, unsigned char *types); duke@435: duke@435: /* duke@435: * Returns the number of Constant Pool entries. duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cb); duke@435: duke@435: /* duke@435: * Returns the number of *declared* fields or methods. duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_GetClassFieldsCount(JNIEnv *env, jclass cb); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_GetClassMethodsCount(JNIEnv *env, jclass cb); duke@435: duke@435: /* duke@435: * Returns the CP indexes of exceptions raised by a given method. duke@435: * Places the result in the given buffer. duke@435: * duke@435: * The method is identified by method_index. duke@435: */ duke@435: JNIEXPORT void JNICALL duke@435: JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cb, jint method_index, duke@435: unsigned short *exceptions); duke@435: /* duke@435: * Returns the number of exceptions raised by a given method. duke@435: * The method is identified by method_index. duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cb, jint method_index); duke@435: duke@435: /* duke@435: * Returns the byte code sequence of a given method. duke@435: * Places the result in the given buffer. duke@435: * duke@435: * The method is identified by method_index. duke@435: */ duke@435: JNIEXPORT void JNICALL duke@435: JVM_GetMethodIxByteCode(JNIEnv *env, jclass cb, jint method_index, duke@435: unsigned char *code); duke@435: duke@435: /* duke@435: * Returns the length of the byte code sequence of a given method. duke@435: * The method is identified by method_index. duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cb, jint method_index); duke@435: duke@435: /* duke@435: * A structure used to a capture exception table entry in a Java method. duke@435: */ duke@435: typedef struct { duke@435: jint start_pc; duke@435: jint end_pc; duke@435: jint handler_pc; duke@435: jint catchType; duke@435: } JVM_ExceptionTableEntryType; duke@435: duke@435: /* duke@435: * Returns the exception table entry at entry_index of a given method. duke@435: * Places the result in the given buffer. duke@435: * duke@435: * The method is identified by method_index. duke@435: */ duke@435: JNIEXPORT void JNICALL duke@435: JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cb, jint method_index, duke@435: jint entry_index, duke@435: JVM_ExceptionTableEntryType *entry); duke@435: duke@435: /* duke@435: * Returns the length of the exception table of a given method. duke@435: * The method is identified by method_index. duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cb, int index); duke@435: duke@435: /* duke@435: * Returns the modifiers of a given field. duke@435: * The field is identified by field_index. duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_GetFieldIxModifiers(JNIEnv *env, jclass cb, int index); duke@435: duke@435: /* duke@435: * Returns the modifiers of a given method. duke@435: * The method is identified by method_index. duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_GetMethodIxModifiers(JNIEnv *env, jclass cb, int index); duke@435: duke@435: /* duke@435: * Returns the number of local variables of a given method. duke@435: * The method is identified by method_index. duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cb, int index); duke@435: duke@435: /* duke@435: * Returns the number of arguments (including this pointer) of a given method. duke@435: * The method is identified by method_index. duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cb, int index); duke@435: duke@435: /* duke@435: * Returns the maximum amount of stack (in words) used by a given method. duke@435: * The method is identified by method_index. duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cb, int index); duke@435: duke@435: /* duke@435: * Is a given method a constructor. duke@435: * The method is identified by method_index. duke@435: */ duke@435: JNIEXPORT jboolean JNICALL duke@435: JVM_IsConstructorIx(JNIEnv *env, jclass cb, int index); duke@435: duke@435: /* duke@435: * Returns the name of a given method in UTF format. duke@435: * The result remains valid until JVM_ReleaseUTF is called. duke@435: * duke@435: * The caller must treat the string as a constant and not modify it duke@435: * in any way. duke@435: */ duke@435: JNIEXPORT const char * JNICALL duke@435: JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cb, jint index); duke@435: duke@435: /* duke@435: * Returns the signature of a given method in UTF format. duke@435: * The result remains valid until JVM_ReleaseUTF is called. duke@435: * duke@435: * The caller must treat the string as a constant and not modify it duke@435: * in any way. duke@435: */ duke@435: JNIEXPORT const char * JNICALL duke@435: JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cb, jint index); duke@435: duke@435: /* duke@435: * Returns the name of the field refered to at a given constant pool duke@435: * index. duke@435: * duke@435: * The result is in UTF format and remains valid until JVM_ReleaseUTF duke@435: * is called. duke@435: * duke@435: * The caller must treat the string as a constant and not modify it duke@435: * in any way. duke@435: */ duke@435: JNIEXPORT const char * JNICALL duke@435: JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cb, jint index); duke@435: duke@435: /* duke@435: * Returns the name of the method refered to at a given constant pool duke@435: * index. duke@435: * duke@435: * The result is in UTF format and remains valid until JVM_ReleaseUTF duke@435: * is called. duke@435: * duke@435: * The caller must treat the string as a constant and not modify it duke@435: * in any way. duke@435: */ duke@435: JNIEXPORT const char * JNICALL duke@435: JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cb, jint index); duke@435: duke@435: /* duke@435: * Returns the signature of the method refered to at a given constant pool duke@435: * index. duke@435: * duke@435: * The result is in UTF format and remains valid until JVM_ReleaseUTF duke@435: * is called. duke@435: * duke@435: * The caller must treat the string as a constant and not modify it duke@435: * in any way. duke@435: */ duke@435: JNIEXPORT const char * JNICALL duke@435: JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cb, jint index); duke@435: duke@435: /* duke@435: * Returns the signature of the field refered to at a given constant pool duke@435: * index. duke@435: * duke@435: * The result is in UTF format and remains valid until JVM_ReleaseUTF duke@435: * is called. duke@435: * duke@435: * The caller must treat the string as a constant and not modify it duke@435: * in any way. duke@435: */ duke@435: JNIEXPORT const char * JNICALL duke@435: JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cb, jint index); duke@435: duke@435: /* duke@435: * Returns the class name refered to at a given constant pool index. duke@435: * duke@435: * The result is in UTF format and remains valid until JVM_ReleaseUTF duke@435: * is called. duke@435: * duke@435: * The caller must treat the string as a constant and not modify it duke@435: * in any way. duke@435: */ duke@435: JNIEXPORT const char * JNICALL duke@435: JVM_GetCPClassNameUTF(JNIEnv *env, jclass cb, jint index); duke@435: duke@435: /* duke@435: * Returns the class name refered to at a given constant pool index. duke@435: * duke@435: * The constant pool entry must refer to a CONSTANT_Fieldref. duke@435: * duke@435: * The result is in UTF format and remains valid until JVM_ReleaseUTF duke@435: * is called. duke@435: * duke@435: * The caller must treat the string as a constant and not modify it duke@435: * in any way. duke@435: */ duke@435: JNIEXPORT const char * JNICALL duke@435: JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cb, jint index); duke@435: duke@435: /* duke@435: * Returns the class name refered to at a given constant pool index. duke@435: * duke@435: * The constant pool entry must refer to CONSTANT_Methodref or duke@435: * CONSTANT_InterfaceMethodref. duke@435: * duke@435: * The result is in UTF format and remains valid until JVM_ReleaseUTF duke@435: * is called. duke@435: * duke@435: * The caller must treat the string as a constant and not modify it duke@435: * in any way. duke@435: */ duke@435: JNIEXPORT const char * JNICALL duke@435: JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cb, jint index); duke@435: duke@435: /* duke@435: * Returns the modifiers of a field in calledClass. The field is duke@435: * referred to in class cb at constant pool entry index. duke@435: * duke@435: * The caller must treat the string as a constant and not modify it duke@435: * in any way. duke@435: * duke@435: * Returns -1 if the field does not exist in calledClass. duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_GetCPFieldModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass); duke@435: duke@435: /* duke@435: * Returns the modifiers of a method in calledClass. The method is duke@435: * referred to in class cb at constant pool entry index. duke@435: * duke@435: * Returns -1 if the method does not exist in calledClass. duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_GetCPMethodModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass); duke@435: duke@435: /* duke@435: * Releases the UTF string obtained from the VM. duke@435: */ duke@435: JNIEXPORT void JNICALL duke@435: JVM_ReleaseUTF(const char *utf); duke@435: duke@435: /* duke@435: * Compare if two classes are in the same package. duke@435: */ duke@435: JNIEXPORT jboolean JNICALL duke@435: JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2); duke@435: duke@435: /* Constants in class files */ duke@435: duke@435: #define JVM_ACC_PUBLIC 0x0001 /* visible to everyone */ duke@435: #define JVM_ACC_PRIVATE 0x0002 /* visible only to the defining class */ duke@435: #define JVM_ACC_PROTECTED 0x0004 /* visible to subclasses */ duke@435: #define JVM_ACC_STATIC 0x0008 /* instance variable is static */ duke@435: #define JVM_ACC_FINAL 0x0010 /* no further subclassing, overriding */ duke@435: #define JVM_ACC_SYNCHRONIZED 0x0020 /* wrap method call in monitor lock */ duke@435: #define JVM_ACC_SUPER 0x0020 /* funky handling of invokespecial */ duke@435: #define JVM_ACC_VOLATILE 0x0040 /* can not cache in registers */ duke@435: #define JVM_ACC_BRIDGE 0x0040 /* bridge method generated by compiler */ duke@435: #define JVM_ACC_TRANSIENT 0x0080 /* not persistent */ duke@435: #define JVM_ACC_VARARGS 0x0080 /* method declared with variable number of args */ duke@435: #define JVM_ACC_NATIVE 0x0100 /* implemented in C */ duke@435: #define JVM_ACC_INTERFACE 0x0200 /* class is an interface */ duke@435: #define JVM_ACC_ABSTRACT 0x0400 /* no definition provided */ duke@435: #define JVM_ACC_STRICT 0x0800 /* strict floating point */ duke@435: #define JVM_ACC_SYNTHETIC 0x1000 /* compiler-generated class, method or field */ duke@435: #define JVM_ACC_ANNOTATION 0x2000 /* annotation type */ duke@435: #define JVM_ACC_ENUM 0x4000 /* field is declared as element of enum */ duke@435: duke@435: #define JVM_ACC_PUBLIC_BIT 0 duke@435: #define JVM_ACC_PRIVATE_BIT 1 duke@435: #define JVM_ACC_PROTECTED_BIT 2 duke@435: #define JVM_ACC_STATIC_BIT 3 duke@435: #define JVM_ACC_FINAL_BIT 4 duke@435: #define JVM_ACC_SYNCHRONIZED_BIT 5 duke@435: #define JVM_ACC_SUPER_BIT 5 duke@435: #define JVM_ACC_VOLATILE_BIT 6 duke@435: #define JVM_ACC_BRIDGE_BIT 6 duke@435: #define JVM_ACC_TRANSIENT_BIT 7 duke@435: #define JVM_ACC_VARARGS_BIT 7 duke@435: #define JVM_ACC_NATIVE_BIT 8 duke@435: #define JVM_ACC_INTERFACE_BIT 9 duke@435: #define JVM_ACC_ABSTRACT_BIT 10 duke@435: #define JVM_ACC_STRICT_BIT 11 duke@435: #define JVM_ACC_SYNTHETIC_BIT 12 duke@435: #define JVM_ACC_ANNOTATION_BIT 13 duke@435: #define JVM_ACC_ENUM_BIT 14 duke@435: duke@435: // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/utilities/ConstantTag.java duke@435: enum { duke@435: JVM_CONSTANT_Utf8 = 1, duke@435: JVM_CONSTANT_Unicode, /* unused */ duke@435: JVM_CONSTANT_Integer, duke@435: JVM_CONSTANT_Float, duke@435: JVM_CONSTANT_Long, duke@435: JVM_CONSTANT_Double, duke@435: JVM_CONSTANT_Class, duke@435: JVM_CONSTANT_String, duke@435: JVM_CONSTANT_Fieldref, duke@435: JVM_CONSTANT_Methodref, duke@435: JVM_CONSTANT_InterfaceMethodref, jrose@1957: JVM_CONSTANT_NameAndType, jrose@1957: JVM_CONSTANT_MethodHandle = 15, // JSR 292 jrose@2015: JVM_CONSTANT_MethodType = 16, // JSR 292 jrose@2742: //JVM_CONSTANT_(unused) = 17, // JSR 292 early drafts only jrose@2353: JVM_CONSTANT_InvokeDynamic = 18, // JSR 292 jrose@2353: JVM_CONSTANT_ExternalMax = 18 // Last tag found in classfiles jrose@1957: }; jrose@1957: jrose@1957: /* JVM_CONSTANT_MethodHandle subtypes */ jrose@1957: enum { jrose@1957: JVM_REF_getField = 1, jrose@1957: JVM_REF_getStatic = 2, jrose@1957: JVM_REF_putField = 3, jrose@1957: JVM_REF_putStatic = 4, jrose@1957: JVM_REF_invokeVirtual = 5, jrose@1957: JVM_REF_invokeStatic = 6, jrose@1957: JVM_REF_invokeSpecial = 7, jrose@1957: JVM_REF_newInvokeSpecial = 8, jrose@1957: JVM_REF_invokeInterface = 9 duke@435: }; duke@435: duke@435: /* Used in the newarray instruction. */ duke@435: duke@435: #define JVM_T_BOOLEAN 4 duke@435: #define JVM_T_CHAR 5 duke@435: #define JVM_T_FLOAT 6 duke@435: #define JVM_T_DOUBLE 7 duke@435: #define JVM_T_BYTE 8 duke@435: #define JVM_T_SHORT 9 duke@435: #define JVM_T_INT 10 duke@435: #define JVM_T_LONG 11 duke@435: duke@435: /* JVM method signatures */ duke@435: duke@435: #define JVM_SIGNATURE_ARRAY '[' duke@435: #define JVM_SIGNATURE_BYTE 'B' duke@435: #define JVM_SIGNATURE_CHAR 'C' duke@435: #define JVM_SIGNATURE_CLASS 'L' duke@435: #define JVM_SIGNATURE_ENDCLASS ';' duke@435: #define JVM_SIGNATURE_ENUM 'E' duke@435: #define JVM_SIGNATURE_FLOAT 'F' duke@435: #define JVM_SIGNATURE_DOUBLE 'D' duke@435: #define JVM_SIGNATURE_FUNC '(' duke@435: #define JVM_SIGNATURE_ENDFUNC ')' duke@435: #define JVM_SIGNATURE_INT 'I' duke@435: #define JVM_SIGNATURE_LONG 'J' duke@435: #define JVM_SIGNATURE_SHORT 'S' duke@435: #define JVM_SIGNATURE_VOID 'V' duke@435: #define JVM_SIGNATURE_BOOLEAN 'Z' duke@435: duke@435: /* duke@435: * A function defined by the byte-code verifier and called by the VM. duke@435: * This is not a function implemented in the VM. duke@435: * duke@435: * Returns JNI_FALSE if verification fails. A detailed error message duke@435: * will be places in msg_buf, whose length is specified by buf_len. duke@435: */ duke@435: typedef jboolean (*verifier_fn_t)(JNIEnv *env, duke@435: jclass cb, duke@435: char * msg_buf, duke@435: jint buf_len); duke@435: duke@435: duke@435: /* duke@435: * Support for a VM-independent class format checker. duke@435: */ duke@435: typedef struct { duke@435: unsigned long code; /* byte code */ duke@435: unsigned long excs; /* exceptions */ duke@435: unsigned long etab; /* catch table */ duke@435: unsigned long lnum; /* line number */ duke@435: unsigned long lvar; /* local vars */ duke@435: } method_size_info; duke@435: duke@435: typedef struct { duke@435: unsigned int constants; /* constant pool */ duke@435: unsigned int fields; duke@435: unsigned int methods; duke@435: unsigned int interfaces; duke@435: unsigned int fields2; /* number of static 2-word fields */ duke@435: unsigned int innerclasses; /* # of records in InnerClasses attr */ duke@435: duke@435: method_size_info clinit; /* memory used in clinit */ duke@435: method_size_info main; /* used everywhere else */ duke@435: } class_size_info; duke@435: duke@435: /* duke@435: * Functions defined in libjava.so to perform string conversions. duke@435: * duke@435: */ duke@435: duke@435: typedef jstring (*to_java_string_fn_t)(JNIEnv *env, char *str); duke@435: duke@435: typedef char *(*to_c_string_fn_t)(JNIEnv *env, jstring s, jboolean *b); duke@435: duke@435: /* This is the function defined in libjava.so that performs class duke@435: * format checks. This functions fills in size information about duke@435: * the class file and returns: duke@435: * duke@435: * 0: good duke@435: * -1: out of memory duke@435: * -2: bad format duke@435: * -3: unsupported version duke@435: * -4: bad class name duke@435: */ duke@435: duke@435: typedef jint (*check_format_fn_t)(char *class_name, duke@435: unsigned char *data, duke@435: unsigned int data_size, duke@435: class_size_info *class_size, duke@435: char *message_buffer, duke@435: jint buffer_length, duke@435: jboolean measure_only, duke@435: jboolean check_relaxed); duke@435: duke@435: #define JVM_RECOGNIZED_CLASS_MODIFIERS (JVM_ACC_PUBLIC | \ duke@435: JVM_ACC_FINAL | \ duke@435: JVM_ACC_SUPER | \ duke@435: JVM_ACC_INTERFACE | \ duke@435: JVM_ACC_ABSTRACT | \ duke@435: JVM_ACC_ANNOTATION | \ duke@435: JVM_ACC_ENUM | \ duke@435: JVM_ACC_SYNTHETIC) duke@435: duke@435: #define JVM_RECOGNIZED_FIELD_MODIFIERS (JVM_ACC_PUBLIC | \ duke@435: JVM_ACC_PRIVATE | \ duke@435: JVM_ACC_PROTECTED | \ duke@435: JVM_ACC_STATIC | \ duke@435: JVM_ACC_FINAL | \ duke@435: JVM_ACC_VOLATILE | \ duke@435: JVM_ACC_TRANSIENT | \ duke@435: JVM_ACC_ENUM | \ duke@435: JVM_ACC_SYNTHETIC) duke@435: duke@435: #define JVM_RECOGNIZED_METHOD_MODIFIERS (JVM_ACC_PUBLIC | \ duke@435: JVM_ACC_PRIVATE | \ duke@435: JVM_ACC_PROTECTED | \ duke@435: JVM_ACC_STATIC | \ duke@435: JVM_ACC_FINAL | \ duke@435: JVM_ACC_SYNCHRONIZED | \ duke@435: JVM_ACC_BRIDGE | \ duke@435: JVM_ACC_VARARGS | \ duke@435: JVM_ACC_NATIVE | \ duke@435: JVM_ACC_ABSTRACT | \ duke@435: JVM_ACC_STRICT | \ duke@435: JVM_ACC_SYNTHETIC) duke@435: duke@435: /* duke@435: * This is the function defined in libjava.so to perform path duke@435: * canonicalization. VM call this function before opening jar files duke@435: * to load system classes. duke@435: * duke@435: */ duke@435: duke@435: typedef int (*canonicalize_fn_t)(JNIEnv *env, char *orig, char *out, int len); duke@435: duke@435: /************************************************************************* duke@435: PART 3: I/O and Network Support duke@435: ************************************************************************/ duke@435: duke@435: /* Note that the JVM IO functions are expected to return JVM_IO_ERR duke@435: * when there is any kind of error. The caller can then use the duke@435: * platform specific support (e.g., errno) to get the detailed duke@435: * error info. The JVM_GetLastErrorString procedure may also be used duke@435: * to obtain a descriptive error string. duke@435: */ duke@435: #define JVM_IO_ERR (-1) duke@435: duke@435: /* For interruptible IO. Returning JVM_IO_INTR indicates that an IO duke@435: * operation has been disrupted by Thread.interrupt. There are a duke@435: * number of technical difficulties related to interruptible IO that duke@435: * need to be solved. For example, most existing programs do not handle duke@435: * InterruptedIOExceptions specially, they simply treat those as any duke@435: * IOExceptions, which typically indicate fatal errors. duke@435: * duke@435: * There are also two modes of operation for interruptible IO. In the duke@435: * resumption mode, an interrupted IO operation is guaranteed not to duke@435: * have any side-effects, and can be restarted. In the termination mode, duke@435: * an interrupted IO operation corrupts the underlying IO stream, so duke@435: * that the only reasonable operation on an interrupted stream is to duke@435: * close that stream. The resumption mode seems to be impossible to duke@435: * implement on Win32 and Solaris. Implementing the termination mode is duke@435: * easier, but it's not clear that's the right semantics. duke@435: * duke@435: * Interruptible IO is not supported on Win32.It can be enabled/disabled duke@435: * using a compile-time flag on Solaris. Third-party JVM ports do not duke@435: * need to implement interruptible IO. duke@435: */ duke@435: #define JVM_IO_INTR (-2) duke@435: duke@435: /* Write a string into the given buffer, in the platform's local encoding, duke@435: * that describes the most recent system-level error to occur in this thread. duke@435: * Return the length of the string or zero if no error occurred. duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_GetLastErrorString(char *buf, int len); duke@435: duke@435: /* duke@435: * Convert a pathname into native format. This function does syntactic duke@435: * cleanup, such as removing redundant separator characters. It modifies duke@435: * the given pathname string in place. duke@435: */ duke@435: JNIEXPORT char * JNICALL duke@435: JVM_NativePath(char *); duke@435: duke@435: /* duke@435: * JVM I/O error codes duke@435: */ duke@435: #define JVM_EEXIST -100 duke@435: duke@435: /* duke@435: * Open a file descriptor. This function returns a negative error code duke@435: * on error, and a non-negative integer that is the file descriptor on duke@435: * success. duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_Open(const char *fname, jint flags, jint mode); duke@435: duke@435: /* duke@435: * Close a file descriptor. This function returns -1 on error, and 0 duke@435: * on success. duke@435: * duke@435: * fd the file descriptor to close. duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_Close(jint fd); duke@435: duke@435: /* duke@435: * Read data from a file decriptor into a char array. duke@435: * duke@435: * fd the file descriptor to read from. duke@435: * buf the buffer where to put the read data. duke@435: * nbytes the number of bytes to read. duke@435: * duke@435: * This function returns -1 on error, and 0 on success. duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_Read(jint fd, char *buf, jint nbytes); duke@435: duke@435: /* duke@435: * Write data from a char array to a file decriptor. duke@435: * duke@435: * fd the file descriptor to read from. duke@435: * buf the buffer from which to fetch the data. duke@435: * nbytes the number of bytes to write. duke@435: * duke@435: * This function returns -1 on error, and 0 on success. duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_Write(jint fd, char *buf, jint nbytes); duke@435: duke@435: /* duke@435: * Returns the number of bytes available for reading from a given file duke@435: * descriptor duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_Available(jint fd, jlong *pbytes); duke@435: duke@435: /* duke@435: * Move the file descriptor pointer from whence by offset. duke@435: * duke@435: * fd the file descriptor to move. duke@435: * offset the number of bytes to move it by. duke@435: * whence the start from where to move it. duke@435: * duke@435: * This function returns the resulting pointer location. duke@435: */ duke@435: JNIEXPORT jlong JNICALL duke@435: JVM_Lseek(jint fd, jlong offset, jint whence); duke@435: duke@435: /* duke@435: * Set the length of the file associated with the given descriptor to the given duke@435: * length. If the new length is longer than the current length then the file duke@435: * is extended; the contents of the extended portion are not defined. The duke@435: * value of the file pointer is undefined after this procedure returns. duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_SetLength(jint fd, jlong length); duke@435: duke@435: /* duke@435: * Synchronize the file descriptor's in memory state with that of the duke@435: * physical device. Return of -1 is an error, 0 is OK. duke@435: */ duke@435: JNIEXPORT jint JNICALL duke@435: JVM_Sync(jint fd); duke@435: duke@435: /* duke@435: * Networking library support duke@435: */ duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_InitializeSocketLibrary(void); duke@435: duke@435: struct sockaddr; duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_Socket(jint domain, jint type, jint protocol); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_SocketClose(jint fd); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_SocketShutdown(jint fd, jint howto); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_Recv(jint fd, char *buf, jint nBytes, jint flags); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_Send(jint fd, char *buf, jint nBytes, jint flags); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_Timeout(int fd, long timeout); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_Listen(jint fd, jint count); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_Connect(jint fd, struct sockaddr *him, jint len); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_Bind(jint fd, struct sockaddr *him, jint len); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_Accept(jint fd, struct sockaddr *him, jint *len); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_RecvFrom(jint fd, char *buf, int nBytes, duke@435: int flags, struct sockaddr *from, int *fromlen); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_SendTo(jint fd, char *buf, int len, duke@435: int flags, struct sockaddr *to, int tolen); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_SocketAvailable(jint fd, jint *result); duke@435: duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_GetSockName(jint fd, struct sockaddr *him, int *len); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen); duke@435: duke@435: JNIEXPORT int JNICALL duke@435: JVM_GetHostName(char* name, int namelen); duke@435: duke@435: /* duke@435: * The standard printing functions supported by the Java VM. (Should they duke@435: * be renamed to JVM_* in the future? duke@435: */ duke@435: duke@435: /* duke@435: * BE CAREFUL! The following functions do not implement the duke@435: * full feature set of standard C printf formats. duke@435: */ coleenp@2507: JNIEXPORT int duke@435: jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args); duke@435: coleenp@2507: JNIEXPORT int duke@435: jio_snprintf(char *str, size_t count, const char *fmt, ...); duke@435: coleenp@2507: JNIEXPORT int duke@435: jio_fprintf(FILE *, const char *fmt, ...); duke@435: coleenp@2507: JNIEXPORT int duke@435: jio_vfprintf(FILE *, const char *fmt, va_list args); duke@435: duke@435: duke@435: JNIEXPORT void * JNICALL duke@435: JVM_RawMonitorCreate(void); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_RawMonitorDestroy(void *mon); duke@435: duke@435: JNIEXPORT jint JNICALL duke@435: JVM_RawMonitorEnter(void *mon); duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_RawMonitorExit(void *mon); duke@435: duke@435: /* duke@435: * java.lang.reflect.Method duke@435: */ duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0); duke@435: duke@435: /* duke@435: * java.lang.reflect.Constructor duke@435: */ duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0); duke@435: duke@435: /* duke@435: * java.lang.management support duke@435: */ duke@435: JNIEXPORT void* JNICALL duke@435: JVM_GetManagement(jint version); duke@435: duke@435: /* duke@435: * com.sun.tools.attach.VirtualMachine support duke@435: * duke@435: * Initialize the agent properties with the properties maintained in the VM. duke@435: */ duke@435: JNIEXPORT jobject JNICALL duke@435: JVM_InitAgentProperties(JNIEnv *env, jobject agent_props); duke@435: duke@435: /* Generics reflection support. duke@435: * duke@435: * Returns information about the given class's EnclosingMethod duke@435: * attribute, if present, or null if the class had no enclosing duke@435: * method. duke@435: * duke@435: * If non-null, the returned array contains three elements. Element 0 duke@435: * is the java.lang.Class of which the enclosing method is a member, duke@435: * and elements 1 and 2 are the java.lang.Strings for the enclosing duke@435: * method's name and descriptor, respectively. duke@435: */ duke@435: JNIEXPORT jobjectArray JNICALL duke@435: JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass); duke@435: duke@435: /* duke@435: * Java thread state support duke@435: */ duke@435: enum { duke@435: JAVA_THREAD_STATE_NEW = 0, duke@435: JAVA_THREAD_STATE_RUNNABLE = 1, duke@435: JAVA_THREAD_STATE_BLOCKED = 2, duke@435: JAVA_THREAD_STATE_WAITING = 3, duke@435: JAVA_THREAD_STATE_TIMED_WAITING = 4, duke@435: JAVA_THREAD_STATE_TERMINATED = 5, duke@435: JAVA_THREAD_STATE_COUNT = 6 duke@435: }; duke@435: duke@435: /* duke@435: * Returns an array of the threadStatus values representing the duke@435: * given Java thread state. Returns NULL if the VM version is duke@435: * incompatible with the JDK or doesn't support the given duke@435: * Java thread state. duke@435: */ duke@435: JNIEXPORT jintArray JNICALL duke@435: JVM_GetThreadStateValues(JNIEnv* env, jint javaThreadState); duke@435: duke@435: /* duke@435: * Returns an array of the substate names representing the duke@435: * given Java thread state. Returns NULL if the VM version is duke@435: * incompatible with the JDK or the VM doesn't support duke@435: * the given Java thread state. duke@435: * values must be the jintArray returned from JVM_GetThreadStateValues duke@435: * and javaThreadState. duke@435: */ duke@435: JNIEXPORT jobjectArray JNICALL duke@435: JVM_GetThreadStateNames(JNIEnv* env, jint javaThreadState, jintArray values); duke@435: duke@435: /* ========================================================================= duke@435: * The following defines a private JVM interface that the JDK can query duke@435: * for the JVM version and capabilities. sun.misc.Version defines duke@435: * the methods for getting the VM version and its capabilities. duke@435: * duke@435: * When a new bit is added, the following should be updated to provide duke@435: * access to the new capability: duke@435: * HS: JVM_GetVersionInfo and Abstract_VM_Version class duke@435: * SDK: Version class duke@435: * duke@435: * Similary, a private JDK interface JDK_GetVersionInfo0 is defined for duke@435: * JVM to query for the JDK version and capabilities. duke@435: * duke@435: * When a new bit is added, the following should be updated to provide duke@435: * access to the new capability: duke@435: * HS: JDK_Version class duke@435: * SDK: JDK_GetVersionInfo0 duke@435: * duke@435: * ========================================================================== duke@435: */ duke@435: typedef struct { duke@435: /* HotSpot Express VM version string: duke@435: * .-bxx[-][-] duke@435: */ duke@435: unsigned int jvm_version; /* Consists of major.minor.0.build */ duke@435: unsigned int update_version : 8; /* 0 in HotSpot Express VM */ duke@435: unsigned int special_update_version : 8; /* 0 in HotSpot Express VM */ duke@435: unsigned int reserved1 : 16; duke@435: unsigned int reserved2; duke@435: duke@435: /* The following bits represents JVM supports that JDK has dependency on. duke@435: * JDK can use these bits to determine which JVM version duke@435: * and support it has to maintain runtime compatibility. duke@435: * duke@435: * When a new bit is added in a minor or update release, make sure duke@435: * the new bit is also added in the main/baseline. duke@435: */ duke@435: unsigned int is_attachable : 1; duke@435: unsigned int is_kernel_jvm : 1; duke@435: unsigned int : 30; duke@435: unsigned int : 32; duke@435: unsigned int : 32; duke@435: } jvm_version_info; duke@435: duke@435: #define JVM_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24) duke@435: #define JVM_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16) duke@435: // Micro version is 0 in HotSpot Express VM (set in jvm.cpp). duke@435: #define JVM_VERSION_MICRO(version) ((version & 0x0000FF00) >> 8) duke@435: /* Build number is available in all HotSpot Express VM builds. duke@435: * It is defined in make/hotspot_version file. duke@435: */ duke@435: #define JVM_VERSION_BUILD(version) ((version & 0x000000FF)) duke@435: duke@435: JNIEXPORT void JNICALL duke@435: JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size); duke@435: duke@435: typedef struct { duke@435: // Naming convention of RE build version string: n.n.n[_uu[c]][-]-bxx duke@435: unsigned int jdk_version; /* Consists of major, minor, micro (n.n.n) */ duke@435: /* and build number (xx) */ duke@435: unsigned int update_version : 8; /* Update release version (uu) */ duke@435: unsigned int special_update_version : 8; /* Special update release version (c)*/ duke@435: unsigned int reserved1 : 16; duke@435: unsigned int reserved2; duke@435: duke@435: /* The following bits represents new JDK supports that VM has dependency on. duke@435: * VM implementation can use these bits to determine which JDK version duke@435: * and support it has to maintain runtime compatibility. duke@435: * duke@435: * When a new bit is added in a minor or update release, make sure duke@435: * the new bit is also added in the main/baseline. duke@435: */ duke@435: unsigned int thread_park_blocker : 1; kevinw@2449: unsigned int post_vm_init_hook_enabled : 1; ysr@3117: unsigned int pending_list_uses_discovered_field : 1; ysr@3117: unsigned int : 29; duke@435: unsigned int : 32; duke@435: unsigned int : 32; duke@435: } jdk_version_info; duke@435: duke@435: #define JDK_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24) duke@435: #define JDK_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16) duke@435: #define JDK_VERSION_MICRO(version) ((version & 0x0000FF00) >> 8) duke@435: duke@435: /* Build number is available only for RE build (i.e. JDK_BUILD_NUMBER is set to bNN) duke@435: * It will be zero for internal builds. duke@435: */ duke@435: #define JDK_VERSION_BUILD(version) ((version & 0x000000FF)) duke@435: duke@435: /* duke@435: * This is the function JDK_GetVersionInfo0 defined in libjava.so duke@435: * that is dynamically looked up by JVM. duke@435: */ duke@435: typedef void (*jdk_version_info_fn_t)(jdk_version_info* info, size_t info_size); duke@435: duke@435: /* duke@435: * This structure is used by the launcher to get the default thread duke@435: * stack size from the VM using JNI_GetDefaultJavaVMInitArgs() with a duke@435: * version of 1.1. As it is not supported otherwise, it has been removed duke@435: * from jni.h duke@435: */ duke@435: typedef struct JDK1_1InitArgs { duke@435: jint version; duke@435: duke@435: char **properties; duke@435: jint checkSource; duke@435: jint nativeStackSize; duke@435: jint javaStackSize; duke@435: jint minHeapSize; duke@435: jint maxHeapSize; duke@435: jint verifyMode; duke@435: char *classpath; duke@435: duke@435: jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args); duke@435: void (JNICALL *exit)(jint code); duke@435: void (JNICALL *abort)(void); duke@435: duke@435: jint enableClassGC; duke@435: jint enableVerboseGC; duke@435: jint disableAsyncGC; duke@435: jint verbose; duke@435: jboolean debugging; duke@435: jint debugPort; duke@435: } JDK1_1InitArgs; duke@435: duke@435: #ifdef __cplusplus duke@435: } /* extern "C" */ duke@435: #endif /* __cplusplus */ duke@435: duke@435: #endif /* !_JAVASOFT_JVM_H_ */ stefank@2314: stefank@2314: #endif // SHARE_VM_PRIMS_JVM_H