1 /*
   2  * Copyright (c) 1997, 2025, 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_constants.h"
  33 #include "jvm_io.h"
  34 #include "jvm_md.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 jboolean JNICALL
 154 JVM_IsContainerized(void);
 155 
 156 JNIEXPORT void * JNICALL
 157 JVM_LoadZipLibrary();
 158 
 159 JNIEXPORT void * JNICALL
 160 JVM_LoadLibrary(const char *name, jboolean throwException);
 161 
 162 JNIEXPORT void JNICALL
 163 JVM_UnloadLibrary(void * handle);
 164 
 165 JNIEXPORT void * JNICALL
 166 JVM_FindLibraryEntry(void *handle, const char *name);
 167 
 168 JNIEXPORT jboolean JNICALL
 169 JVM_IsSupportedJNIVersion(jint version);
 170 
 171 JNIEXPORT jobjectArray JNICALL
 172 JVM_GetVmArguments(JNIEnv *env);
 173 
 174 JNIEXPORT jboolean JNICALL
 175 JVM_IsPreviewEnabled(void);
 176 
 177 JNIEXPORT jboolean JNICALL
 178 JVM_IsContinuationsSupported(void);
 179 
 180 JNIEXPORT jboolean JNICALL
 181 JVM_IsForeignLinkerSupported(void);
 182 
 183 JNIEXPORT jboolean JNICALL
 184 JVM_IsStaticallyLinked(void);
 185 
 186 JNIEXPORT void JNICALL
 187 JVM_InitializeFromArchive(JNIEnv* env, jclass cls);
 188 
 189 JNIEXPORT void JNICALL
 190 JVM_RegisterLambdaProxyClassForArchiving(JNIEnv* env, jclass caller,
 191                                          jstring interfaceMethodName,
 192                                          jobject factoryType,
 193                                          jobject interfaceMethodType,
 194                                          jobject implementationMember,
 195                                          jobject dynamicMethodType,
 196                                          jclass lambdaProxyClass);
 197 
 198 JNIEXPORT jclass JNICALL
 199 JVM_LookupLambdaProxyClassFromArchive(JNIEnv* env, jclass caller,
 200                                       jstring interfaceMethodName,
 201                                       jobject factoryType,
 202                                       jobject interfaceMethodType,
 203                                       jobject implementationMember,
 204                                       jobject dynamicMethodType);
 205 
 206 JNIEXPORT jint JNICALL
 207 JVM_GetCDSConfigStatus();
 208 
 209 JNIEXPORT jlong JNICALL
 210 JVM_GetRandomSeedForDumping();
 211 
 212 JNIEXPORT void JNICALL
 213 JVM_LogLambdaFormInvoker(JNIEnv* env, jstring line);
 214 
 215 JNIEXPORT void JNICALL
 216 JVM_DumpClassListToFile(JNIEnv* env, jstring fileName);
 217 
 218 JNIEXPORT void JNICALL
 219 JVM_DumpDynamicArchive(JNIEnv* env, jstring archiveName);
 220 
 221 JNIEXPORT jboolean JNICALL
 222 JVM_NeedsClassInitBarrierForCDS(JNIEnv* env, jclass cls);
 223 
 224 /*
 225  * java.lang.Throwable
 226  */
 227 JNIEXPORT void JNICALL
 228 JVM_FillInStackTrace(JNIEnv *env, jobject throwable);
 229 
 230 /*
 231  * java.lang.StackTraceElement
 232  */
 233 JNIEXPORT void JNICALL
 234 JVM_InitStackTraceElementArray(JNIEnv *env, jobjectArray elements, jobject backtrace, jint depth);
 235 
 236 JNIEXPORT void JNICALL
 237 JVM_InitStackTraceElement(JNIEnv* env, jobject element, jobject stackFrameInfo);
 238 
 239 /*
 240  * java.lang.NullPointerException
 241  */
 242 
 243 JNIEXPORT jstring JNICALL
 244 JVM_GetExtendedNPEMessage(JNIEnv *env, jthrowable throwable);
 245 
 246 /*
 247  * java.lang.StackWalker
 248  */
 249 enum {
 250   JVM_STACKWALK_CLASS_INFO_ONLY            = 0x2,
 251   JVM_STACKWALK_SHOW_HIDDEN_FRAMES         = 0x20,
 252   JVM_STACKWALK_FILL_LIVE_STACK_FRAMES     = 0x100
 253 };
 254 
 255 JNIEXPORT void JNICALL
 256 JVM_ExpandStackFrameInfo(JNIEnv *env, jobject obj);
 257 
 258 JNIEXPORT jobject JNICALL
 259 JVM_CallStackWalk(JNIEnv *env, jobject stackStream, jint mode,
 260                   jint skip_frames, jobject contScope, jobject cont,
 261                   jint buffer_size, jint start_index, jobjectArray frames);
 262 
 263 JNIEXPORT jint JNICALL
 264 JVM_MoreStackWalk(JNIEnv *env, jobject stackStream, jint mode, jlong anchor,
 265                   jint last_batch_count, jint buffer_size, jint start_index,
 266                   jobjectArray frames);
 267 
 268 JNIEXPORT void JNICALL
 269 JVM_SetStackWalkContinuation(JNIEnv *env, jobject stackStream, jlong anchor, jobjectArray frames, jobject cont);
 270 
 271 /*
 272  * java.lang.Thread
 273  */
 274 JNIEXPORT void JNICALL
 275 JVM_StartThread(JNIEnv *env, jobject thread);
 276 
 277 JNIEXPORT void JNICALL
 278 JVM_SetThreadPriority(JNIEnv *env, jobject thread, jint prio);
 279 
 280 JNIEXPORT void JNICALL
 281 JVM_Yield(JNIEnv *env, jclass threadClass);
 282 
 283 JNIEXPORT void JNICALL
 284 JVM_SleepNanos(JNIEnv *env, jclass threadClass, jlong nanos);
 285 
 286 JNIEXPORT jobject JNICALL
 287 JVM_CurrentCarrierThread(JNIEnv *env, jclass threadClass);
 288 
 289 JNIEXPORT jobject JNICALL
 290 JVM_CurrentThread(JNIEnv *env, jclass threadClass);
 291 
 292 JNIEXPORT void JNICALL
 293 JVM_SetCurrentThread(JNIEnv *env, jobject thisThread, jobject theThread);
 294 
 295 JNIEXPORT void JNICALL
 296 JVM_Interrupt(JNIEnv *env, jobject thread);
 297 
 298 JNIEXPORT jboolean JNICALL
 299 JVM_HoldsLock(JNIEnv *env, jclass threadClass, jobject obj);
 300 
 301 JNIEXPORT jobject JNICALL
 302 JVM_GetStackTrace(JNIEnv *env, jobject thread);
 303 
 304 JNIEXPORT jobject JNICALL
 305 JVM_CreateThreadSnapshot(JNIEnv* env, jobject thread);
 306 
 307 JNIEXPORT jobjectArray JNICALL
 308 JVM_GetAllThreads(JNIEnv *env, jclass dummy);
 309 
 310 JNIEXPORT void JNICALL
 311 JVM_SetNativeThreadName(JNIEnv *env, jobject jthread, jstring name);
 312 
 313 /* getStackTrace() and getAllStackTraces() method */
 314 JNIEXPORT jobjectArray JNICALL
 315 JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads);
 316 
 317 JNIEXPORT jobject JNICALL
 318 JVM_ScopedValueCache(JNIEnv *env, jclass threadClass);
 319 
 320 JNIEXPORT void JNICALL
 321 JVM_SetScopedValueCache(JNIEnv *env, jclass threadClass, jobject theCache);
 322 
 323 JNIEXPORT jobject JNICALL
 324 JVM_FindScopedValueBindings(JNIEnv *env, jclass threadClass);
 325 
 326 JNIEXPORT jlong JNICALL
 327 JVM_GetNextThreadIdOffset(JNIEnv *env, jclass threadClass);
 328 
 329 /*
 330  * jdk.internal.vm.Continuation
 331  */
 332 JNIEXPORT void JNICALL
 333 JVM_RegisterContinuationMethods(JNIEnv *env, jclass cls);
 334 
 335 /*
 336  * java.lang.Package
 337  */
 338 JNIEXPORT jstring JNICALL
 339 JVM_GetSystemPackage(JNIEnv *env, jstring name);
 340 
 341 JNIEXPORT jobjectArray JNICALL
 342 JVM_GetSystemPackages(JNIEnv *env);
 343 
 344 /*
 345  * java.lang.ref.Reference
 346  */
 347 JNIEXPORT jobject JNICALL
 348 JVM_GetAndClearReferencePendingList(JNIEnv *env);
 349 
 350 JNIEXPORT jboolean JNICALL
 351 JVM_HasReferencePendingList(JNIEnv *env);
 352 
 353 JNIEXPORT void JNICALL
 354 JVM_WaitForReferencePendingList(JNIEnv *env);
 355 
 356 JNIEXPORT jobject JNICALL
 357 JVM_ReferenceGet(JNIEnv *env, jobject ref);
 358 
 359 JNIEXPORT jboolean JNICALL
 360 JVM_ReferenceRefersTo(JNIEnv *env, jobject ref, jobject o);
 361 
 362 JNIEXPORT void JNICALL
 363 JVM_ReferenceClear(JNIEnv *env, jobject ref);
 364 
 365 /*
 366  * java.lang.ref.PhantomReference
 367  */
 368 JNIEXPORT jboolean JNICALL
 369 JVM_PhantomReferenceRefersTo(JNIEnv *env, jobject ref, jobject o);
 370 
 371 /*
 372  * java.io.ObjectInputStream
 373  */
 374 JNIEXPORT jobject JNICALL
 375 JVM_LatestUserDefinedLoader(JNIEnv *env);
 376 
 377 /*
 378  * java.lang.reflect.Array
 379  */
 380 JNIEXPORT jint JNICALL
 381 JVM_GetArrayLength(JNIEnv *env, jobject arr);
 382 
 383 JNIEXPORT jobject JNICALL
 384 JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index);
 385 
 386 JNIEXPORT jvalue JNICALL
 387 JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode);
 388 
 389 JNIEXPORT void JNICALL
 390 JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val);
 391 
 392 JNIEXPORT void JNICALL
 393 JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v,
 394                              unsigned char vCode);
 395 
 396 JNIEXPORT jobject JNICALL
 397 JVM_NewArray(JNIEnv *env, jclass eltClass, jint length);
 398 
 399 JNIEXPORT jobject JNICALL
 400 JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim);
 401 
 402 
 403 /*
 404  * Returns the immediate caller class of the native method invoking
 405  * JVM_GetCallerClass.  The Method.invoke and other frames due to
 406  * reflection machinery are skipped.
 407  *
 408  * The caller is expected to be marked with
 409  * jdk.internal.reflect.CallerSensitive. The JVM will throw an
 410  * error if it is not marked properly.
 411  */
 412 JNIEXPORT jclass JNICALL
 413 JVM_GetCallerClass(JNIEnv *env);
 414 
 415 
 416 /*
 417  * Find primitive classes
 418  * utf: class name
 419  */
 420 JNIEXPORT jclass JNICALL
 421 JVM_FindPrimitiveClass(JNIEnv *env, const char *utf);
 422 
 423 
 424 /*
 425  * Find a class from a boot class loader. Returns null if class not found.
 426  */
 427 JNIEXPORT jclass JNICALL
 428 JVM_FindClassFromBootLoader(JNIEnv *env, const char *name);
 429 
 430 /*
 431  * Find a class from a given class loader.  Throws ClassNotFoundException.
 432  *  name:   name of class
 433  *  init:   whether initialization is done
 434  *  loader: class loader to look up the class. This may not be the same as the caller's
 435  *          class loader.
 436  */
 437 JNIEXPORT jclass JNICALL
 438 JVM_FindClassFromLoader(JNIEnv *env, const char *name, jboolean init,
 439                         jobject loader);
 440 
 441 /*
 442  * Find a class from a given class.
 443  */
 444 JNIEXPORT jclass JNICALL
 445 JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init,
 446                              jclass from);
 447 
 448 /* Find a loaded class cached by the VM */
 449 JNIEXPORT jclass JNICALL
 450 JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name);
 451 
 452 /* Define a class */
 453 JNIEXPORT jclass JNICALL
 454 JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf,
 455                 jsize len, jobject pd);
 456 
 457 /* Define a class with a source (added in JDK1.5) */
 458 JNIEXPORT jclass JNICALL
 459 JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader,
 460                           const jbyte *buf, jsize len, jobject pd,
 461                           const char *source);
 462 
 463 /*
 464  * Define a class with the specified lookup class.
 465  *  lookup:  Lookup class
 466  *  name:    the name of the class
 467  *  buf:     class bytes
 468  *  len:     length of class bytes
 469  *  pd:      protection domain
 470  *  init:    initialize the class
 471  *  flags:   properties of the class
 472  *  classData: private static pre-initialized field; may be null
 473  */
 474 JNIEXPORT jclass JNICALL
 475 JVM_LookupDefineClass(JNIEnv *env, jclass lookup, const char *name, const jbyte *buf,
 476                       jsize len, jobject pd, jboolean init, int flags, jobject classData);
 477 
 478 /*
 479  * Module support functions
 480  */
 481 
 482 /*
 483  * Define a module with the specified packages and bind the module to the
 484  * given class loader.
 485  *  module:       module to define
 486  *  is_open:      specifies if module is open (currently ignored)
 487  *  version:      the module version
 488  *  location:     the module location
 489  *  packages:     array of packages in the module
 490  */
 491 JNIEXPORT void JNICALL
 492 JVM_DefineModule(JNIEnv *env, jobject module, jboolean is_open, jstring version,
 493                  jstring location, jobjectArray packages);
 494 
 495 /*
 496  * Set the boot loader's unnamed module.
 497  *  module: boot loader's unnamed module
 498  */
 499 JNIEXPORT void JNICALL
 500 JVM_SetBootLoaderUnnamedModule(JNIEnv *env, jobject module);
 501 
 502 /*
 503  * Do a qualified export of a package.
 504  *  from_module: module containing the package to export
 505  *  package:     name of the package to export
 506  *  to_module:   module to export the package to
 507  */
 508 JNIEXPORT void JNICALL
 509 JVM_AddModuleExports(JNIEnv *env, jobject from_module, jstring package, jobject to_module);
 510 
 511 /*
 512  * Do an export of a package to all unnamed modules.
 513  *  from_module: module containing the package to export
 514  *  package:     name of the package to export to all unnamed modules
 515  */
 516 JNIEXPORT void JNICALL
 517 JVM_AddModuleExportsToAllUnnamed(JNIEnv *env, jobject from_module, jstring package);
 518 
 519 /*
 520  * Do an unqualified export of a package.
 521  *  from_module: module containing the package to export
 522  *  package:     name of the package to export
 523  */
 524 JNIEXPORT void JNICALL
 525 JVM_AddModuleExportsToAll(JNIEnv *env, jobject from_module, jstring package);
 526 
 527 /*
 528  * Add a module to the list of modules that a given module can read.
 529  *  from_module:   module requesting read access
 530  *  source_module: module that from_module wants to read
 531  */
 532 JNIEXPORT void JNICALL
 533 JVM_AddReadsModule(JNIEnv *env, jobject from_module, jobject source_module);
 534 
 535 /*
 536  * Define all modules that have been stored in the CDS archived heap.
 537  *  platform_loader: the built-in platform class loader
 538  *  system_loader:   the built-in system class loader
 539  */
 540 JNIEXPORT void JNICALL
 541 JVM_DefineArchivedModules(JNIEnv *env, jobject platform_loader, jobject system_loader);
 542 
 543 /*
 544  * Reflection support functions
 545  */
 546 
 547 JNIEXPORT jstring JNICALL
 548 JVM_InitClassName(JNIEnv *env, jclass cls);
 549 
 550 JNIEXPORT jobjectArray JNICALL
 551 JVM_GetClassInterfaces(JNIEnv *env, jclass cls);
 552 
 553 JNIEXPORT jboolean JNICALL
 554 JVM_IsInterface(JNIEnv *env, jclass cls);
 555 
 556 JNIEXPORT jboolean JNICALL
 557 JVM_IsHiddenClass(JNIEnv *env, jclass cls);
 558 
 559 JNIEXPORT jobjectArray JNICALL
 560 JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass);
 561 
 562 JNIEXPORT jclass JNICALL
 563 JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass);
 564 
 565 JNIEXPORT jstring JNICALL
 566 JVM_GetSimpleBinaryName(JNIEnv *env, jclass ofClass);
 567 
 568 /* Generics support (JDK 1.5) */
 569 JNIEXPORT jstring JNICALL
 570 JVM_GetClassSignature(JNIEnv *env, jclass cls);
 571 
 572 /* Annotations support (JDK 1.5) */
 573 JNIEXPORT jbyteArray JNICALL
 574 JVM_GetClassAnnotations(JNIEnv *env, jclass cls);
 575 
 576 /* Type use annotations support (JDK 1.8) */
 577 
 578 JNIEXPORT jbyteArray JNICALL
 579 JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls);
 580 
 581 JNIEXPORT jbyteArray JNICALL
 582 JVM_GetFieldTypeAnnotations(JNIEnv *env, jobject field);
 583 
 584 JNIEXPORT jbyteArray JNICALL
 585 JVM_GetMethodTypeAnnotations(JNIEnv *env, jobject method);
 586 
 587 /*
 588  * New (JDK 1.4) reflection implementation
 589  */
 590 
 591 JNIEXPORT jobjectArray JNICALL
 592 JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly);
 593 
 594 JNIEXPORT jobjectArray JNICALL
 595 JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly);
 596 
 597 JNIEXPORT jobjectArray JNICALL
 598 JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly);
 599 
 600 /* Nestmates - since JDK 11 */
 601 
 602 JNIEXPORT jboolean JNICALL
 603 JVM_AreNestMates(JNIEnv *env, jclass current, jclass member);
 604 
 605 JNIEXPORT jclass JNICALL
 606 JVM_GetNestHost(JNIEnv *env, jclass current);
 607 
 608 JNIEXPORT jobjectArray JNICALL
 609 JVM_GetNestMembers(JNIEnv *env, jclass current);
 610 
 611 /* Records - since JDK 16 */
 612 
 613 JNIEXPORT jboolean JNICALL
 614 JVM_IsRecord(JNIEnv *env, jclass cls);
 615 
 616 JNIEXPORT jobjectArray JNICALL
 617 JVM_GetRecordComponents(JNIEnv *env, jclass ofClass);
 618 
 619 /* Sealed classes - since JDK 17 */
 620 
 621 JNIEXPORT jobjectArray JNICALL
 622 JVM_GetPermittedSubclasses(JNIEnv *env, jclass current);
 623 
 624 /* The following two reflection routines are still needed due to startup time issues */
 625 /*
 626  * java.lang.reflect.Method
 627  */
 628 JNIEXPORT jobject JNICALL
 629 JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0);
 630 
 631 /*
 632  * java.lang.reflect.Constructor
 633  */
 634 JNIEXPORT jobject JNICALL
 635 JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0);
 636 
 637 /*
 638  * Constant pool access; currently used to implement reflective access to annotations (JDK 1.5)
 639  */
 640 
 641 JNIEXPORT jobject JNICALL
 642 JVM_GetClassConstantPool(JNIEnv *env, jclass cls);
 643 
 644 JNIEXPORT jint JNICALL JVM_ConstantPoolGetSize
 645 (JNIEnv *env, jobject jcpool);
 646 
 647 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAt
 648 (JNIEnv *env, jobject jcpool, jint index);
 649 
 650 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAtIfLoaded
 651 (JNIEnv *env, jobject jcpool, jint index);
 652 
 653 JNIEXPORT jint JNICALL JVM_ConstantPoolGetClassRefIndexAt
 654 (JNIEnv *env, jobject jcpool, jint index);
 655 
 656 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAt
 657 (JNIEnv *env, jobject jcpool, jint index);
 658 
 659 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAtIfLoaded
 660 (JNIEnv *env, jobject jcpool, jint index);
 661 
 662 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAt
 663 (JNIEnv *env, jobject jcpool, jint index);
 664 
 665 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAtIfLoaded
 666 (JNIEnv *env, jobject jcpool, jint index);
 667 
 668 JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetMemberRefInfoAt
 669 (JNIEnv *env, jobject jcpool, jint index);
 670 
 671 JNIEXPORT jint JNICALL JVM_ConstantPoolGetNameAndTypeRefIndexAt
 672 (JNIEnv *env, jobject jcpool, jint index);
 673 
 674 JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetNameAndTypeRefInfoAt
 675 (JNIEnv *env, jobject jcpool, jint index);
 676 
 677 JNIEXPORT jint JNICALL JVM_ConstantPoolGetIntAt
 678 (JNIEnv *env, jobject jcpool, jint index);
 679 
 680 JNIEXPORT jlong JNICALL JVM_ConstantPoolGetLongAt
 681 (JNIEnv *env, jobject jcpool, jint index);
 682 
 683 JNIEXPORT jfloat JNICALL JVM_ConstantPoolGetFloatAt
 684 (JNIEnv *env, jobject jcpool, jint index);
 685 
 686 JNIEXPORT jdouble JNICALL JVM_ConstantPoolGetDoubleAt
 687 (JNIEnv *env, jobject jcpool, jint index);
 688 
 689 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetStringAt
 690 (JNIEnv *env, jobject jcpool, jint index);
 691 
 692 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetUTF8At
 693 (JNIEnv *env, jobject jcpool, jint index);
 694 
 695 JNIEXPORT jbyte JNICALL JVM_ConstantPoolGetTagAt
 696 (JNIEnv *env, jobject jcpool, jint index);
 697 
 698 /*
 699  * Parameter reflection
 700  */
 701 
 702 JNIEXPORT jobjectArray JNICALL
 703 JVM_GetMethodParameters(JNIEnv *env, jobject method);
 704 
 705 /*
 706  * Ensure that code doing a stackwalk and using javaVFrame::locals() to
 707  * get the value will see a materialized value and not a scalar-replaced
 708  * null value.
 709  */
 710 #define JVM_EnsureMaterializedForStackWalk(env, value) \
 711     do {} while(0) // Nothing to do.  The fact that the value escaped
 712                    // through a native method is enough.
 713 JNIEXPORT void JNICALL
 714 JVM_EnsureMaterializedForStackWalk_func(JNIEnv* env, jobject vthread, jobject value);
 715 
 716 /*
 717  * Signal support, used to implement the shutdown sequence.  Every VM must
 718  * support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts
 719  * (^C) and the latter for external termination (kill, system shutdown, etc.).
 720  * Other platform-dependent signal values may also be supported.
 721  */
 722 
 723 JNIEXPORT void * JNICALL
 724 JVM_RegisterSignal(jint sig, void *handler);
 725 
 726 JNIEXPORT jboolean JNICALL
 727 JVM_RaiseSignal(jint sig);
 728 
 729 JNIEXPORT jint JNICALL
 730 JVM_FindSignal(const char *name);
 731 
 732 /*
 733  * Retrieve the assertion directives for the specified class.
 734  */
 735 JNIEXPORT jboolean JNICALL
 736 JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls);
 737 
 738 /*
 739  * Retrieve the assertion directives from the VM.
 740  */
 741 JNIEXPORT jobject JNICALL
 742 JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused);
 743 
 744 /*
 745  * java.lang.ref.Finalizer
 746  */
 747 JNIEXPORT void JNICALL
 748 JVM_ReportFinalizationComplete(JNIEnv *env, jobject finalizee);
 749 
 750 JNIEXPORT jboolean JNICALL
 751 JVM_IsFinalizationEnabled(JNIEnv *env);
 752 
 753 /*************************************************************************
 754  PART 2: Support for the Verifier and Class File Format Checker
 755  ************************************************************************/
 756 /*
 757  * Return the class name in UTF format. The result is valid
 758  * until JVM_ReleaseUTf is called.
 759  *
 760  * The caller must treat the string as a constant and not modify it
 761  * in any way.
 762  */
 763 JNIEXPORT const char * JNICALL
 764 JVM_GetClassNameUTF(JNIEnv *env, jclass cb);
 765 
 766 /*
 767  * Returns the constant pool types in the buffer provided by "types."
 768  */
 769 JNIEXPORT void JNICALL
 770 JVM_GetClassCPTypes(JNIEnv *env, jclass cb, unsigned char *types);
 771 
 772 /*
 773  * Returns the number of Constant Pool entries.
 774  */
 775 JNIEXPORT jint JNICALL
 776 JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cb);
 777 
 778 /*
 779  * Returns the number of *declared* fields or methods.
 780  */
 781 JNIEXPORT jint JNICALL
 782 JVM_GetClassFieldsCount(JNIEnv *env, jclass cb);
 783 
 784 JNIEXPORT jint JNICALL
 785 JVM_GetClassMethodsCount(JNIEnv *env, jclass cb);
 786 
 787 /*
 788  * Returns the CP indexes of exceptions raised by a given method.
 789  * Places the result in the given buffer.
 790  *
 791  * The method is identified by method_index.
 792  */
 793 JNIEXPORT void JNICALL
 794 JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cb, jint method_index,
 795                                 unsigned short *exceptions);
 796 /*
 797  * Returns the number of exceptions raised by a given method.
 798  * The method is identified by method_index.
 799  */
 800 JNIEXPORT jint JNICALL
 801 JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cb, jint method_index);
 802 
 803 /*
 804  * Returns the byte code sequence of a given method.
 805  * Places the result in the given buffer.
 806  *
 807  * The method is identified by method_index.
 808  */
 809 JNIEXPORT void JNICALL
 810 JVM_GetMethodIxByteCode(JNIEnv *env, jclass cb, jint method_index,
 811                         unsigned char *code);
 812 
 813 /*
 814  * Returns the length of the byte code sequence of a given method.
 815  * The method is identified by method_index.
 816  */
 817 JNIEXPORT jint JNICALL
 818 JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cb, jint method_index);
 819 
 820 /*
 821  * A structure used to a capture exception table entry in a Java method.
 822  */
 823 typedef struct {
 824     jint start_pc;
 825     jint end_pc;
 826     jint handler_pc;
 827     jint catchType;
 828 } JVM_ExceptionTableEntryType;
 829 
 830 /*
 831  * Returns the exception table entry at entry_index of a given method.
 832  * Places the result in the given buffer.
 833  *
 834  * The method is identified by method_index.
 835  */
 836 JNIEXPORT void JNICALL
 837 JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cb, jint method_index,
 838                                    jint entry_index,
 839                                    JVM_ExceptionTableEntryType *entry);
 840 
 841 /*
 842  * Returns the length of the exception table of a given method.
 843  * The method is identified by method_index.
 844  */
 845 JNIEXPORT jint JNICALL
 846 JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cb, int index);
 847 
 848 /*
 849  * Returns the modifiers of a given field.
 850  * The field is identified by field_index.
 851  */
 852 JNIEXPORT jint JNICALL
 853 JVM_GetFieldIxModifiers(JNIEnv *env, jclass cb, int index);
 854 
 855 /*
 856  * Returns the modifiers of a given method.
 857  * The method is identified by method_index.
 858  */
 859 JNIEXPORT jint JNICALL
 860 JVM_GetMethodIxModifiers(JNIEnv *env, jclass cb, int index);
 861 
 862 /*
 863  * Returns the number of local variables of a given method.
 864  * The method is identified by method_index.
 865  */
 866 JNIEXPORT jint JNICALL
 867 JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cb, int index);
 868 
 869 /*
 870  * Returns the number of arguments (including this pointer) of a given method.
 871  * The method is identified by method_index.
 872  */
 873 JNIEXPORT jint JNICALL
 874 JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cb, int index);
 875 
 876 /*
 877  * Returns the maximum amount of stack (in words) used by a given method.
 878  * The method is identified by method_index.
 879  */
 880 JNIEXPORT jint JNICALL
 881 JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cb, int index);
 882 
 883 /*
 884  * Is a given method a constructor.
 885  * The method is identified by method_index.
 886  */
 887 JNIEXPORT jboolean JNICALL
 888 JVM_IsConstructorIx(JNIEnv *env, jclass cb, int index);
 889 
 890 /*
 891  * Is the given method generated by the VM.
 892  * The method is identified by method_index.
 893  */
 894 JNIEXPORT jboolean JNICALL
 895 JVM_IsVMGeneratedMethodIx(JNIEnv *env, jclass cb, int index);
 896 
 897 /*
 898  * Returns the name of a given method in UTF format.
 899  * The result remains valid until JVM_ReleaseUTF is called.
 900  *
 901  * The caller must treat the string as a constant and not modify it
 902  * in any way.
 903  */
 904 JNIEXPORT const char * JNICALL
 905 JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cb, jint index);
 906 
 907 /*
 908  * Returns the signature of a given method in UTF format.
 909  * The result remains valid until JVM_ReleaseUTF is called.
 910  *
 911  * The caller must treat the string as a constant and not modify it
 912  * in any way.
 913  */
 914 JNIEXPORT const char * JNICALL
 915 JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cb, jint index);
 916 
 917 /*
 918  * Returns the name of the field referred to at a given constant pool
 919  * index.
 920  *
 921  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 922  * is called.
 923  *
 924  * The caller must treat the string as a constant and not modify it
 925  * in any way.
 926  */
 927 JNIEXPORT const char * JNICALL
 928 JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cb, jint index);
 929 
 930 /*
 931  * Returns the name of the method referred to at a given constant pool
 932  * index.
 933  *
 934  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 935  * is called.
 936  *
 937  * The caller must treat the string as a constant and not modify it
 938  * in any way.
 939  */
 940 JNIEXPORT const char * JNICALL
 941 JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cb, jint index);
 942 
 943 /*
 944  * Returns the signature of the method referred to at a given constant pool
 945  * index.
 946  *
 947  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 948  * is called.
 949  *
 950  * The caller must treat the string as a constant and not modify it
 951  * in any way.
 952  */
 953 JNIEXPORT const char * JNICALL
 954 JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cb, jint index);
 955 
 956 /*
 957  * Returns the signature of the field referred to at a given constant pool
 958  * index.
 959  *
 960  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 961  * is called.
 962  *
 963  * The caller must treat the string as a constant and not modify it
 964  * in any way.
 965  */
 966 JNIEXPORT const char * JNICALL
 967 JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cb, jint index);
 968 
 969 /*
 970  * Returns the class name referred to at a given constant pool index.
 971  *
 972  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 973  * is called.
 974  *
 975  * The caller must treat the string as a constant and not modify it
 976  * in any way.
 977  */
 978 JNIEXPORT const char * JNICALL
 979 JVM_GetCPClassNameUTF(JNIEnv *env, jclass cb, jint index);
 980 
 981 /*
 982  * Returns the class name referred to at a given constant pool index.
 983  *
 984  * The constant pool entry must refer to a CONSTANT_Fieldref.
 985  *
 986  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 987  * is called.
 988  *
 989  * The caller must treat the string as a constant and not modify it
 990  * in any way.
 991  */
 992 JNIEXPORT const char * JNICALL
 993 JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cb, jint index);
 994 
 995 /*
 996  * Returns the class name referred to at a given constant pool index.
 997  *
 998  * The constant pool entry must refer to CONSTANT_Methodref or
 999  * CONSTANT_InterfaceMethodref.
1000  *
1001  * The result is in UTF format and remains valid until JVM_ReleaseUTF
1002  * is called.
1003  *
1004  * The caller must treat the string as a constant and not modify it
1005  * in any way.
1006  */
1007 JNIEXPORT const char * JNICALL
1008 JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cb, jint index);
1009 
1010 /*
1011  * Returns the modifiers of a field in calledClass. The field is
1012  * referred to in class cb at constant pool entry index.
1013  *
1014  * The caller must treat the string as a constant and not modify it
1015  * in any way.
1016  *
1017  * Returns -1 if the field does not exist in calledClass.
1018  */
1019 JNIEXPORT jint JNICALL
1020 JVM_GetCPFieldModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
1021 
1022 /*
1023  * Returns the modifiers of a method in calledClass. The method is
1024  * referred to in class cb at constant pool entry index.
1025  *
1026  * Returns -1 if the method does not exist in calledClass.
1027  */
1028 JNIEXPORT jint JNICALL
1029 JVM_GetCPMethodModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
1030 
1031 /*
1032  * Releases the UTF string obtained from the VM.
1033  */
1034 JNIEXPORT void JNICALL
1035 JVM_ReleaseUTF(const char *utf);
1036 
1037 /*
1038  * Compare if two classes are in the same package.
1039  */
1040 JNIEXPORT jboolean JNICALL
1041 JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2);
1042 
1043 
1044 /*************************************************************************
1045  PART 3: I/O and Network Support
1046  ************************************************************************/
1047 
1048 /*
1049  * Convert a pathname into native format.  This function does syntactic
1050  * cleanup, such as removing redundant separator characters.  It modifies
1051  * the given pathname string in place.
1052  */
1053 JNIEXPORT char * JNICALL
1054 JVM_NativePath(char *);
1055 
1056 JNIEXPORT void * JNICALL
1057 JVM_RawMonitorCreate(void);
1058 
1059 JNIEXPORT void JNICALL
1060 JVM_RawMonitorDestroy(void *mon);
1061 
1062 JNIEXPORT jint JNICALL
1063 JVM_RawMonitorEnter(void *mon);
1064 
1065 JNIEXPORT void JNICALL
1066 JVM_RawMonitorExit(void *mon);
1067 
1068 /*
1069  * java.lang.management support
1070  */
1071 JNIEXPORT void* JNICALL
1072 JVM_GetManagement(jint version);
1073 
1074 /*
1075  * com.sun.tools.attach.VirtualMachine support
1076  *
1077  * Initialize the agent properties with the properties maintained in the VM.
1078  */
1079 JNIEXPORT jobject JNICALL
1080 JVM_InitAgentProperties(JNIEnv *env, jobject agent_props);
1081 
1082 JNIEXPORT jstring JNICALL
1083 JVM_GetTemporaryDirectory(JNIEnv *env);
1084 
1085 /* Generics reflection support.
1086  *
1087  * Returns information about the given class's EnclosingMethod
1088  * attribute, if present, or null if the class had no enclosing
1089  * method.
1090  *
1091  * If non-null, the returned array contains three elements. Element 0
1092  * is the java.lang.Class of which the enclosing method is a member,
1093  * and elements 1 and 2 are the java.lang.Strings for the enclosing
1094  * method's name and descriptor, respectively.
1095  */
1096 JNIEXPORT jobjectArray JNICALL
1097 JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass);
1098 
1099 /*
1100  * Virtual thread support.
1101  */
1102 JNIEXPORT void JNICALL
1103 JVM_VirtualThreadStart(JNIEnv* env, jobject vthread);
1104 
1105 JNIEXPORT void JNICALL
1106 JVM_VirtualThreadEnd(JNIEnv* env, jobject vthread);
1107 
1108 JNIEXPORT void JNICALL
1109 JVM_VirtualThreadMount(JNIEnv* env, jobject vthread, jboolean hide);
1110 
1111 JNIEXPORT void JNICALL
1112 JVM_VirtualThreadUnmount(JNIEnv* env, jobject vthread, jboolean hide);
1113 
1114 JNIEXPORT void JNICALL
1115 JVM_VirtualThreadDisableSuspend(JNIEnv* env, jclass clazz, jboolean enter);
1116 
1117 JNIEXPORT void JNICALL
1118 JVM_VirtualThreadPinnedEvent(JNIEnv* env, jclass clazz, jstring op);
1119 
1120 JNIEXPORT jobject JNICALL
1121 JVM_TakeVirtualThreadListToUnblock(JNIEnv* env, jclass ignored);
1122 
1123 /*
1124  * Core reflection support.
1125  */
1126 JNIEXPORT jint JNICALL
1127 JVM_GetClassFileVersion(JNIEnv *env, jclass current);
1128 
1129 /*
1130  * Return JNI_TRUE if warnings are printed when agents are dynamically loaded.
1131  */
1132 JNIEXPORT jboolean JNICALL
1133 JVM_PrintWarningAtDynamicAgentLoad(void);
1134 
1135 /*
1136  * This structure is used by the launcher to get the default thread
1137  * stack size from the VM using JNI_GetDefaultJavaVMInitArgs() with a
1138  * version of 1.1.  As it is not supported otherwise, it has been removed
1139  * from jni.h
1140  */
1141 typedef struct JDK1_1InitArgs {
1142     jint version;
1143 
1144     char **properties;
1145     jint checkSource;
1146     jint nativeStackSize;
1147     jint javaStackSize;
1148     jint minHeapSize;
1149     jint maxHeapSize;
1150     jint verifyMode;
1151     char *classpath;
1152 
1153     jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args);
1154     void (JNICALL *exit)(jint code);
1155     void (JNICALL *abort)(void);
1156 
1157     jint enableClassGC;
1158     jint enableVerboseGC;
1159     jint disableAsyncGC;
1160     jint verbose;
1161     jboolean debugging;
1162     jint debugPort;
1163 } JDK1_1InitArgs;
1164 
1165 
1166 #ifdef __cplusplus
1167 } /* extern "C" */
1168 
1169 #endif /* __cplusplus */
1170 
1171 #endif /* !_JAVASOFT_JVM_H_ */