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