1 /*
   2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   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 #include "utilities/macros.hpp"
  30 
  31 #include OS_HEADER_H(jvm)
  32 
  33 #ifndef _JAVASOFT_JVM_H_
  34 #define _JAVASOFT_JVM_H_
  35 
  36 // HotSpot integration note:
  37 //
  38 // This file and jvm.h used with the JDK are identical,
  39 // except for the three includes removed below
  40 
  41 // #include <sys/stat.h>
  42 // #include "jni.h"
  43 // #include "jvm_md.h"
  44 
  45 
  46 #ifdef __cplusplus
  47 extern "C" {
  48 #endif
  49 
  50 /*
  51  * This file contains additional functions exported from the VM.
  52  * These functions are complementary to the standard JNI support.
  53  * There are three parts to this file:
  54  *
  55  * First, this file contains the VM-related functions needed by native
  56  * libraries in the standard Java API. For example, the java.lang.Object
  57  * class needs VM-level functions that wait for and notify monitors.
  58  *
  59  * Second, this file contains the functions and constant definitions
  60  * needed by the byte code verifier and class file format checker.
  61  * These functions allow the verifier and format checker to be written
  62  * in a VM-independent way.
  63  *
  64  * Third, this file contains various I/O and nerwork operations needed
  65  * by the standard Java I/O and network APIs.
  66  */
  67 
  68 /*
  69  * Bump the version number when either of the following happens:
  70  *
  71  * 1. There is a change in JVM_* functions.
  72  *
  73  * 2. There is a change in the contract between VM and Java classes.
  74  *    For example, if the VM relies on a new private field in Thread
  75  *    class.
  76  */
  77 
  78 #define JVM_INTERFACE_VERSION 5
  79 
  80 JNIEXPORT jobjectArray JNICALL
  81 JVM_GetMethodParameters(JNIEnv *env, jobject method);
  82 
  83 JNIEXPORT jint JNICALL
  84 JVM_GetInterfaceVersion(void);
  85 
  86 /*************************************************************************
  87  PART 1: Functions for Native Libraries
  88  ************************************************************************/
  89 /*
  90  * java.lang.Object
  91  */
  92 JNIEXPORT jint JNICALL
  93 JVM_IHashCode(JNIEnv *env, jobject obj);
  94 
  95 JNIEXPORT void JNICALL
  96 JVM_MonitorWait(JNIEnv *env, jobject obj, jlong ms);
  97 
  98 JNIEXPORT void JNICALL
  99 JVM_MonitorNotify(JNIEnv *env, jobject obj);
 100 
 101 JNIEXPORT void JNICALL
 102 JVM_MonitorNotifyAll(JNIEnv *env, jobject obj);
 103 
 104 JNIEXPORT jobject JNICALL
 105 JVM_Clone(JNIEnv *env, jobject obj);
 106 
 107 /*
 108  * java.lang.String
 109  */
 110 JNIEXPORT jstring JNICALL
 111 JVM_InternString(JNIEnv *env, jstring str);
 112 
 113 /*
 114  * java.lang.System
 115  */
 116 JNIEXPORT jlong JNICALL
 117 JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored);
 118 
 119 JNIEXPORT jlong JNICALL
 120 JVM_NanoTime(JNIEnv *env, jclass ignored);
 121 
 122 JNIEXPORT jlong JNICALL
 123 JVM_GetNanoTimeAdjustment(JNIEnv *env, jclass ignored, jlong offset_secs);
 124 
 125 JNIEXPORT void JNICALL
 126 JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos,
 127               jobject dst, jint dst_pos, jint length);
 128 
 129 JNIEXPORT jobject JNICALL
 130 JVM_InitProperties(JNIEnv *env, jobject p);
 131 
 132 /*
 133  * java.lang.Runtime
 134  */
 135 
 136 JNIEXPORT void JNICALL
 137 JVM_Halt(jint code);
 138 
 139 JNIEXPORT void JNICALL
 140 JVM_GC(void);
 141 
 142 /* Returns the number of real-time milliseconds that have elapsed since the
 143  * least-recently-inspected heap object was last inspected by the garbage
 144  * collector.
 145  *
 146  * For simple stop-the-world collectors this value is just the time
 147  * since the most recent collection.  For generational collectors it is the
 148  * time since the oldest generation was most recently collected.  Other
 149  * collectors are free to return a pessimistic estimate of the elapsed time, or
 150  * simply the time since the last full collection was performed.
 151  *
 152  * Note that in the presence of reference objects, a given object that is no
 153  * longer strongly reachable may have to be inspected multiple times before it
 154  * can be reclaimed.
 155  */
 156 JNIEXPORT jlong JNICALL
 157 JVM_MaxObjectInspectionAge(void);
 158 
 159 JNIEXPORT jlong JNICALL
 160 JVM_TotalMemory(void);
 161 
 162 JNIEXPORT jlong JNICALL
 163 JVM_FreeMemory(void);
 164 
 165 JNIEXPORT jlong JNICALL
 166 JVM_MaxMemory(void);
 167 
 168 JNIEXPORT jint JNICALL
 169 JVM_ActiveProcessorCount(void);
 170 
 171 JNIEXPORT void * JNICALL
 172 JVM_LoadLibrary(const char *name);
 173 
 174 JNIEXPORT void JNICALL
 175 JVM_UnloadLibrary(void * handle);
 176 
 177 JNIEXPORT void * JNICALL
 178 JVM_FindLibraryEntry(void *handle, const char *name);
 179 
 180 JNIEXPORT jboolean JNICALL
 181 JVM_IsSupportedJNIVersion(jint version);
 182 
 183 JNIEXPORT jobjectArray JNICALL
 184 JVM_GetVmArguments(JNIEnv *env);
 185 
 186 /*
 187  * java.lang.Throwable
 188  */
 189 JNIEXPORT void JNICALL
 190 JVM_FillInStackTrace(JNIEnv *env, jobject throwable);
 191 
 192 /*
 193  * java.lang.StackTraceElement
 194  */
 195 JNIEXPORT void JNICALL
 196 JVM_InitStackTraceElementArray(JNIEnv *env, jobjectArray elements, jobject throwable);
 197 
 198 JNIEXPORT void JNICALL
 199 JVM_InitStackTraceElement(JNIEnv* env, jobject element, jobject stackFrameInfo);
 200 
 201 /*
 202  * java.lang.StackWalker
 203  */
 204 enum {
 205   JVM_STACKWALK_FILL_CLASS_REFS_ONLY       = 0x02,
 206   JVM_STACKWALK_GET_CALLER_CLASS           = 0x04,
 207   JVM_STACKWALK_SHOW_HIDDEN_FRAMES         = 0x20,
 208   JVM_STACKWALK_FILL_LIVE_STACK_FRAMES     = 0x100
 209 };
 210 
 211 JNIEXPORT jobject JNICALL
 212 JVM_CallStackWalk(JNIEnv *env, jobject stackStream, jlong mode,
 213                   jint skip_frames, jint frame_count, jint start_index,
 214                   jobjectArray frames);
 215 
 216 JNIEXPORT jint JNICALL
 217 JVM_MoreStackWalk(JNIEnv *env, jobject stackStream, jlong mode, jlong anchor,
 218                   jint frame_count, jint start_index,
 219                   jobjectArray frames);
 220 
 221 /*
 222  * java.lang.Thread
 223  */
 224 JNIEXPORT void JNICALL
 225 JVM_StartThread(JNIEnv *env, jobject thread);
 226 
 227 JNIEXPORT void JNICALL
 228 JVM_StopThread(JNIEnv *env, jobject thread, jobject exception);
 229 
 230 JNIEXPORT jboolean JNICALL
 231 JVM_IsThreadAlive(JNIEnv *env, jobject thread);
 232 
 233 JNIEXPORT void JNICALL
 234 JVM_SuspendThread(JNIEnv *env, jobject thread);
 235 
 236 JNIEXPORT void JNICALL
 237 JVM_ResumeThread(JNIEnv *env, jobject thread);
 238 
 239 JNIEXPORT void JNICALL
 240 JVM_SetThreadPriority(JNIEnv *env, jobject thread, jint prio);
 241 
 242 JNIEXPORT void JNICALL
 243 JVM_Yield(JNIEnv *env, jclass threadClass);
 244 
 245 JNIEXPORT void JNICALL
 246 JVM_Sleep(JNIEnv *env, jclass threadClass, jlong millis);
 247 
 248 JNIEXPORT jobject JNICALL
 249 JVM_CurrentThread(JNIEnv *env, jclass threadClass);
 250 
 251 JNIEXPORT jint JNICALL
 252 JVM_CountStackFrames(JNIEnv *env, jobject thread);
 253 
 254 JNIEXPORT void JNICALL
 255 JVM_Interrupt(JNIEnv *env, jobject thread);
 256 
 257 JNIEXPORT jboolean JNICALL
 258 JVM_IsInterrupted(JNIEnv *env, jobject thread, jboolean clearInterrupted);
 259 
 260 JNIEXPORT jboolean JNICALL
 261 JVM_HoldsLock(JNIEnv *env, jclass threadClass, jobject obj);
 262 
 263 JNIEXPORT void JNICALL
 264 JVM_DumpAllStacks(JNIEnv *env, jclass unused);
 265 
 266 JNIEXPORT jobjectArray JNICALL
 267 JVM_GetAllThreads(JNIEnv *env, jclass dummy);
 268 
 269 JNIEXPORT void JNICALL
 270 JVM_SetNativeThreadName(JNIEnv *env, jobject jthread, jstring name);
 271 
 272 /* getStackTrace() and getAllStackTraces() method */
 273 JNIEXPORT jobjectArray JNICALL
 274 JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads);
 275 
 276 /*






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