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