src/share/vm/prims/jvm.h

Wed, 14 Oct 2020 17:44:48 +0800

author
aoqi
date
Wed, 14 Oct 2020 17:44:48 +0800
changeset 9931
fd44df5e3bc3
parent 9572
624a0741915c
parent 9915
26ffadc256e1
child 10015
eb7ce841ccec
permissions
-rw-r--r--

Merge

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

mercurial