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