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