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