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