src/java.base/share/native/include/jvm.h
changeset 48300 8a5edac3d5a2
parent 48299 e8f5fc8f5f67
child 48301 32f13c6c1bbd
equal deleted inserted replaced
48299:e8f5fc8f5f67 48300:8a5edac3d5a2
     1 /*
       
     2  * Copyright (c) 1997, 2017, 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 network 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 5
       
    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 jlong JNICALL
       
   108 JVM_GetNanoTimeAdjustment(JNIEnv *env, jclass ignored, jlong offset_secs);
       
   109 
       
   110 JNIEXPORT void JNICALL
       
   111 JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos,
       
   112               jobject dst, jint dst_pos, jint length);
       
   113 
       
   114 JNIEXPORT jobject JNICALL
       
   115 JVM_InitProperties(JNIEnv *env, jobject p);
       
   116 
       
   117 
       
   118 /*
       
   119  * java.lang.Runtime
       
   120  */
       
   121 JNIEXPORT void JNICALL
       
   122 JVM_Halt(jint code);
       
   123 
       
   124 JNIEXPORT void JNICALL
       
   125 JVM_GC(void);
       
   126 
       
   127 /* Returns the number of real-time milliseconds that have elapsed since the
       
   128  * least-recently-inspected heap object was last inspected by the garbage
       
   129  * collector.
       
   130  *
       
   131  * For simple stop-the-world collectors this value is just the time
       
   132  * since the most recent collection.  For generational collectors it is the
       
   133  * time since the oldest generation was most recently collected.  Other
       
   134  * collectors are free to return a pessimistic estimate of the elapsed time, or
       
   135  * simply the time since the last full collection was performed.
       
   136  *
       
   137  * Note that in the presence of reference objects, a given object that is no
       
   138  * longer strongly reachable may have to be inspected multiple times before it
       
   139  * can be reclaimed.
       
   140  */
       
   141 JNIEXPORT jlong JNICALL
       
   142 JVM_MaxObjectInspectionAge(void);
       
   143 
       
   144 JNIEXPORT jlong JNICALL
       
   145 JVM_TotalMemory(void);
       
   146 
       
   147 JNIEXPORT jlong JNICALL
       
   148 JVM_FreeMemory(void);
       
   149 
       
   150 JNIEXPORT jlong JNICALL
       
   151 JVM_MaxMemory(void);
       
   152 
       
   153 JNIEXPORT jint JNICALL
       
   154 JVM_ActiveProcessorCount(void);
       
   155 
       
   156 JNIEXPORT void * JNICALL
       
   157 JVM_LoadLibrary(const char *name);
       
   158 
       
   159 JNIEXPORT void JNICALL
       
   160 JVM_UnloadLibrary(void * handle);
       
   161 
       
   162 JNIEXPORT void * JNICALL
       
   163 JVM_FindLibraryEntry(void *handle, const char *name);
       
   164 
       
   165 JNIEXPORT jboolean JNICALL
       
   166 JVM_IsSupportedJNIVersion(jint version);
       
   167 
       
   168 JNIEXPORT jobjectArray JNICALL
       
   169 JVM_GetVmArguments(JNIEnv *env);
       
   170 
       
   171 
       
   172 /*
       
   173  * java.lang.Throwable
       
   174  */
       
   175 JNIEXPORT void JNICALL
       
   176 JVM_FillInStackTrace(JNIEnv *env, jobject throwable);
       
   177 
       
   178 /*
       
   179  * java.lang.StackTraceElement
       
   180  */
       
   181 JNIEXPORT void JNICALL
       
   182 JVM_InitStackTraceElementArray(JNIEnv *env, jobjectArray elements, jobject throwable);
       
   183 
       
   184 JNIEXPORT void JNICALL
       
   185 JVM_InitStackTraceElement(JNIEnv* env, jobject element, jobject stackFrameInfo);
       
   186 
       
   187 /*
       
   188  * java.lang.StackWalker
       
   189  */
       
   190 enum {
       
   191   JVM_STACKWALK_FILL_CLASS_REFS_ONLY       = 0x2,
       
   192   JVM_STACKWALK_GET_CALLER_CLASS           = 0x04,
       
   193   JVM_STACKWALK_SHOW_HIDDEN_FRAMES         = 0x20,
       
   194   JVM_STACKWALK_FILL_LIVE_STACK_FRAMES     = 0x100
       
   195 };
       
   196 
       
   197 JNIEXPORT jobject JNICALL
       
   198 JVM_CallStackWalk(JNIEnv *env, jobject stackStream, jlong mode,
       
   199                   jint skip_frames, jint frame_count, jint start_index,
       
   200                   jobjectArray frames);
       
   201 
       
   202 JNIEXPORT jint JNICALL
       
   203 JVM_MoreStackWalk(JNIEnv *env, jobject stackStream, jlong mode, jlong anchor,
       
   204                   jint frame_count, jint start_index,
       
   205                   jobjectArray frames);
       
   206 
       
   207 /*
       
   208  * java.lang.Thread
       
   209  */
       
   210 JNIEXPORT void JNICALL
       
   211 JVM_StartThread(JNIEnv *env, jobject thread);
       
   212 
       
   213 JNIEXPORT void JNICALL
       
   214 JVM_StopThread(JNIEnv *env, jobject thread, jobject exception);
       
   215 
       
   216 JNIEXPORT jboolean JNICALL
       
   217 JVM_IsThreadAlive(JNIEnv *env, jobject thread);
       
   218 
       
   219 JNIEXPORT void JNICALL
       
   220 JVM_SuspendThread(JNIEnv *env, jobject thread);
       
   221 
       
   222 JNIEXPORT void JNICALL
       
   223 JVM_ResumeThread(JNIEnv *env, jobject thread);
       
   224 
       
   225 JNIEXPORT void JNICALL
       
   226 JVM_SetThreadPriority(JNIEnv *env, jobject thread, jint prio);
       
   227 
       
   228 JNIEXPORT void JNICALL
       
   229 JVM_Yield(JNIEnv *env, jclass threadClass);
       
   230 
       
   231 JNIEXPORT void JNICALL
       
   232 JVM_Sleep(JNIEnv *env, jclass threadClass, jlong millis);
       
   233 
       
   234 JNIEXPORT jobject JNICALL
       
   235 JVM_CurrentThread(JNIEnv *env, jclass threadClass);
       
   236 
       
   237 JNIEXPORT jint JNICALL
       
   238 JVM_CountStackFrames(JNIEnv *env, jobject thread);
       
   239 
       
   240 JNIEXPORT void JNICALL
       
   241 JVM_Interrupt(JNIEnv *env, jobject thread);
       
   242 
       
   243 JNIEXPORT jboolean JNICALL
       
   244 JVM_IsInterrupted(JNIEnv *env, jobject thread, jboolean clearInterrupted);
       
   245 
       
   246 JNIEXPORT jboolean JNICALL
       
   247 JVM_HoldsLock(JNIEnv *env, jclass threadClass, jobject obj);
       
   248 
       
   249 JNIEXPORT void JNICALL
       
   250 JVM_DumpAllStacks(JNIEnv *env, jclass unused);
       
   251 
       
   252 JNIEXPORT jobjectArray JNICALL
       
   253 JVM_GetAllThreads(JNIEnv *env, jclass dummy);
       
   254 
       
   255 JNIEXPORT void JNICALL
       
   256 JVM_SetNativeThreadName(JNIEnv *env, jobject jthread, jstring name);
       
   257 
       
   258 /* getStackTrace() and getAllStackTraces() method */
       
   259 JNIEXPORT jobjectArray JNICALL
       
   260 JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads);
       
   261 
       
   262 /*
       
   263  * java.lang.SecurityManager
       
   264  */
       
   265 JNIEXPORT jobjectArray JNICALL
       
   266 JVM_GetClassContext(JNIEnv *env);
       
   267 
       
   268 /*
       
   269  * java.lang.Package
       
   270  */
       
   271 JNIEXPORT jstring JNICALL
       
   272 JVM_GetSystemPackage(JNIEnv *env, jstring name);
       
   273 
       
   274 JNIEXPORT jobjectArray JNICALL
       
   275 JVM_GetSystemPackages(JNIEnv *env);
       
   276 
       
   277 /*
       
   278  * java.lang.ref.Reference
       
   279  */
       
   280 JNIEXPORT jobject JNICALL
       
   281 JVM_GetAndClearReferencePendingList(JNIEnv *env);
       
   282 
       
   283 JNIEXPORT jboolean JNICALL
       
   284 JVM_HasReferencePendingList(JNIEnv *env);
       
   285 
       
   286 JNIEXPORT void JNICALL
       
   287 JVM_WaitForReferencePendingList(JNIEnv *env);
       
   288 
       
   289 /*
       
   290  * java.io.ObjectInputStream
       
   291  */
       
   292 JNIEXPORT jobject JNICALL
       
   293 JVM_LatestUserDefinedLoader(JNIEnv *env);
       
   294 
       
   295 /*
       
   296  * java.lang.reflect.Array
       
   297  */
       
   298 JNIEXPORT jint JNICALL
       
   299 JVM_GetArrayLength(JNIEnv *env, jobject arr);
       
   300 
       
   301 JNIEXPORT jobject JNICALL
       
   302 JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index);
       
   303 
       
   304 JNIEXPORT jvalue JNICALL
       
   305 JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode);
       
   306 
       
   307 JNIEXPORT void JNICALL
       
   308 JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val);
       
   309 
       
   310 JNIEXPORT void JNICALL
       
   311 JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v,
       
   312                              unsigned char vCode);
       
   313 
       
   314 JNIEXPORT jobject JNICALL
       
   315 JVM_NewArray(JNIEnv *env, jclass eltClass, jint length);
       
   316 
       
   317 JNIEXPORT jobject JNICALL
       
   318 JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim);
       
   319 
       
   320 /*
       
   321  * java.lang.Class and java.lang.ClassLoader
       
   322  */
       
   323 
       
   324 #define JVM_CALLER_DEPTH -1
       
   325 
       
   326 /*
       
   327  * Returns the immediate caller class of the native method invoking
       
   328  * JVM_GetCallerClass.  The Method.invoke and other frames due to
       
   329  * reflection machinery are skipped.
       
   330  *
       
   331  * The depth parameter must be -1 (JVM_DEPTH). The caller is expected
       
   332  * to be marked with sun.reflect.CallerSensitive.  The JVM will throw
       
   333  * an error if it is not marked propertly.
       
   334  */
       
   335 JNIEXPORT jclass JNICALL
       
   336 JVM_GetCallerClass(JNIEnv *env, int depth);
       
   337 
       
   338 
       
   339 /*
       
   340  * Find primitive classes
       
   341  * utf: class name
       
   342  */
       
   343 JNIEXPORT jclass JNICALL
       
   344 JVM_FindPrimitiveClass(JNIEnv *env, const char *utf);
       
   345 
       
   346 
       
   347 /*
       
   348  * Find a class from a boot class loader. Returns NULL if class not found.
       
   349  */
       
   350 JNIEXPORT jclass JNICALL
       
   351 JVM_FindClassFromBootLoader(JNIEnv *env, const char *name);
       
   352 
       
   353 /*
       
   354  * Find a class from a given class loader.  Throws ClassNotFoundException.
       
   355  *  name:   name of class
       
   356  *  init:   whether initialization is done
       
   357  *  loader: class loader to look up the class. This may not be the same as the caller's
       
   358  *          class loader.
       
   359  *  caller: initiating class. The initiating class may be null when a security
       
   360  *          manager is not installed.
       
   361  */
       
   362 JNIEXPORT jclass JNICALL
       
   363 JVM_FindClassFromCaller(JNIEnv *env, const char *name, jboolean init,
       
   364                         jobject loader, jclass caller);
       
   365 
       
   366 /*
       
   367  * Find a class from a given class.
       
   368  */
       
   369 JNIEXPORT jclass JNICALL
       
   370 JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init,
       
   371                              jclass from);
       
   372 
       
   373 /* Find a loaded class cached by the VM */
       
   374 JNIEXPORT jclass JNICALL
       
   375 JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name);
       
   376 
       
   377 /* Define a class */
       
   378 JNIEXPORT jclass JNICALL
       
   379 JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf,
       
   380                 jsize len, jobject pd);
       
   381 
       
   382 /* Define a class with a source (added in JDK1.5) */
       
   383 JNIEXPORT jclass JNICALL
       
   384 JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader,
       
   385                           const jbyte *buf, jsize len, jobject pd,
       
   386                           const char *source);
       
   387 
       
   388 /*
       
   389  * Module support funcions
       
   390  */
       
   391 
       
   392 /*
       
   393  * Define a module with the specified packages and bind the module to the
       
   394  * given class loader.
       
   395  *  module:       module to define
       
   396  *  is_open:      specifies if module is open (currently ignored)
       
   397  *  version:      the module version
       
   398  *  location:     the module location
       
   399  *  packages:     list of packages in the module
       
   400  *  num_packages: number of packages in the module
       
   401  */
       
   402 JNIEXPORT void JNICALL
       
   403 JVM_DefineModule(JNIEnv *env, jobject module, jboolean is_open, jstring version,
       
   404                  jstring location, const char* const* packages, jsize num_packages);
       
   405 
       
   406 /*
       
   407  * Set the boot loader's unnamed module.
       
   408  *  module: boot loader's unnamed module
       
   409  */
       
   410 JNIEXPORT void JNICALL
       
   411 JVM_SetBootLoaderUnnamedModule(JNIEnv *env, jobject module);
       
   412 
       
   413 /*
       
   414  * Do a qualified export of a package.
       
   415  *  from_module: module containing the package to export
       
   416  *  package:     name of the package to export
       
   417  *  to_module:   module to export the package to
       
   418  */
       
   419 JNIEXPORT void JNICALL
       
   420 JVM_AddModuleExports(JNIEnv *env, jobject from_module, const char* package, jobject to_module);
       
   421 
       
   422 /*
       
   423  * Do an export of a package to all unnamed modules.
       
   424  *  from_module: module containing the package to export
       
   425  *  package:     name of the package to export to all unnamed modules
       
   426  */
       
   427 JNIEXPORT void JNICALL
       
   428 JVM_AddModuleExportsToAllUnnamed(JNIEnv *env, jobject from_module, const char* package);
       
   429 
       
   430 /*
       
   431  * Do an unqualified export of a package.
       
   432  *  from_module: module containing the package to export
       
   433  *  package:     name of the package to export
       
   434  */
       
   435 JNIEXPORT void JNICALL
       
   436 JVM_AddModuleExportsToAll(JNIEnv *env, jobject from_module, const char* package);
       
   437 
       
   438 /*
       
   439  * Add a module to the list of modules that a given module can read.
       
   440  *  from_module:   module requesting read access
       
   441  *  source_module: module that from_module wants to read
       
   442  */
       
   443 JNIEXPORT void JNICALL
       
   444 JVM_AddReadsModule(JNIEnv *env, jobject from_module, jobject source_module);
       
   445 
       
   446 /*
       
   447  * Reflection support functions
       
   448  */
       
   449 
       
   450 JNIEXPORT jstring JNICALL
       
   451 JVM_GetClassName(JNIEnv *env, jclass cls);
       
   452 
       
   453 JNIEXPORT jobjectArray JNICALL
       
   454 JVM_GetClassInterfaces(JNIEnv *env, jclass cls);
       
   455 
       
   456 JNIEXPORT jboolean JNICALL
       
   457 JVM_IsInterface(JNIEnv *env, jclass cls);
       
   458 
       
   459 JNIEXPORT jobjectArray JNICALL
       
   460 JVM_GetClassSigners(JNIEnv *env, jclass cls);
       
   461 
       
   462 JNIEXPORT void JNICALL
       
   463 JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers);
       
   464 
       
   465 JNIEXPORT jobject JNICALL
       
   466 JVM_GetProtectionDomain(JNIEnv *env, jclass cls);
       
   467 
       
   468 JNIEXPORT jboolean JNICALL
       
   469 JVM_IsArrayClass(JNIEnv *env, jclass cls);
       
   470 
       
   471 JNIEXPORT jboolean JNICALL
       
   472 JVM_IsPrimitiveClass(JNIEnv *env, jclass cls);
       
   473 
       
   474 JNIEXPORT jint JNICALL
       
   475 JVM_GetClassModifiers(JNIEnv *env, jclass cls);
       
   476 
       
   477 JNIEXPORT jobjectArray JNICALL
       
   478 JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass);
       
   479 
       
   480 JNIEXPORT jclass JNICALL
       
   481 JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass);
       
   482 
       
   483 JNIEXPORT jstring JNICALL
       
   484 JVM_GetSimpleBinaryName(JNIEnv *env, jclass ofClass);
       
   485 
       
   486 /* Generics support (JDK 1.5) */
       
   487 JNIEXPORT jstring JNICALL
       
   488 JVM_GetClassSignature(JNIEnv *env, jclass cls);
       
   489 
       
   490 /* Annotations support (JDK 1.5) */
       
   491 JNIEXPORT jbyteArray JNICALL
       
   492 JVM_GetClassAnnotations(JNIEnv *env, jclass cls);
       
   493 
       
   494 /* Type use annotations support (JDK 1.8) */
       
   495 
       
   496 JNIEXPORT jbyteArray JNICALL
       
   497 JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls);
       
   498 
       
   499 JNIEXPORT jbyteArray JNICALL
       
   500 JVM_GetFieldTypeAnnotations(JNIEnv *env, jobject field);
       
   501 
       
   502 JNIEXPORT jbyteArray JNICALL
       
   503 JVM_GetMethodTypeAnnotations(JNIEnv *env, jobject method);
       
   504 
       
   505 /*
       
   506  * New (JDK 1.4) reflection implementation
       
   507  */
       
   508 
       
   509 JNIEXPORT jobjectArray JNICALL
       
   510 JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly);
       
   511 
       
   512 JNIEXPORT jobjectArray JNICALL
       
   513 JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly);
       
   514 
       
   515 JNIEXPORT jobjectArray JNICALL
       
   516 JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly);
       
   517 
       
   518 /* Differs from JVM_GetClassModifiers in treatment of inner classes.
       
   519    This returns the access flags for the class as specified in the
       
   520    class file rather than searching the InnerClasses attribute (if
       
   521    present) to find the source-level access flags. Only the values of
       
   522    the low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be
       
   523    valid. */
       
   524 JNIEXPORT jint JNICALL
       
   525 JVM_GetClassAccessFlags(JNIEnv *env, jclass cls);
       
   526 
       
   527 /* The following two reflection routines are still needed due to startup time issues */
       
   528 /*
       
   529  * java.lang.reflect.Method
       
   530  */
       
   531 JNIEXPORT jobject JNICALL
       
   532 JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0);
       
   533 
       
   534 /*
       
   535  * java.lang.reflect.Constructor
       
   536  */
       
   537 JNIEXPORT jobject JNICALL
       
   538 JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0);
       
   539 
       
   540 /*
       
   541  * Constant pool access; currently used to implement reflective access to annotations (JDK 1.5)
       
   542  */
       
   543 
       
   544 JNIEXPORT jobject JNICALL
       
   545 JVM_GetClassConstantPool(JNIEnv *env, jclass cls);
       
   546 
       
   547 JNIEXPORT jint JNICALL JVM_ConstantPoolGetSize
       
   548 (JNIEnv *env, jobject unused, jobject jcpool);
       
   549 
       
   550 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAt
       
   551 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
       
   552 
       
   553 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAtIfLoaded
       
   554 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
       
   555 
       
   556 JNIEXPORT jint JNICALL JVM_ConstantPoolGetClassRefIndexAt
       
   557 (JNIEnv *env, jobject obj, jobject unused, jint index);
       
   558 
       
   559 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAt
       
   560 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
       
   561 
       
   562 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAtIfLoaded
       
   563 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
       
   564 
       
   565 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAt
       
   566 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
       
   567 
       
   568 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAtIfLoaded
       
   569 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
       
   570 
       
   571 JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetMemberRefInfoAt
       
   572 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
       
   573 
       
   574 JNIEXPORT jint JNICALL JVM_ConstantPoolGetNameAndTypeRefIndexAt
       
   575 (JNIEnv *env, jobject obj, jobject unused, jint index);
       
   576 
       
   577 JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetNameAndTypeRefInfoAt
       
   578 (JNIEnv *env, jobject obj, jobject unused, jint index);
       
   579 
       
   580 JNIEXPORT jint JNICALL JVM_ConstantPoolGetIntAt
       
   581 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
       
   582 
       
   583 JNIEXPORT jlong JNICALL JVM_ConstantPoolGetLongAt
       
   584 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
       
   585 
       
   586 JNIEXPORT jfloat JNICALL JVM_ConstantPoolGetFloatAt
       
   587 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
       
   588 
       
   589 JNIEXPORT jdouble JNICALL JVM_ConstantPoolGetDoubleAt
       
   590 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
       
   591 
       
   592 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetStringAt
       
   593 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
       
   594 
       
   595 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetUTF8At
       
   596 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
       
   597 
       
   598 JNIEXPORT jbyte JNICALL JVM_ConstantPoolGetTagAt
       
   599 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
       
   600 
       
   601 /*
       
   602  * Parameter reflection
       
   603  */
       
   604 
       
   605 JNIEXPORT jobjectArray JNICALL
       
   606 JVM_GetMethodParameters(JNIEnv *env, jobject method);
       
   607 
       
   608 /*
       
   609  * java.security.*
       
   610  */
       
   611 
       
   612 JNIEXPORT jobject JNICALL
       
   613 JVM_DoPrivileged(JNIEnv *env, jclass cls,
       
   614                  jobject action, jobject context, jboolean wrapException);
       
   615 
       
   616 JNIEXPORT jobject JNICALL
       
   617 JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls);
       
   618 
       
   619 JNIEXPORT jobject JNICALL
       
   620 JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls);
       
   621 
       
   622 /*
       
   623  * Signal support, used to implement the shutdown sequence.  Every VM must
       
   624  * support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts
       
   625  * (^C) and the latter for external termination (kill, system shutdown, etc.).
       
   626  * Other platform-dependent signal values may also be supported.
       
   627  */
       
   628 
       
   629 JNIEXPORT void * JNICALL
       
   630 JVM_RegisterSignal(jint sig, void *handler);
       
   631 
       
   632 JNIEXPORT jboolean JNICALL
       
   633 JVM_RaiseSignal(jint sig);
       
   634 
       
   635 JNIEXPORT jint JNICALL
       
   636 JVM_FindSignal(const char *name);
       
   637 
       
   638 /*
       
   639  * Retrieve the assertion directives for the specified class.
       
   640  */
       
   641 JNIEXPORT jboolean JNICALL
       
   642 JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls);
       
   643 
       
   644 /*
       
   645  * Retrieve the assertion directives from the VM.
       
   646  */
       
   647 JNIEXPORT jobject JNICALL
       
   648 JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused);
       
   649 
       
   650 /*
       
   651  * java.util.concurrent.atomic.AtomicLong
       
   652  */
       
   653 JNIEXPORT jboolean JNICALL
       
   654 JVM_SupportsCX8(void);
       
   655 
       
   656 /*
       
   657  * com.sun.dtrace.jsdt support
       
   658  */
       
   659 
       
   660 #define JVM_TRACING_DTRACE_VERSION 1
       
   661 
       
   662 /*
       
   663  * Structure to pass one probe description to JVM
       
   664  */
       
   665 typedef struct {
       
   666     jmethodID method;
       
   667     jstring   function;
       
   668     jstring   name;
       
   669     void*            reserved[4];     // for future use
       
   670 } JVM_DTraceProbe;
       
   671 
       
   672 /**
       
   673  * Encapsulates the stability ratings for a DTrace provider field
       
   674  */
       
   675 typedef struct {
       
   676     jint nameStability;
       
   677     jint dataStability;
       
   678     jint dependencyClass;
       
   679 } JVM_DTraceInterfaceAttributes;
       
   680 
       
   681 /*
       
   682  * Structure to pass one provider description to JVM
       
   683  */
       
   684 typedef struct {
       
   685     jstring                       name;
       
   686     JVM_DTraceProbe*              probes;
       
   687     jint                          probe_count;
       
   688     JVM_DTraceInterfaceAttributes providerAttributes;
       
   689     JVM_DTraceInterfaceAttributes moduleAttributes;
       
   690     JVM_DTraceInterfaceAttributes functionAttributes;
       
   691     JVM_DTraceInterfaceAttributes nameAttributes;
       
   692     JVM_DTraceInterfaceAttributes argsAttributes;
       
   693     void*                         reserved[4]; // for future use
       
   694 } JVM_DTraceProvider;
       
   695 
       
   696 /*
       
   697  * Get the version number the JVM was built with
       
   698  */
       
   699 JNIEXPORT jint JNICALL
       
   700 JVM_DTraceGetVersion(JNIEnv* env);
       
   701 
       
   702 /*
       
   703  * Register new probe with given signature, return global handle
       
   704  *
       
   705  * The version passed in is the version that the library code was
       
   706  * built with.
       
   707  */
       
   708 JNIEXPORT jlong JNICALL
       
   709 JVM_DTraceActivate(JNIEnv* env, jint version, jstring module_name,
       
   710   jint providers_count, JVM_DTraceProvider* providers);
       
   711 
       
   712 /*
       
   713  * Check JSDT probe
       
   714  */
       
   715 JNIEXPORT jboolean JNICALL
       
   716 JVM_DTraceIsProbeEnabled(JNIEnv* env, jmethodID method);
       
   717 
       
   718 /*
       
   719  * Destroy custom DOF
       
   720  */
       
   721 JNIEXPORT void JNICALL
       
   722 JVM_DTraceDispose(JNIEnv* env, jlong activation_handle);
       
   723 
       
   724 /*
       
   725  * Check to see if DTrace is supported by OS
       
   726  */
       
   727 JNIEXPORT jboolean JNICALL
       
   728 JVM_DTraceIsSupported(JNIEnv* env);
       
   729 
       
   730 /*************************************************************************
       
   731  PART 2: Support for the Verifier and Class File Format Checker
       
   732  ************************************************************************/
       
   733 /*
       
   734  * Return the class name in UTF format. The result is valid
       
   735  * until JVM_ReleaseUTf is called.
       
   736  *
       
   737  * The caller must treat the string as a constant and not modify it
       
   738  * in any way.
       
   739  */
       
   740 JNIEXPORT const char * JNICALL
       
   741 JVM_GetClassNameUTF(JNIEnv *env, jclass cb);
       
   742 
       
   743 /*
       
   744  * Returns the constant pool types in the buffer provided by "types."
       
   745  */
       
   746 JNIEXPORT void JNICALL
       
   747 JVM_GetClassCPTypes(JNIEnv *env, jclass cb, unsigned char *types);
       
   748 
       
   749 /*
       
   750  * Returns the number of Constant Pool entries.
       
   751  */
       
   752 JNIEXPORT jint JNICALL
       
   753 JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cb);
       
   754 
       
   755 /*
       
   756  * Returns the number of *declared* fields or methods.
       
   757  */
       
   758 JNIEXPORT jint JNICALL
       
   759 JVM_GetClassFieldsCount(JNIEnv *env, jclass cb);
       
   760 
       
   761 JNIEXPORT jint JNICALL
       
   762 JVM_GetClassMethodsCount(JNIEnv *env, jclass cb);
       
   763 
       
   764 /*
       
   765  * Returns the CP indexes of exceptions raised by a given method.
       
   766  * Places the result in the given buffer.
       
   767  *
       
   768  * The method is identified by method_index.
       
   769  */
       
   770 JNIEXPORT void JNICALL
       
   771 JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cb, jint method_index,
       
   772                                 unsigned short *exceptions);
       
   773 /*
       
   774  * Returns the number of exceptions raised by a given method.
       
   775  * The method is identified by method_index.
       
   776  */
       
   777 JNIEXPORT jint JNICALL
       
   778 JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cb, jint method_index);
       
   779 
       
   780 /*
       
   781  * Returns the byte code sequence of a given method.
       
   782  * Places the result in the given buffer.
       
   783  *
       
   784  * The method is identified by method_index.
       
   785  */
       
   786 JNIEXPORT void JNICALL
       
   787 JVM_GetMethodIxByteCode(JNIEnv *env, jclass cb, jint method_index,
       
   788                         unsigned char *code);
       
   789 
       
   790 /*
       
   791  * Returns the length of the byte code sequence of a given method.
       
   792  * The method is identified by method_index.
       
   793  */
       
   794 JNIEXPORT jint JNICALL
       
   795 JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cb, jint method_index);
       
   796 
       
   797 /*
       
   798  * A structure used to a capture exception table entry in a Java method.
       
   799  */
       
   800 typedef struct {
       
   801     jint start_pc;
       
   802     jint end_pc;
       
   803     jint handler_pc;
       
   804     jint catchType;
       
   805 } JVM_ExceptionTableEntryType;
       
   806 
       
   807 /*
       
   808  * Returns the exception table entry at entry_index of a given method.
       
   809  * Places the result in the given buffer.
       
   810  *
       
   811  * The method is identified by method_index.
       
   812  */
       
   813 JNIEXPORT void JNICALL
       
   814 JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cb, jint method_index,
       
   815                                    jint entry_index,
       
   816                                    JVM_ExceptionTableEntryType *entry);
       
   817 
       
   818 /*
       
   819  * Returns the length of the exception table of a given method.
       
   820  * The method is identified by method_index.
       
   821  */
       
   822 JNIEXPORT jint JNICALL
       
   823 JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cb, int index);
       
   824 
       
   825 /*
       
   826  * Returns the modifiers of a given field.
       
   827  * The field is identified by field_index.
       
   828  */
       
   829 JNIEXPORT jint JNICALL
       
   830 JVM_GetFieldIxModifiers(JNIEnv *env, jclass cb, int index);
       
   831 
       
   832 /*
       
   833  * Returns the modifiers of a given method.
       
   834  * The method is identified by method_index.
       
   835  */
       
   836 JNIEXPORT jint JNICALL
       
   837 JVM_GetMethodIxModifiers(JNIEnv *env, jclass cb, int index);
       
   838 
       
   839 /*
       
   840  * Returns the number of local variables of a given method.
       
   841  * The method is identified by method_index.
       
   842  */
       
   843 JNIEXPORT jint JNICALL
       
   844 JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cb, int index);
       
   845 
       
   846 /*
       
   847  * Returns the number of arguments (including this pointer) of a given method.
       
   848  * The method is identified by method_index.
       
   849  */
       
   850 JNIEXPORT jint JNICALL
       
   851 JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cb, int index);
       
   852 
       
   853 /*
       
   854  * Returns the maximum amount of stack (in words) used by a given method.
       
   855  * The method is identified by method_index.
       
   856  */
       
   857 JNIEXPORT jint JNICALL
       
   858 JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cb, int index);
       
   859 
       
   860 /*
       
   861  * Is a given method a constructor.
       
   862  * The method is identified by method_index.
       
   863  */
       
   864 JNIEXPORT jboolean JNICALL
       
   865 JVM_IsConstructorIx(JNIEnv *env, jclass cb, int index);
       
   866 
       
   867 /*
       
   868  * Is the given method generated by the VM.
       
   869  * The method is identified by method_index.
       
   870  */
       
   871 JNIEXPORT jboolean JNICALL
       
   872 JVM_IsVMGeneratedMethodIx(JNIEnv *env, jclass cb, int index);
       
   873 
       
   874 /*
       
   875  * Returns the name of a given method in UTF format.
       
   876  * The result remains valid until JVM_ReleaseUTF is called.
       
   877  *
       
   878  * The caller must treat the string as a constant and not modify it
       
   879  * in any way.
       
   880  */
       
   881 JNIEXPORT const char * JNICALL
       
   882 JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cb, jint index);
       
   883 
       
   884 /*
       
   885  * Returns the signature of a given method in UTF format.
       
   886  * The result remains valid until JVM_ReleaseUTF 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_GetMethodIxSignatureUTF(JNIEnv *env, jclass cb, jint index);
       
   893 
       
   894 /*
       
   895  * Returns the name of the field 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_GetCPFieldNameUTF(JNIEnv *env, jclass cb, jint index);
       
   906 
       
   907 /*
       
   908  * Returns the name of the method 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_GetCPMethodNameUTF(JNIEnv *env, jclass cb, jint index);
       
   919 
       
   920 /*
       
   921  * Returns the signature of the method referred to at a given constant pool
       
   922  * index.
       
   923  *
       
   924  * The result is in UTF format and remains valid until JVM_ReleaseUTF
       
   925  * is called.
       
   926  *
       
   927  * The caller must treat the string as a constant and not modify it
       
   928  * in any way.
       
   929  */
       
   930 JNIEXPORT const char * JNICALL
       
   931 JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cb, jint index);
       
   932 
       
   933 /*
       
   934  * Returns the signature of the field referred to at a given constant pool
       
   935  * index.
       
   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_GetCPFieldSignatureUTF(JNIEnv *env, jclass cb, jint index);
       
   945 
       
   946 /*
       
   947  * Returns the class name referred to at a given constant pool index.
       
   948  *
       
   949  * The result is in UTF format and remains valid until JVM_ReleaseUTF
       
   950  * is called.
       
   951  *
       
   952  * The caller must treat the string as a constant and not modify it
       
   953  * in any way.
       
   954  */
       
   955 JNIEXPORT const char * JNICALL
       
   956 JVM_GetCPClassNameUTF(JNIEnv *env, jclass cb, jint index);
       
   957 
       
   958 /*
       
   959  * Returns the class name referred to at a given constant pool index.
       
   960  *
       
   961  * The constant pool entry must refer to a CONSTANT_Fieldref.
       
   962  *
       
   963  * The result is in UTF format and remains valid until JVM_ReleaseUTF
       
   964  * is called.
       
   965  *
       
   966  * The caller must treat the string as a constant and not modify it
       
   967  * in any way.
       
   968  */
       
   969 JNIEXPORT const char * JNICALL
       
   970 JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cb, jint index);
       
   971 
       
   972 /*
       
   973  * Returns the class name referred to at a given constant pool index.
       
   974  *
       
   975  * The constant pool entry must refer to CONSTANT_Methodref or
       
   976  * CONSTANT_InterfaceMethodref.
       
   977  *
       
   978  * The result is in UTF format and remains valid until JVM_ReleaseUTF
       
   979  * is called.
       
   980  *
       
   981  * The caller must treat the string as a constant and not modify it
       
   982  * in any way.
       
   983  */
       
   984 JNIEXPORT const char * JNICALL
       
   985 JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cb, jint index);
       
   986 
       
   987 /*
       
   988  * Returns the modifiers of a field in calledClass. The field is
       
   989  * referred to in class cb at constant pool entry index.
       
   990  *
       
   991  * The caller must treat the string as a constant and not modify it
       
   992  * in any way.
       
   993  *
       
   994  * Returns -1 if the field does not exist in calledClass.
       
   995  */
       
   996 JNIEXPORT jint JNICALL
       
   997 JVM_GetCPFieldModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
       
   998 
       
   999 /*
       
  1000  * Returns the modifiers of a method in calledClass. The method is
       
  1001  * referred to in class cb at constant pool entry index.
       
  1002  *
       
  1003  * Returns -1 if the method does not exist in calledClass.
       
  1004  */
       
  1005 JNIEXPORT jint JNICALL
       
  1006 JVM_GetCPMethodModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
       
  1007 
       
  1008 /*
       
  1009  * Releases the UTF string obtained from the VM.
       
  1010  */
       
  1011 JNIEXPORT void JNICALL
       
  1012 JVM_ReleaseUTF(const char *utf);
       
  1013 
       
  1014 /*
       
  1015  * Compare if two classes are in the same package.
       
  1016  */
       
  1017 JNIEXPORT jboolean JNICALL
       
  1018 JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2);
       
  1019 
       
  1020 /* Get classfile constants */
       
  1021 #include "classfile_constants.h"
       
  1022 
       
  1023 /*
       
  1024  * A function defined by the byte-code verifier and called by the VM.
       
  1025  * This is not a function implemented in the VM.
       
  1026  *
       
  1027  * Returns JNI_FALSE if verification fails. A detailed error message
       
  1028  * will be places in msg_buf, whose length is specified by buf_len.
       
  1029  */
       
  1030 typedef jboolean (*verifier_fn_t)(JNIEnv *env,
       
  1031                                   jclass cb,
       
  1032                                   char * msg_buf,
       
  1033                                   jint buf_len);
       
  1034 
       
  1035 
       
  1036 /*
       
  1037  * Support for a VM-independent class format checker.
       
  1038  */
       
  1039 typedef struct {
       
  1040     unsigned long code;    /* byte code */
       
  1041     unsigned long excs;    /* exceptions */
       
  1042     unsigned long etab;    /* catch table */
       
  1043     unsigned long lnum;    /* line number */
       
  1044     unsigned long lvar;    /* local vars */
       
  1045 } method_size_info;
       
  1046 
       
  1047 typedef struct {
       
  1048     unsigned int constants;    /* constant pool */
       
  1049     unsigned int fields;
       
  1050     unsigned int methods;
       
  1051     unsigned int interfaces;
       
  1052     unsigned int fields2;      /* number of static 2-word fields */
       
  1053     unsigned int innerclasses; /* # of records in InnerClasses attr */
       
  1054 
       
  1055     method_size_info clinit;   /* memory used in clinit */
       
  1056     method_size_info main;     /* used everywhere else */
       
  1057 } class_size_info;
       
  1058 
       
  1059 /*
       
  1060  * Functions defined in libjava.so to perform string conversions.
       
  1061  *
       
  1062  */
       
  1063 
       
  1064 typedef jstring (*to_java_string_fn_t)(JNIEnv *env, char *str);
       
  1065 
       
  1066 typedef char *(*to_c_string_fn_t)(JNIEnv *env, jstring s, jboolean *b);
       
  1067 
       
  1068 /* This is the function defined in libjava.so that performs class
       
  1069  * format checks. This functions fills in size information about
       
  1070  * the class file and returns:
       
  1071  *
       
  1072  *   0: good
       
  1073  *  -1: out of memory
       
  1074  *  -2: bad format
       
  1075  *  -3: unsupported version
       
  1076  *  -4: bad class name
       
  1077  */
       
  1078 
       
  1079 typedef jint (*check_format_fn_t)(char *class_name,
       
  1080                                   unsigned char *data,
       
  1081                                   unsigned int data_size,
       
  1082                                   class_size_info *class_size,
       
  1083                                   char *message_buffer,
       
  1084                                   jint buffer_length,
       
  1085                                   jboolean measure_only,
       
  1086                                   jboolean check_relaxed);
       
  1087 
       
  1088 #define JVM_RECOGNIZED_CLASS_MODIFIERS (JVM_ACC_PUBLIC | \
       
  1089                                         JVM_ACC_FINAL | \
       
  1090                                         JVM_ACC_SUPER | \
       
  1091                                         JVM_ACC_INTERFACE | \
       
  1092                                         JVM_ACC_ABSTRACT | \
       
  1093                                         JVM_ACC_ANNOTATION | \
       
  1094                                         JVM_ACC_ENUM | \
       
  1095                                         JVM_ACC_SYNTHETIC)
       
  1096 
       
  1097 #define JVM_RECOGNIZED_FIELD_MODIFIERS (JVM_ACC_PUBLIC | \
       
  1098                                         JVM_ACC_PRIVATE | \
       
  1099                                         JVM_ACC_PROTECTED | \
       
  1100                                         JVM_ACC_STATIC | \
       
  1101                                         JVM_ACC_FINAL | \
       
  1102                                         JVM_ACC_VOLATILE | \
       
  1103                                         JVM_ACC_TRANSIENT | \
       
  1104                                         JVM_ACC_ENUM | \
       
  1105                                         JVM_ACC_SYNTHETIC)
       
  1106 
       
  1107 #define JVM_RECOGNIZED_METHOD_MODIFIERS (JVM_ACC_PUBLIC | \
       
  1108                                          JVM_ACC_PRIVATE | \
       
  1109                                          JVM_ACC_PROTECTED | \
       
  1110                                          JVM_ACC_STATIC | \
       
  1111                                          JVM_ACC_FINAL | \
       
  1112                                          JVM_ACC_SYNCHRONIZED | \
       
  1113                                          JVM_ACC_BRIDGE | \
       
  1114                                          JVM_ACC_VARARGS | \
       
  1115                                          JVM_ACC_NATIVE | \
       
  1116                                          JVM_ACC_ABSTRACT | \
       
  1117                                          JVM_ACC_STRICT | \
       
  1118                                          JVM_ACC_SYNTHETIC)
       
  1119 
       
  1120 /*
       
  1121  * This is the function defined in libjava.so to perform path
       
  1122  * canonicalization. VM call this function before opening jar files
       
  1123  * to load system classes.
       
  1124  *
       
  1125  */
       
  1126 
       
  1127 typedef int (*canonicalize_fn_t)(JNIEnv *env, char *orig, char *out, int len);
       
  1128 
       
  1129 /*************************************************************************
       
  1130  PART 3: I/O and Network Support
       
  1131  ************************************************************************/
       
  1132 
       
  1133 /*
       
  1134  * Convert a pathname into native format.  This function does syntactic
       
  1135  * cleanup, such as removing redundant separator characters.  It modifies
       
  1136  * the given pathname string in place.
       
  1137  */
       
  1138 JNIEXPORT char * JNICALL
       
  1139 JVM_NativePath(char *);
       
  1140 
       
  1141 /*
       
  1142  * The standard printing functions supported by the Java VM. (Should they
       
  1143  * be renamed to JVM_* in the future?
       
  1144  */
       
  1145 
       
  1146 /* jio_snprintf() and jio_vsnprintf() behave like snprintf(3) and vsnprintf(3),
       
  1147  *  respectively, with the following differences:
       
  1148  * - The string written to str is always zero-terminated, also in case of
       
  1149  *   truncation (count is too small to hold the result string), unless count
       
  1150  *   is 0. In case of truncation count-1 characters are written and '\0'
       
  1151  *   appendend.
       
  1152  * - If count is too small to hold the whole string, -1 is returned across
       
  1153  *   all platforms. */
       
  1154 
       
  1155 JNIEXPORT int
       
  1156 jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
       
  1157 
       
  1158 JNIEXPORT int
       
  1159 jio_snprintf(char *str, size_t count, const char *fmt, ...);
       
  1160 
       
  1161 JNIEXPORT int
       
  1162 jio_fprintf(FILE *, const char *fmt, ...);
       
  1163 
       
  1164 JNIEXPORT int
       
  1165 jio_vfprintf(FILE *, const char *fmt, va_list args);
       
  1166 
       
  1167 
       
  1168 JNIEXPORT void * JNICALL
       
  1169 JVM_RawMonitorCreate(void);
       
  1170 
       
  1171 JNIEXPORT void JNICALL
       
  1172 JVM_RawMonitorDestroy(void *mon);
       
  1173 
       
  1174 JNIEXPORT jint JNICALL
       
  1175 JVM_RawMonitorEnter(void *mon);
       
  1176 
       
  1177 JNIEXPORT void JNICALL
       
  1178 JVM_RawMonitorExit(void *mon);
       
  1179 
       
  1180 /*
       
  1181  * java.lang.management support
       
  1182  */
       
  1183 JNIEXPORT void* JNICALL
       
  1184 JVM_GetManagement(jint version);
       
  1185 
       
  1186 /*
       
  1187  * com.sun.tools.attach.VirtualMachine support
       
  1188  *
       
  1189  * Initialize the agent properties with the properties maintained in the VM.
       
  1190  */
       
  1191 JNIEXPORT jobject JNICALL
       
  1192 JVM_InitAgentProperties(JNIEnv *env, jobject agent_props);
       
  1193 
       
  1194 JNIEXPORT jstring JNICALL
       
  1195 JVM_GetTemporaryDirectory(JNIEnv *env);
       
  1196 
       
  1197 /* Generics reflection support.
       
  1198  *
       
  1199  * Returns information about the given class's EnclosingMethod
       
  1200  * attribute, if present, or null if the class had no enclosing
       
  1201  * method.
       
  1202  *
       
  1203  * If non-null, the returned array contains three elements. Element 0
       
  1204  * is the java.lang.Class of which the enclosing method is a member,
       
  1205  * and elements 1 and 2 are the java.lang.Strings for the enclosing
       
  1206  * method's name and descriptor, respectively.
       
  1207  */
       
  1208 JNIEXPORT jobjectArray JNICALL
       
  1209 JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass);
       
  1210 
       
  1211 /* =========================================================================
       
  1212  * The following defines a private JVM interface that the JDK can query
       
  1213  * for the JVM version and capabilities.  sun.misc.Version defines
       
  1214  * the methods for getting the VM version and its capabilities.
       
  1215  *
       
  1216  * When a new bit is added, the following should be updated to provide
       
  1217  * access to the new capability:
       
  1218  *    HS:   JVM_GetVersionInfo and Abstract_VM_Version class
       
  1219  *    SDK:  Version class
       
  1220  *
       
  1221  * Similary, a private JDK interface JDK_GetVersionInfo0 is defined for
       
  1222  * JVM to query for the JDK version and capabilities.
       
  1223  *
       
  1224  * When a new bit is added, the following should be updated to provide
       
  1225  * access to the new capability:
       
  1226  *    HS:   JDK_Version class
       
  1227  *    SDK:  JDK_GetVersionInfo0
       
  1228  *
       
  1229  * ==========================================================================
       
  1230  */
       
  1231 typedef struct {
       
  1232     unsigned int jvm_version;  /* Encoded $VNUM as specified by JEP-223 */
       
  1233     unsigned int patch_version : 8; /* JEP-223 patch version */
       
  1234     unsigned int reserved3 : 8;
       
  1235     unsigned int reserved1 : 16;
       
  1236     unsigned int reserved2;
       
  1237 
       
  1238     /* The following bits represents JVM supports that JDK has dependency on.
       
  1239      * JDK can use these bits to determine which JVM version
       
  1240      * and support it has to maintain runtime compatibility.
       
  1241      *
       
  1242      * When a new bit is added in a minor or update release, make sure
       
  1243      * the new bit is also added in the main/baseline.
       
  1244      */
       
  1245     unsigned int is_attach_supported : 1;
       
  1246     unsigned int : 31;
       
  1247     unsigned int : 32;
       
  1248     unsigned int : 32;
       
  1249 } jvm_version_info;
       
  1250 
       
  1251 #define JVM_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24)
       
  1252 #define JVM_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16)
       
  1253 #define JVM_VERSION_SECURITY(version) ((version & 0x0000FF00) >> 8)
       
  1254 #define JVM_VERSION_BUILD(version) ((version & 0x000000FF))
       
  1255 
       
  1256 JNIEXPORT void JNICALL
       
  1257 JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size);
       
  1258 
       
  1259 typedef struct {
       
  1260     unsigned int jdk_version; /* Encoded $VNUM as specified by JEP-223 */
       
  1261     unsigned int patch_version : 8; /* JEP-223 patch version */
       
  1262     unsigned int reserved3 : 8;
       
  1263     unsigned int reserved1 : 16;
       
  1264     unsigned int reserved2;
       
  1265 
       
  1266     /* The following bits represents new JDK supports that VM has dependency on.
       
  1267      * VM implementation can use these bits to determine which JDK version
       
  1268      * and support it has to maintain runtime compatibility.
       
  1269      *
       
  1270      * When a new bit is added in a minor or update release, make sure
       
  1271      * the new bit is also added in the main/baseline.
       
  1272      */
       
  1273     unsigned int thread_park_blocker : 1;
       
  1274     unsigned int post_vm_init_hook_enabled : 1;
       
  1275     unsigned int pending_list_uses_discovered_field : 1;
       
  1276     unsigned int : 29;
       
  1277     unsigned int : 32;
       
  1278     unsigned int : 32;
       
  1279 } jdk_version_info;
       
  1280 
       
  1281 #define JDK_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24)
       
  1282 #define JDK_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16)
       
  1283 #define JDK_VERSION_SECURITY(version) ((version & 0x0000FF00) >> 8)
       
  1284 #define JDK_VERSION_BUILD(version) ((version & 0x000000FF))
       
  1285 
       
  1286 /*
       
  1287  * This is the function JDK_GetVersionInfo0 defined in libjava.so
       
  1288  * that is dynamically looked up by JVM.
       
  1289  */
       
  1290 typedef void (*jdk_version_info_fn_t)(jdk_version_info* info, size_t info_size);
       
  1291 
       
  1292 /*
       
  1293  * This structure is used by the launcher to get the default thread
       
  1294  * stack size from the VM using JNI_GetDefaultJavaVMInitArgs() with a
       
  1295  * version of 1.1.  As it is not supported otherwise, it has been removed
       
  1296  * from jni.h
       
  1297  */
       
  1298 typedef struct JDK1_1InitArgs {
       
  1299     jint version;
       
  1300 
       
  1301     char **properties;
       
  1302     jint checkSource;
       
  1303     jint nativeStackSize;
       
  1304     jint javaStackSize;
       
  1305     jint minHeapSize;
       
  1306     jint maxHeapSize;
       
  1307     jint verifyMode;
       
  1308     char *classpath;
       
  1309 
       
  1310     jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args);
       
  1311     void (JNICALL *exit)(jint code);
       
  1312     void (JNICALL *abort)(void);
       
  1313 
       
  1314     jint enableClassGC;
       
  1315     jint enableVerboseGC;
       
  1316     jint disableAsyncGC;
       
  1317     jint verbose;
       
  1318     jboolean debugging;
       
  1319     jint debugPort;
       
  1320 } JDK1_1InitArgs;
       
  1321 
       
  1322 
       
  1323 #ifdef __cplusplus
       
  1324 } /* extern "C" */
       
  1325 
       
  1326 #endif /* __cplusplus */
       
  1327 
       
  1328 #endif /* !_JAVASOFT_JVM_H_ */