1 /*
   2  * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #ifndef _JAVASOFT_JVM_H_
  27 #define _JAVASOFT_JVM_H_
  28 
  29 #include <sys/stat.h>
  30 
  31 #include "jni.h"
  32 #include "jvm_md.h"
  33 #include "jvm_constants.h"
  34 #include "jvm_io.h"
  35 
  36 #ifdef __cplusplus
  37 extern "C" {
  38 #endif
  39 
  40 /*
  41  * This file contains additional functions exported from the VM.
  42  * These functions are complementary to the standard JNI support.
  43  * There are three parts to this file:
  44  *
  45  * First, this file contains the VM-related functions needed by native
  46  * libraries in the standard Java API. For example, the java.lang.Object
  47  * class needs VM-level functions that wait for and notify monitors.
  48  *
  49  * Second, (included from jvm_constants.h) constant definitions
  50  * needed by the byte code verifier and class file format checker.
  51  * These definitions allow the verifier and format checker to be written
  52  * in a VM-independent way.
  53  *
  54  * Third, this file contains various I/O and network operations needed
  55  * by the standard Java I/O and network APIs. A part of these APIs,
  56  * namely the jio_xxxprintf functions, are included from jvm_io.h.
  57  */
  58 
  59 
  60 /*************************************************************************
  61  PART 1: Functions for Native Libraries
  62  ************************************************************************/
  63 /*
  64  * java.lang.Object
  65  */
  66 JNIEXPORT jint JNICALL
  67 JVM_IHashCode(JNIEnv *env, jobject obj);
  68 
  69 JNIEXPORT void JNICALL
  70 JVM_MonitorWait(JNIEnv *env, jobject obj, jlong ms);
  71 
  72 JNIEXPORT void JNICALL
  73 JVM_MonitorNotify(JNIEnv *env, jobject obj);
  74 
  75 JNIEXPORT void JNICALL
  76 JVM_MonitorNotifyAll(JNIEnv *env, jobject obj);
  77 
  78 JNIEXPORT jobject JNICALL
  79 JVM_Clone(JNIEnv *env, jobject obj);
  80 
  81 /*
  82  * java.lang.String
  83  */
  84 JNIEXPORT jstring JNICALL
  85 JVM_InternString(JNIEnv *env, jstring str);
  86 
  87 /*
  88  * java.lang.System
  89  */
  90 JNIEXPORT jlong JNICALL
  91 JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored);
  92 
  93 JNIEXPORT jlong JNICALL
  94 JVM_NanoTime(JNIEnv *env, jclass ignored);
  95 
  96 JNIEXPORT jlong JNICALL
  97 JVM_GetNanoTimeAdjustment(JNIEnv *env, jclass ignored, jlong offset_secs);
  98 
  99 JNIEXPORT void JNICALL
 100 JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos,
 101               jobject dst, jint dst_pos, jint length);
 102 
 103 /*
 104  * Return an array of all properties as alternating name and value pairs.
 105  */
 106 JNIEXPORT jobjectArray JNICALL
 107 JVM_GetProperties(JNIEnv *env);
 108 
 109 /*
 110  * java.lang.Runtime
 111  */
 112 JNIEXPORT void JNICALL
 113 JVM_BeforeHalt();
 114 
 115 JNIEXPORT void JNICALL
 116 JVM_Halt(jint code);
 117 
 118 JNIEXPORT void JNICALL
 119 JVM_GC(void);
 120 
 121 /* Returns the number of real-time milliseconds that have elapsed since the
 122  * least-recently-inspected heap object was last inspected by the garbage
 123  * collector.
 124  *
 125  * For simple stop-the-world collectors this value is just the time
 126  * since the most recent collection.  For generational collectors it is the
 127  * time since the oldest generation was most recently collected.  Other
 128  * collectors are free to return a pessimistic estimate of the elapsed time, or
 129  * simply the time since the last full collection was performed.
 130  *
 131  * Note that in the presence of reference objects, a given object that is no
 132  * longer strongly reachable may have to be inspected multiple times before it
 133  * can be reclaimed.
 134  */
 135 JNIEXPORT jlong JNICALL
 136 JVM_MaxObjectInspectionAge(void);
 137 
 138 JNIEXPORT jlong JNICALL
 139 JVM_TotalMemory(void);
 140 
 141 JNIEXPORT jlong JNICALL
 142 JVM_FreeMemory(void);
 143 
 144 JNIEXPORT jlong JNICALL
 145 JVM_MaxMemory(void);
 146 
 147 JNIEXPORT jint JNICALL
 148 JVM_ActiveProcessorCount(void);
 149 
 150 JNIEXPORT jboolean JNICALL
 151 JVM_IsUseContainerSupport(void);
 152 
 153 JNIEXPORT void * JNICALL
 154 JVM_LoadLibrary(const char *name, jboolean throwException);
 155 
 156 JNIEXPORT void JNICALL
 157 JVM_UnloadLibrary(void * handle);
 158 
 159 JNIEXPORT void * JNICALL
 160 JVM_FindLibraryEntry(void *handle, const char *name);
 161 
 162 JNIEXPORT jboolean JNICALL
 163 JVM_IsSupportedJNIVersion(jint version);
 164 
 165 JNIEXPORT jobjectArray JNICALL
 166 JVM_GetVmArguments(JNIEnv *env);
 167 
 168 JNIEXPORT void JNICALL
 169 JVM_InitializeFromArchive(JNIEnv* env, jclass cls);
 170 
 171 JNIEXPORT void JNICALL
 172 JVM_RegisterLambdaProxyClassForArchiving(JNIEnv* env, jclass caller,
 173                                          jstring interfaceMethodName,
 174                                          jobject factoryType,
 175                                          jobject interfaceMethodType,
 176                                          jobject implementationMember,
 177                                          jobject dynamicMethodType,
 178                                          jclass lambdaProxyClass);
 179 
 180 JNIEXPORT jclass JNICALL
 181 JVM_LookupLambdaProxyClassFromArchive(JNIEnv* env, jclass caller,
 182                                       jstring interfaceMethodName,
 183                                       jobject factoryType,
 184                                       jobject interfaceMethodType,
 185                                       jobject implementationMember,
 186                                       jobject dynamicMethodType);
 187 
 188 JNIEXPORT jboolean JNICALL
 189 JVM_IsCDSDumpingEnabled(JNIEnv* env);
 190 
 191 JNIEXPORT jboolean JNICALL
 192 JVM_IsSharingEnabled(JNIEnv* env);
 193 
 194 JNIEXPORT jboolean JNICALL
 195 JVM_IsDumpingClassList(JNIEnv* env);
 196 
 197 JNIEXPORT jlong JNICALL
 198 JVM_GetRandomSeedForDumping();
 199 
 200 JNIEXPORT void JNICALL
 201 JVM_LogLambdaFormInvoker(JNIEnv* env, jstring line);
 202 
 203 JNIEXPORT void JNICALL
 204 JVM_DumpClassListToFile(JNIEnv* env, jstring fileName);
 205 
 206 JNIEXPORT void JNICALL
 207 JVM_DumpDynamicArchive(JNIEnv* env, jstring archiveName);
 208 
 209 /*
 210  * java.lang.Throwable
 211  */
 212 JNIEXPORT void JNICALL
 213 JVM_FillInStackTrace(JNIEnv *env, jobject throwable);
 214 
 215 /*
 216  * java.lang.StackTraceElement
 217  */
 218 JNIEXPORT void JNICALL
 219 JVM_InitStackTraceElementArray(JNIEnv *env, jobjectArray elements, jobject throwable);
 220 
 221 JNIEXPORT void JNICALL
 222 JVM_InitStackTraceElement(JNIEnv* env, jobject element, jobject stackFrameInfo);
 223 
 224 /*
 225  * java.lang.NullPointerException
 226  */
 227 
 228 JNIEXPORT jstring JNICALL
 229 JVM_GetExtendedNPEMessage(JNIEnv *env, jthrowable throwable);
 230 
 231 /*
 232  * java.lang.StackWalker
 233  */
 234 enum {
 235   JVM_STACKWALK_FILL_CLASS_REFS_ONLY       = 0x2,
 236   JVM_STACKWALK_GET_CALLER_CLASS           = 0x04,
 237   JVM_STACKWALK_SHOW_HIDDEN_FRAMES         = 0x20,
 238   JVM_STACKWALK_FILL_LIVE_STACK_FRAMES     = 0x100
 239 };
 240 
 241 JNIEXPORT jobject JNICALL
 242 JVM_CallStackWalk(JNIEnv *env, jobject stackStream, jlong mode,
 243                   jint skip_frames, jint frame_count, jint start_index,
 244                   jobjectArray frames);









 245 
 246 JNIEXPORT jint JNICALL
 247 JVM_MoreStackWalk(JNIEnv *env, jobject stackStream, jlong mode, jlong anchor,
 248                   jint frame_count, jint start_index,
 249                   jobjectArray frames);
 250 



 251 /*
 252  * java.lang.Thread
 253  */
 254 JNIEXPORT void JNICALL
 255 JVM_StartThread(JNIEnv *env, jobject thread);
 256 
 257 JNIEXPORT void JNICALL
 258 JVM_StopThread(JNIEnv *env, jobject thread, jobject exception);
 259 
 260 JNIEXPORT jboolean JNICALL
 261 JVM_IsThreadAlive(JNIEnv *env, jobject thread);
 262 
 263 JNIEXPORT void JNICALL
 264 JVM_SuspendThread(JNIEnv *env, jobject thread);
 265 
 266 JNIEXPORT void JNICALL
 267 JVM_ResumeThread(JNIEnv *env, jobject thread);
 268 
 269 JNIEXPORT void JNICALL
 270 JVM_SetThreadPriority(JNIEnv *env, jobject thread, jint prio);
 271 
 272 JNIEXPORT void JNICALL
 273 JVM_Yield(JNIEnv *env, jclass threadClass);
 274 
 275 JNIEXPORT void JNICALL
 276 JVM_Sleep(JNIEnv *env, jclass threadClass, jlong millis);
 277 



 278 JNIEXPORT jobject JNICALL
 279 JVM_CurrentThread(JNIEnv *env, jclass threadClass);
 280 
 281 JNIEXPORT void JNICALL
 282 JVM_Interrupt(JNIEnv *env, jobject thread);
 283 
 284 JNIEXPORT jboolean JNICALL
 285 JVM_HoldsLock(JNIEnv *env, jclass threadClass, jobject obj);
 286 



 287 JNIEXPORT void JNICALL
 288 JVM_DumpAllStacks(JNIEnv *env, jclass unused);
 289 
 290 JNIEXPORT jobjectArray JNICALL
 291 JVM_GetAllThreads(JNIEnv *env, jclass dummy);
 292 
 293 JNIEXPORT void JNICALL
 294 JVM_SetNativeThreadName(JNIEnv *env, jobject jthread, jstring name);
 295 
 296 /* getStackTrace() and getAllStackTraces() method */
 297 JNIEXPORT jobjectArray JNICALL
 298 JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads);
 299 






 300 /*
 301  * java.lang.SecurityManager
 302  */
 303 JNIEXPORT jobjectArray JNICALL
 304 JVM_GetClassContext(JNIEnv *env);
 305 
 306 /*
 307  * java.lang.Package
 308  */
 309 JNIEXPORT jstring JNICALL
 310 JVM_GetSystemPackage(JNIEnv *env, jstring name);
 311 
 312 JNIEXPORT jobjectArray JNICALL
 313 JVM_GetSystemPackages(JNIEnv *env);
 314 
 315 /*
 316  * java.lang.ref.Reference
 317  */
 318 JNIEXPORT jobject JNICALL
 319 JVM_GetAndClearReferencePendingList(JNIEnv *env);
 320 
 321 JNIEXPORT jboolean JNICALL
 322 JVM_HasReferencePendingList(JNIEnv *env);
 323 
 324 JNIEXPORT void JNICALL
 325 JVM_WaitForReferencePendingList(JNIEnv *env);
 326 
 327 JNIEXPORT jboolean JNICALL
 328 JVM_ReferenceRefersTo(JNIEnv *env, jobject ref, jobject o);
 329 
 330 JNIEXPORT void JNICALL
 331 JVM_ReferenceClear(JNIEnv *env, jobject ref);
 332 
 333 /*
 334  * java.lang.ref.PhantomReference
 335  */
 336 JNIEXPORT jboolean JNICALL
 337 JVM_PhantomReferenceRefersTo(JNIEnv *env, jobject ref, jobject o);
 338 
 339 /*
 340  * java.io.ObjectInputStream
 341  */
 342 JNIEXPORT jobject JNICALL
 343 JVM_LatestUserDefinedLoader(JNIEnv *env);
 344 
 345 /*
 346  * java.lang.reflect.Array
 347  */
 348 JNIEXPORT jint JNICALL
 349 JVM_GetArrayLength(JNIEnv *env, jobject arr);
 350 
 351 JNIEXPORT jobject JNICALL
 352 JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index);
 353 
 354 JNIEXPORT jvalue JNICALL
 355 JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode);
 356 
 357 JNIEXPORT void JNICALL
 358 JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val);
 359 
 360 JNIEXPORT void JNICALL
 361 JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v,
 362                              unsigned char vCode);
 363 
 364 JNIEXPORT jobject JNICALL
 365 JVM_NewArray(JNIEnv *env, jclass eltClass, jint length);
 366 
 367 JNIEXPORT jobject JNICALL
 368 JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim);
 369 
 370 
 371 /*
 372  * Returns the immediate caller class of the native method invoking
 373  * JVM_GetCallerClass.  The Method.invoke and other frames due to
 374  * reflection machinery are skipped.
 375  *
 376  * The caller is expected to be marked with
 377  * jdk.internal.reflect.CallerSensitive. The JVM will throw an
 378  * error if it is not marked properly.
 379  */
 380 JNIEXPORT jclass JNICALL
 381 JVM_GetCallerClass(JNIEnv *env);
 382 
 383 
 384 /*
 385  * Find primitive classes
 386  * utf: class name
 387  */
 388 JNIEXPORT jclass JNICALL
 389 JVM_FindPrimitiveClass(JNIEnv *env, const char *utf);
 390 
 391 
 392 /*
 393  * Find a class from a boot class loader. Returns NULL if class not found.
 394  */
 395 JNIEXPORT jclass JNICALL
 396 JVM_FindClassFromBootLoader(JNIEnv *env, const char *name);
 397 
 398 /*
 399  * Find a class from a given class loader.  Throws ClassNotFoundException.
 400  *  name:   name of class
 401  *  init:   whether initialization is done
 402  *  loader: class loader to look up the class. This may not be the same as the caller's
 403  *          class loader.
 404  *  caller: initiating class. The initiating class may be null when a security
 405  *          manager is not installed.
 406  */
 407 JNIEXPORT jclass JNICALL
 408 JVM_FindClassFromCaller(JNIEnv *env, const char *name, jboolean init,
 409                         jobject loader, jclass caller);
 410 
 411 /*
 412  * Find a class from a given class.
 413  */
 414 JNIEXPORT jclass JNICALL
 415 JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init,
 416                              jclass from);
 417 
 418 /* Find a loaded class cached by the VM */
 419 JNIEXPORT jclass JNICALL
 420 JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name);
 421 
 422 /* Define a class */
 423 JNIEXPORT jclass JNICALL
 424 JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf,
 425                 jsize len, jobject pd);
 426 
 427 /* Define a class with a source (added in JDK1.5) */
 428 JNIEXPORT jclass JNICALL
 429 JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader,
 430                           const jbyte *buf, jsize len, jobject pd,
 431                           const char *source);
 432 
 433 /*
 434  * Define a class with the specified lookup class.
 435  *  lookup:  Lookup class
 436  *  name:    the name of the class
 437  *  buf:     class bytes
 438  *  len:     length of class bytes
 439  *  pd:      protection domain
 440  *  init:    initialize the class
 441  *  flags:   properties of the class
 442  *  classData: private static pre-initialized field; may be null
 443  */
 444 JNIEXPORT jclass JNICALL
 445 JVM_LookupDefineClass(JNIEnv *env, jclass lookup, const char *name, const jbyte *buf,
 446                       jsize len, jobject pd, jboolean init, int flags, jobject classData);
 447 
 448 /*
 449  * Module support funcions
 450  */
 451 
 452 /*
 453  * Define a module with the specified packages and bind the module to the
 454  * given class loader.
 455  *  module:       module to define
 456  *  is_open:      specifies if module is open (currently ignored)
 457  *  version:      the module version
 458  *  location:     the module location
 459  *  packages:     array of packages in the module
 460  */
 461 JNIEXPORT void JNICALL
 462 JVM_DefineModule(JNIEnv *env, jobject module, jboolean is_open, jstring version,
 463                  jstring location, jobjectArray packages);
 464 
 465 /*
 466  * Set the boot loader's unnamed module.
 467  *  module: boot loader's unnamed module
 468  */
 469 JNIEXPORT void JNICALL
 470 JVM_SetBootLoaderUnnamedModule(JNIEnv *env, jobject module);
 471 
 472 /*
 473  * Do a qualified export of a package.
 474  *  from_module: module containing the package to export
 475  *  package:     name of the package to export
 476  *  to_module:   module to export the package to
 477  */
 478 JNIEXPORT void JNICALL
 479 JVM_AddModuleExports(JNIEnv *env, jobject from_module, jstring package, jobject to_module);
 480 
 481 /*
 482  * Do an export of a package to all unnamed modules.
 483  *  from_module: module containing the package to export
 484  *  package:     name of the package to export to all unnamed modules
 485  */
 486 JNIEXPORT void JNICALL
 487 JVM_AddModuleExportsToAllUnnamed(JNIEnv *env, jobject from_module, jstring package);
 488 
 489 /*
 490  * Do an unqualified export of a package.
 491  *  from_module: module containing the package to export
 492  *  package:     name of the package to export
 493  */
 494 JNIEXPORT void JNICALL
 495 JVM_AddModuleExportsToAll(JNIEnv *env, jobject from_module, jstring package);
 496 
 497 /*
 498  * Add a module to the list of modules that a given module can read.
 499  *  from_module:   module requesting read access
 500  *  source_module: module that from_module wants to read
 501  */
 502 JNIEXPORT void JNICALL
 503 JVM_AddReadsModule(JNIEnv *env, jobject from_module, jobject source_module);
 504 
 505 /*
 506  * Define all modules that have been stored in the CDS archived heap.
 507  *  platform_loader: the built-in platform class loader
 508  *  system_loader:   the built-in system class loader
 509  */
 510 JNIEXPORT void JNICALL
 511 JVM_DefineArchivedModules(JNIEnv *env, jobject platform_loader, jobject system_loader);
 512 
 513 /*
 514  * Reflection support functions
 515  */
 516 
 517 JNIEXPORT jstring JNICALL
 518 JVM_InitClassName(JNIEnv *env, jclass cls);
 519 
 520 JNIEXPORT jobjectArray JNICALL
 521 JVM_GetClassInterfaces(JNIEnv *env, jclass cls);
 522 
 523 JNIEXPORT jboolean JNICALL
 524 JVM_IsInterface(JNIEnv *env, jclass cls);
 525 
 526 JNIEXPORT jobjectArray JNICALL
 527 JVM_GetClassSigners(JNIEnv *env, jclass cls);
 528 
 529 JNIEXPORT void JNICALL
 530 JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers);
 531 
 532 JNIEXPORT jobject JNICALL
 533 JVM_GetProtectionDomain(JNIEnv *env, jclass cls);
 534 
 535 JNIEXPORT jboolean JNICALL
 536 JVM_IsArrayClass(JNIEnv *env, jclass cls);
 537 
 538 JNIEXPORT jboolean JNICALL
 539 JVM_IsPrimitiveClass(JNIEnv *env, jclass cls);
 540 
 541 JNIEXPORT jboolean JNICALL
 542 JVM_IsHiddenClass(JNIEnv *env, jclass cls);
 543 
 544 JNIEXPORT jint JNICALL
 545 JVM_GetClassModifiers(JNIEnv *env, jclass cls);
 546 
 547 JNIEXPORT jobjectArray JNICALL
 548 JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass);
 549 
 550 JNIEXPORT jclass JNICALL
 551 JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass);
 552 
 553 JNIEXPORT jstring JNICALL
 554 JVM_GetSimpleBinaryName(JNIEnv *env, jclass ofClass);
 555 
 556 /* Generics support (JDK 1.5) */
 557 JNIEXPORT jstring JNICALL
 558 JVM_GetClassSignature(JNIEnv *env, jclass cls);
 559 
 560 /* Annotations support (JDK 1.5) */
 561 JNIEXPORT jbyteArray JNICALL
 562 JVM_GetClassAnnotations(JNIEnv *env, jclass cls);
 563 
 564 /* Type use annotations support (JDK 1.8) */
 565 
 566 JNIEXPORT jbyteArray JNICALL
 567 JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls);
 568 
 569 JNIEXPORT jbyteArray JNICALL
 570 JVM_GetFieldTypeAnnotations(JNIEnv *env, jobject field);
 571 
 572 JNIEXPORT jbyteArray JNICALL
 573 JVM_GetMethodTypeAnnotations(JNIEnv *env, jobject method);
 574 
 575 /*
 576  * New (JDK 1.4) reflection implementation
 577  */
 578 
 579 JNIEXPORT jobjectArray JNICALL
 580 JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly);
 581 
 582 JNIEXPORT jobjectArray JNICALL
 583 JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly);
 584 
 585 JNIEXPORT jobjectArray JNICALL
 586 JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly);
 587 
 588 
 589 /* Differs from JVM_GetClassModifiers in treatment of inner classes.
 590    This returns the access flags for the class as specified in the
 591    class file rather than searching the InnerClasses attribute (if
 592    present) to find the source-level access flags. Only the values of
 593    the low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be
 594    valid. */
 595 JNIEXPORT jint JNICALL
 596 JVM_GetClassAccessFlags(JNIEnv *env, jclass cls);
 597 
 598 /* Nestmates - since JDK 11 */
 599 
 600 JNIEXPORT jboolean JNICALL
 601 JVM_AreNestMates(JNIEnv *env, jclass current, jclass member);
 602 
 603 JNIEXPORT jclass JNICALL
 604 JVM_GetNestHost(JNIEnv *env, jclass current);
 605 
 606 JNIEXPORT jobjectArray JNICALL
 607 JVM_GetNestMembers(JNIEnv *env, jclass current);
 608 
 609 /* Records - since JDK 16 */
 610 
 611 JNIEXPORT jboolean JNICALL
 612 JVM_IsRecord(JNIEnv *env, jclass cls);
 613 
 614 JNIEXPORT jobjectArray JNICALL
 615 JVM_GetRecordComponents(JNIEnv *env, jclass ofClass);
 616 
 617 /* Sealed classes - since JDK 17 */
 618 
 619 JNIEXPORT jobjectArray JNICALL
 620 JVM_GetPermittedSubclasses(JNIEnv *env, jclass current);
 621 
 622 /* The following two reflection routines are still needed due to startup time issues */
 623 /*
 624  * java.lang.reflect.Method
 625  */
 626 JNIEXPORT jobject JNICALL
 627 JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0);
 628 
 629 /*
 630  * java.lang.reflect.Constructor
 631  */
 632 JNIEXPORT jobject JNICALL
 633 JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0);
 634 
 635 /*
 636  * Constant pool access; currently used to implement reflective access to annotations (JDK 1.5)
 637  */
 638 
 639 JNIEXPORT jobject JNICALL
 640 JVM_GetClassConstantPool(JNIEnv *env, jclass cls);
 641 
 642 JNIEXPORT jint JNICALL JVM_ConstantPoolGetSize
 643 (JNIEnv *env, jobject unused, jobject jcpool);
 644 
 645 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAt
 646 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 647 
 648 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAtIfLoaded
 649 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 650 
 651 JNIEXPORT jint JNICALL JVM_ConstantPoolGetClassRefIndexAt
 652 (JNIEnv *env, jobject obj, jobject unused, jint index);
 653 
 654 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAt
 655 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 656 
 657 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAtIfLoaded
 658 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 659 
 660 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAt
 661 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 662 
 663 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAtIfLoaded
 664 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 665 
 666 JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetMemberRefInfoAt
 667 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 668 
 669 JNIEXPORT jint JNICALL JVM_ConstantPoolGetNameAndTypeRefIndexAt
 670 (JNIEnv *env, jobject obj, jobject unused, jint index);
 671 
 672 JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetNameAndTypeRefInfoAt
 673 (JNIEnv *env, jobject obj, jobject unused, jint index);
 674 
 675 JNIEXPORT jint JNICALL JVM_ConstantPoolGetIntAt
 676 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 677 
 678 JNIEXPORT jlong JNICALL JVM_ConstantPoolGetLongAt
 679 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 680 
 681 JNIEXPORT jfloat JNICALL JVM_ConstantPoolGetFloatAt
 682 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 683 
 684 JNIEXPORT jdouble JNICALL JVM_ConstantPoolGetDoubleAt
 685 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 686 
 687 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetStringAt
 688 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 689 
 690 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetUTF8At
 691 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 692 
 693 JNIEXPORT jbyte JNICALL JVM_ConstantPoolGetTagAt
 694 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 695 
 696 /*
 697  * Parameter reflection
 698  */
 699 
 700 JNIEXPORT jobjectArray JNICALL
 701 JVM_GetMethodParameters(JNIEnv *env, jobject method);
 702 
 703 /*
 704  * java.security.*
 705  */
 706 
 707 JNIEXPORT jobject JNICALL
 708 JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls);
 709 
 710 /*
 711  * Ensure that code doing a stackwalk and using javaVFrame::locals() to
 712  * get the value will see a materialized value and not a scalar-replaced
 713  * null value.
 714  */
 715 #define JVM_EnsureMaterializedForStackWalk(env, value) \
 716     do {} while(0) // Nothing to do.  The fact that the value escaped
 717                    // through a native method is enough.
 718 
 719 JNIEXPORT jobject JNICALL
 720 JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls);
 721 
 722 /*
 723  * Signal support, used to implement the shutdown sequence.  Every VM must
 724  * support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts
 725  * (^C) and the latter for external termination (kill, system shutdown, etc.).
 726  * Other platform-dependent signal values may also be supported.
 727  */
 728 
 729 JNIEXPORT void * JNICALL
 730 JVM_RegisterSignal(jint sig, void *handler);
 731 
 732 JNIEXPORT jboolean JNICALL
 733 JVM_RaiseSignal(jint sig);
 734 
 735 JNIEXPORT jint JNICALL
 736 JVM_FindSignal(const char *name);
 737 
 738 /*
 739  * Retrieve the assertion directives for the specified class.
 740  */
 741 JNIEXPORT jboolean JNICALL
 742 JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls);
 743 
 744 /*
 745  * Retrieve the assertion directives from the VM.
 746  */
 747 JNIEXPORT jobject JNICALL
 748 JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused);
 749 
 750 /*
 751  * java.util.concurrent.atomic.AtomicLong
 752  */
 753 JNIEXPORT jboolean JNICALL
 754 JVM_SupportsCX8(void);
 755 
 756 /*
 757  * java.lang.ref.Finalizer
 758  */
 759 JNIEXPORT void JNICALL
 760 JVM_ReportFinalizationComplete(JNIEnv *env, jobject finalizee);
 761 
 762 /*************************************************************************
 763  PART 2: Support for the Verifier and Class File Format Checker
 764  ************************************************************************/
 765 /*
 766  * Return the class name in UTF format. The result is valid
 767  * until JVM_ReleaseUTf is called.
 768  *
 769  * The caller must treat the string as a constant and not modify it
 770  * in any way.
 771  */
 772 JNIEXPORT const char * JNICALL
 773 JVM_GetClassNameUTF(JNIEnv *env, jclass cb);
 774 
 775 /*
 776  * Returns the constant pool types in the buffer provided by "types."
 777  */
 778 JNIEXPORT void JNICALL
 779 JVM_GetClassCPTypes(JNIEnv *env, jclass cb, unsigned char *types);
 780 
 781 /*
 782  * Returns the number of Constant Pool entries.
 783  */
 784 JNIEXPORT jint JNICALL
 785 JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cb);
 786 
 787 /*
 788  * Returns the number of *declared* fields or methods.
 789  */
 790 JNIEXPORT jint JNICALL
 791 JVM_GetClassFieldsCount(JNIEnv *env, jclass cb);
 792 
 793 JNIEXPORT jint JNICALL
 794 JVM_GetClassMethodsCount(JNIEnv *env, jclass cb);
 795 
 796 /*
 797  * Returns the CP indexes of exceptions raised by a given method.
 798  * Places the result in the given buffer.
 799  *
 800  * The method is identified by method_index.
 801  */
 802 JNIEXPORT void JNICALL
 803 JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cb, jint method_index,
 804                                 unsigned short *exceptions);
 805 /*
 806  * Returns the number of exceptions raised by a given method.
 807  * The method is identified by method_index.
 808  */
 809 JNIEXPORT jint JNICALL
 810 JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cb, jint method_index);
 811 
 812 /*
 813  * Returns the byte code sequence of a given method.
 814  * Places the result in the given buffer.
 815  *
 816  * The method is identified by method_index.
 817  */
 818 JNIEXPORT void JNICALL
 819 JVM_GetMethodIxByteCode(JNIEnv *env, jclass cb, jint method_index,
 820                         unsigned char *code);
 821 
 822 /*
 823  * Returns the length of the byte code sequence of a given method.
 824  * The method is identified by method_index.
 825  */
 826 JNIEXPORT jint JNICALL
 827 JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cb, jint method_index);
 828 
 829 /*
 830  * A structure used to a capture exception table entry in a Java method.
 831  */
 832 typedef struct {
 833     jint start_pc;
 834     jint end_pc;
 835     jint handler_pc;
 836     jint catchType;
 837 } JVM_ExceptionTableEntryType;
 838 
 839 /*
 840  * Returns the exception table entry at entry_index of a given method.
 841  * Places the result in the given buffer.
 842  *
 843  * The method is identified by method_index.
 844  */
 845 JNIEXPORT void JNICALL
 846 JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cb, jint method_index,
 847                                    jint entry_index,
 848                                    JVM_ExceptionTableEntryType *entry);
 849 
 850 /*
 851  * Returns the length of the exception table of a given method.
 852  * The method is identified by method_index.
 853  */
 854 JNIEXPORT jint JNICALL
 855 JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cb, int index);
 856 
 857 /*
 858  * Returns the modifiers of a given field.
 859  * The field is identified by field_index.
 860  */
 861 JNIEXPORT jint JNICALL
 862 JVM_GetFieldIxModifiers(JNIEnv *env, jclass cb, int index);
 863 
 864 /*
 865  * Returns the modifiers of a given method.
 866  * The method is identified by method_index.
 867  */
 868 JNIEXPORT jint JNICALL
 869 JVM_GetMethodIxModifiers(JNIEnv *env, jclass cb, int index);
 870 
 871 /*
 872  * Returns the number of local variables of a given method.
 873  * The method is identified by method_index.
 874  */
 875 JNIEXPORT jint JNICALL
 876 JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cb, int index);
 877 
 878 /*
 879  * Returns the number of arguments (including this pointer) of a given method.
 880  * The method is identified by method_index.
 881  */
 882 JNIEXPORT jint JNICALL
 883 JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cb, int index);
 884 
 885 /*
 886  * Returns the maximum amount of stack (in words) used by a given method.
 887  * The method is identified by method_index.
 888  */
 889 JNIEXPORT jint JNICALL
 890 JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cb, int index);
 891 
 892 /*
 893  * Is a given method a constructor.
 894  * The method is identified by method_index.
 895  */
 896 JNIEXPORT jboolean JNICALL
 897 JVM_IsConstructorIx(JNIEnv *env, jclass cb, int index);
 898 
 899 /*
 900  * Is the given method generated by the VM.
 901  * The method is identified by method_index.
 902  */
 903 JNIEXPORT jboolean JNICALL
 904 JVM_IsVMGeneratedMethodIx(JNIEnv *env, jclass cb, int index);
 905 
 906 /*
 907  * Returns the name of a given method in UTF format.
 908  * The result remains valid until JVM_ReleaseUTF is called.
 909  *
 910  * The caller must treat the string as a constant and not modify it
 911  * in any way.
 912  */
 913 JNIEXPORT const char * JNICALL
 914 JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cb, jint index);
 915 
 916 /*
 917  * Returns the signature of a given method in UTF format.
 918  * The result remains valid until JVM_ReleaseUTF is called.
 919  *
 920  * The caller must treat the string as a constant and not modify it
 921  * in any way.
 922  */
 923 JNIEXPORT const char * JNICALL
 924 JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cb, jint index);
 925 
 926 /*
 927  * Returns the name of the field referred to at a given constant pool
 928  * index.
 929  *
 930  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 931  * is called.
 932  *
 933  * The caller must treat the string as a constant and not modify it
 934  * in any way.
 935  */
 936 JNIEXPORT const char * JNICALL
 937 JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cb, jint index);
 938 
 939 /*
 940  * Returns the name of the method referred to at a given constant pool
 941  * index.
 942  *
 943  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 944  * is called.
 945  *
 946  * The caller must treat the string as a constant and not modify it
 947  * in any way.
 948  */
 949 JNIEXPORT const char * JNICALL
 950 JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cb, jint index);
 951 
 952 /*
 953  * Returns the signature of the method referred to at a given constant pool
 954  * index.
 955  *
 956  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 957  * is called.
 958  *
 959  * The caller must treat the string as a constant and not modify it
 960  * in any way.
 961  */
 962 JNIEXPORT const char * JNICALL
 963 JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cb, jint index);
 964 
 965 /*
 966  * Returns the signature of the field referred to at a given constant pool
 967  * index.
 968  *
 969  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 970  * is called.
 971  *
 972  * The caller must treat the string as a constant and not modify it
 973  * in any way.
 974  */
 975 JNIEXPORT const char * JNICALL
 976 JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cb, jint index);
 977 
 978 /*
 979  * Returns the class name referred to at a given constant pool index.
 980  *
 981  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 982  * is called.
 983  *
 984  * The caller must treat the string as a constant and not modify it
 985  * in any way.
 986  */
 987 JNIEXPORT const char * JNICALL
 988 JVM_GetCPClassNameUTF(JNIEnv *env, jclass cb, jint index);
 989 
 990 /*
 991  * Returns the class name referred to at a given constant pool index.
 992  *
 993  * The constant pool entry must refer to a CONSTANT_Fieldref.
 994  *
 995  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 996  * is called.
 997  *
 998  * The caller must treat the string as a constant and not modify it
 999  * in any way.
1000  */
1001 JNIEXPORT const char * JNICALL
1002 JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cb, jint index);
1003 
1004 /*
1005  * Returns the class name referred to at a given constant pool index.
1006  *
1007  * The constant pool entry must refer to CONSTANT_Methodref or
1008  * CONSTANT_InterfaceMethodref.
1009  *
1010  * The result is in UTF format and remains valid until JVM_ReleaseUTF
1011  * is called.
1012  *
1013  * The caller must treat the string as a constant and not modify it
1014  * in any way.
1015  */
1016 JNIEXPORT const char * JNICALL
1017 JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cb, jint index);
1018 
1019 /*
1020  * Returns the modifiers of a field in calledClass. The field is
1021  * referred to in class cb at constant pool entry index.
1022  *
1023  * The caller must treat the string as a constant and not modify it
1024  * in any way.
1025  *
1026  * Returns -1 if the field does not exist in calledClass.
1027  */
1028 JNIEXPORT jint JNICALL
1029 JVM_GetCPFieldModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
1030 
1031 /*
1032  * Returns the modifiers of a method in calledClass. The method is
1033  * referred to in class cb at constant pool entry index.
1034  *
1035  * Returns -1 if the method does not exist in calledClass.
1036  */
1037 JNIEXPORT jint JNICALL
1038 JVM_GetCPMethodModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
1039 
1040 /*
1041  * Releases the UTF string obtained from the VM.
1042  */
1043 JNIEXPORT void JNICALL
1044 JVM_ReleaseUTF(const char *utf);
1045 
1046 /*
1047  * Compare if two classes are in the same package.
1048  */
1049 JNIEXPORT jboolean JNICALL
1050 JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2);
1051 
1052 
1053 /*************************************************************************
1054  PART 3: I/O and Network Support
1055  ************************************************************************/
1056 
1057 /*
1058  * Convert a pathname into native format.  This function does syntactic
1059  * cleanup, such as removing redundant separator characters.  It modifies
1060  * the given pathname string in place.
1061  */
1062 JNIEXPORT char * JNICALL
1063 JVM_NativePath(char *);
1064 
1065 JNIEXPORT void * JNICALL
1066 JVM_RawMonitorCreate(void);
1067 
1068 JNIEXPORT void JNICALL
1069 JVM_RawMonitorDestroy(void *mon);
1070 
1071 JNIEXPORT jint JNICALL
1072 JVM_RawMonitorEnter(void *mon);
1073 
1074 JNIEXPORT void JNICALL
1075 JVM_RawMonitorExit(void *mon);
1076 
1077 /*
1078  * java.lang.management support
1079  */
1080 JNIEXPORT void* JNICALL
1081 JVM_GetManagement(jint version);
1082 
1083 /*
1084  * com.sun.tools.attach.VirtualMachine support
1085  *
1086  * Initialize the agent properties with the properties maintained in the VM.
1087  */
1088 JNIEXPORT jobject JNICALL
1089 JVM_InitAgentProperties(JNIEnv *env, jobject agent_props);
1090 
1091 JNIEXPORT jstring JNICALL
1092 JVM_GetTemporaryDirectory(JNIEnv *env);
1093 
1094 /* Generics reflection support.
1095  *
1096  * Returns information about the given class's EnclosingMethod
1097  * attribute, if present, or null if the class had no enclosing
1098  * method.
1099  *
1100  * If non-null, the returned array contains three elements. Element 0
1101  * is the java.lang.Class of which the enclosing method is a member,
1102  * and elements 1 and 2 are the java.lang.Strings for the enclosing
1103  * method's name and descriptor, respectively.
1104  */
1105 JNIEXPORT jobjectArray JNICALL
1106 JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass);














1107 
1108 /*
1109  * This structure is used by the launcher to get the default thread
1110  * stack size from the VM using JNI_GetDefaultJavaVMInitArgs() with a
1111  * version of 1.1.  As it is not supported otherwise, it has been removed
1112  * from jni.h
1113  */
1114 typedef struct JDK1_1InitArgs {
1115     jint version;
1116 
1117     char **properties;
1118     jint checkSource;
1119     jint nativeStackSize;
1120     jint javaStackSize;
1121     jint minHeapSize;
1122     jint maxHeapSize;
1123     jint verifyMode;
1124     char *classpath;
1125 
1126     jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args);
1127     void (JNICALL *exit)(jint code);
1128     void (JNICALL *abort)(void);
1129 
1130     jint enableClassGC;
1131     jint enableVerboseGC;
1132     jint disableAsyncGC;
1133     jint verbose;
1134     jboolean debugging;
1135     jint debugPort;
1136 } JDK1_1InitArgs;
1137 
1138 
1139 #ifdef __cplusplus
1140 } /* extern "C" */
1141 
1142 #endif /* __cplusplus */
1143 
1144 #endif /* !_JAVASOFT_JVM_H_ */
--- EOF ---