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