1 /*
   2  * Copyright (c) 1997, 2023, 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_IsValhallaEnabled(void);
 176 
 177 JNIEXPORT jboolean JNICALL
 178 JVM_IsContinuationsSupported(void);
 179 
 180 JNIEXPORT jboolean JNICALL
 181 JVM_IsForeignLinkerSupported(void);
 182 
 183 JNIEXPORT void JNICALL
 184 JVM_InitializeFromArchive(JNIEnv* env, jclass cls);
 185 
 186 JNIEXPORT void JNICALL
 187 JVM_RegisterLambdaProxyClassForArchiving(JNIEnv* env, jclass caller,
 188                                          jstring interfaceMethodName,
 189                                          jobject factoryType,
 190                                          jobject interfaceMethodType,
 191                                          jobject implementationMember,
 192                                          jobject dynamicMethodType,
 193                                          jclass lambdaProxyClass);
 194 
 195 JNIEXPORT jclass JNICALL
 196 JVM_LookupLambdaProxyClassFromArchive(JNIEnv* env, jclass caller,
 197                                       jstring interfaceMethodName,
 198                                       jobject factoryType,
 199                                       jobject interfaceMethodType,
 200                                       jobject implementationMember,
 201                                       jobject dynamicMethodType);
 202 
 203 JNIEXPORT jboolean JNICALL
 204 JVM_IsCDSDumpingEnabled(JNIEnv* env);
 205 
 206 JNIEXPORT jboolean JNICALL
 207 JVM_IsSharingEnabled(JNIEnv* env);
 208 
 209 JNIEXPORT jboolean JNICALL
 210 JVM_IsDumpingClassList(JNIEnv* env);
 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 /*
 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_FILL_CLASS_REFS_ONLY       = 0x2,
 251   JVM_STACKWALK_GET_CALLER_CLASS           = 0x04,
 252   JVM_STACKWALK_SHOW_HIDDEN_FRAMES         = 0x20,
 253   JVM_STACKWALK_FILL_LIVE_STACK_FRAMES     = 0x100
 254 };
 255 
 256 JNIEXPORT jobject JNICALL
 257 JVM_CallStackWalk(JNIEnv *env, jobject stackStream, jlong mode,
 258                   jint skip_frames, jobject contScope, jobject cont,
 259                   jint frame_count, jint start_index, jobjectArray frames);
 260 
 261 JNIEXPORT jint JNICALL
 262 JVM_MoreStackWalk(JNIEnv *env, jobject stackStream, jlong mode, jlong anchor,
 263                   jint frame_count, jint start_index,
 264                   jobjectArray frames);
 265 
 266 JNIEXPORT void JNICALL
 267 JVM_SetStackWalkContinuation(JNIEnv *env, jobject stackStream, jlong anchor, jobjectArray frames, jobject cont);
 268 
 269 /*
 270  * java.lang.Thread
 271  */
 272 JNIEXPORT void JNICALL
 273 JVM_StartThread(JNIEnv *env, jobject thread);
 274 
 275 JNIEXPORT void JNICALL
 276 JVM_SetThreadPriority(JNIEnv *env, jobject thread, jint prio);
 277 
 278 JNIEXPORT void JNICALL
 279 JVM_Yield(JNIEnv *env, jclass threadClass);
 280 
 281 JNIEXPORT void JNICALL
 282 JVM_SleepNanos(JNIEnv *env, jclass threadClass, jlong nanos);
 283 
 284 JNIEXPORT jobject JNICALL
 285 JVM_CurrentCarrierThread(JNIEnv *env, jclass threadClass);
 286 
 287 JNIEXPORT jobject JNICALL
 288 JVM_CurrentThread(JNIEnv *env, jclass threadClass);
 289 
 290 JNIEXPORT void JNICALL
 291 JVM_SetCurrentThread(JNIEnv *env, jobject thisThread, jobject theThread);
 292 
 293 JNIEXPORT void JNICALL
 294 JVM_Interrupt(JNIEnv *env, jobject thread);
 295 
 296 JNIEXPORT jboolean JNICALL
 297 JVM_HoldsLock(JNIEnv *env, jclass threadClass, jobject obj);
 298 
 299 JNIEXPORT jobject JNICALL
 300 JVM_GetStackTrace(JNIEnv *env, jobject thread);
 301 
 302 JNIEXPORT void JNICALL
 303 JVM_DumpAllStacks(JNIEnv *env, jclass unused);
 304 
 305 JNIEXPORT jobjectArray JNICALL
 306 JVM_GetAllThreads(JNIEnv *env, jclass dummy);
 307 
 308 JNIEXPORT void JNICALL
 309 JVM_SetNativeThreadName(JNIEnv *env, jobject jthread, jstring name);
 310 
 311 /* getStackTrace() and getAllStackTraces() method */
 312 JNIEXPORT jobjectArray JNICALL
 313 JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads);
 314 
 315 JNIEXPORT jobject JNICALL
 316 JVM_ScopedValueCache(JNIEnv *env, jclass threadClass);
 317 
 318 JNIEXPORT void JNICALL
 319 JVM_SetScopedValueCache(JNIEnv *env, jclass threadClass, jobject theCache);
 320 
 321 JNIEXPORT jobject JNICALL
 322 JVM_FindScopedValueBindings(JNIEnv *env, jclass threadClass);
 323 
 324 JNIEXPORT jlong JNICALL
 325 JVM_GetNextThreadIdOffset(JNIEnv *env, jclass threadClass);
 326 
 327 /*
 328  * jdk.internal.vm.Continuation
 329  */
 330 JNIEXPORT void JNICALL
 331 JVM_RegisterContinuationMethods(JNIEnv *env, jclass cls);
 332 
 333 /*
 334  * java.lang.SecurityManager
 335  */
 336 JNIEXPORT jobjectArray JNICALL
 337 JVM_GetClassContext(JNIEnv *env);
 338 
 339 /*
 340  * java.lang.Package
 341  */
 342 JNIEXPORT jstring JNICALL
 343 JVM_GetSystemPackage(JNIEnv *env, jstring name);
 344 
 345 JNIEXPORT jobjectArray JNICALL
 346 JVM_GetSystemPackages(JNIEnv *env);
 347 
 348 /*
 349  * java.lang.ref.Reference
 350  */
 351 JNIEXPORT jobject JNICALL
 352 JVM_GetAndClearReferencePendingList(JNIEnv *env);
 353 
 354 JNIEXPORT jboolean JNICALL
 355 JVM_HasReferencePendingList(JNIEnv *env);
 356 
 357 JNIEXPORT void JNICALL
 358 JVM_WaitForReferencePendingList(JNIEnv *env);
 359 
 360 JNIEXPORT jboolean JNICALL
 361 JVM_ReferenceRefersTo(JNIEnv *env, jobject ref, jobject o);
 362 
 363 JNIEXPORT void JNICALL
 364 JVM_ReferenceClear(JNIEnv *env, jobject ref);
 365 
 366 /*
 367  * java.lang.ref.PhantomReference
 368  */
 369 JNIEXPORT jboolean JNICALL
 370 JVM_PhantomReferenceRefersTo(JNIEnv *env, jobject ref, jobject o);
 371 
 372 /*
 373  * java.io.ObjectInputStream
 374  */
 375 JNIEXPORT jobject JNICALL
 376 JVM_LatestUserDefinedLoader(JNIEnv *env);
 377 
 378 /*
 379  * java.lang.reflect.Array
 380  */
 381 JNIEXPORT jint JNICALL
 382 JVM_GetArrayLength(JNIEnv *env, jobject arr);
 383 
 384 JNIEXPORT jobject JNICALL
 385 JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index);
 386 
 387 JNIEXPORT jvalue JNICALL
 388 JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode);
 389 
 390 JNIEXPORT void JNICALL
 391 JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val);
 392 
 393 JNIEXPORT void JNICALL
 394 JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v,
 395                              unsigned char vCode);
 396 
 397 JNIEXPORT jobject JNICALL
 398 JVM_NewArray(JNIEnv *env, jclass eltClass, jint length);
 399 
 400 JNIEXPORT jobject JNICALL
 401 JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim);
 402 
 403 
 404 /*
 405  * Returns the immediate caller class of the native method invoking
 406  * JVM_GetCallerClass.  The Method.invoke and other frames due to
 407  * reflection machinery are skipped.
 408  *
 409  * The caller is expected to be marked with
 410  * jdk.internal.reflect.CallerSensitive. The JVM will throw an
 411  * error if it is not marked properly.
 412  */
 413 JNIEXPORT jclass JNICALL
 414 JVM_GetCallerClass(JNIEnv *env);
 415 
 416 
 417 /*
 418  * Find primitive classes
 419  * utf: class name
 420  */
 421 JNIEXPORT jclass JNICALL
 422 JVM_FindPrimitiveClass(JNIEnv *env, const char *utf);
 423 
 424 
 425 /*
 426  * Find a class from a boot class loader. Returns nullptr if class not found.
 427  */
 428 JNIEXPORT jclass JNICALL
 429 JVM_FindClassFromBootLoader(JNIEnv *env, const char *name);
 430 
 431 /*
 432  * Find a class from a given class loader.  Throws ClassNotFoundException.
 433  *  name:   name of class
 434  *  init:   whether initialization is done
 435  *  loader: class loader to look up the class. This may not be the same as the caller's
 436  *          class loader.
 437  *  caller: initiating class. The initiating class may be null when a security
 438  *          manager is not installed.
 439  */
 440 JNIEXPORT jclass JNICALL
 441 JVM_FindClassFromCaller(JNIEnv *env, const char *name, jboolean init,
 442                         jobject loader, jclass caller);
 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 jobjectArray JNICALL
 560 JVM_GetClassSigners(JNIEnv *env, jclass cls);
 561 
 562 JNIEXPORT void JNICALL
 563 JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers);
 564 
 565 JNIEXPORT jobject JNICALL
 566 JVM_GetProtectionDomain(JNIEnv *env, jclass cls);
 567 
 568 JNIEXPORT jboolean JNICALL
 569 JVM_IsArrayClass(JNIEnv *env, jclass cls);
 570 
 571 JNIEXPORT jboolean JNICALL
 572 JVM_IsPrimitiveClass(JNIEnv *env, jclass cls);
 573 
 574 JNIEXPORT jboolean JNICALL
 575 JVM_IsHiddenClass(JNIEnv *env, jclass cls);
 576 
 577 JNIEXPORT jboolean JNICALL
 578 JVM_IsIdentityClass(JNIEnv *env, jclass cls);
 579 
 580 JNIEXPORT jint JNICALL
 581 JVM_GetClassModifiers(JNIEnv *env, jclass cls);
 582 
 583 JNIEXPORT jobjectArray JNICALL
 584 JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass);
 585 
 586 JNIEXPORT jclass JNICALL
 587 JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass);
 588 
 589 JNIEXPORT jstring JNICALL
 590 JVM_GetSimpleBinaryName(JNIEnv *env, jclass ofClass);
 591 
 592 /* Generics support (JDK 1.5) */
 593 JNIEXPORT jstring JNICALL
 594 JVM_GetClassSignature(JNIEnv *env, jclass cls);
 595 
 596 /* Annotations support (JDK 1.5) */
 597 JNIEXPORT jbyteArray JNICALL
 598 JVM_GetClassAnnotations(JNIEnv *env, jclass cls);
 599 
 600 /* Type use annotations support (JDK 1.8) */
 601 
 602 JNIEXPORT jbyteArray JNICALL
 603 JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls);
 604 
 605 JNIEXPORT jbyteArray JNICALL
 606 JVM_GetFieldTypeAnnotations(JNIEnv *env, jobject field);
 607 
 608 JNIEXPORT jbyteArray JNICALL
 609 JVM_GetMethodTypeAnnotations(JNIEnv *env, jobject method);
 610 
 611 /*
 612  * New (JDK 1.4) reflection implementation
 613  */
 614 
 615 JNIEXPORT jobjectArray JNICALL
 616 JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly);
 617 
 618 JNIEXPORT jobjectArray JNICALL
 619 JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly);
 620 
 621 JNIEXPORT jobjectArray JNICALL
 622 JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly);
 623 
 624 
 625 /* Differs from JVM_GetClassModifiers in treatment of inner classes.
 626    This returns the access flags for the class as specified in the
 627    class file rather than searching the InnerClasses attribute (if
 628    present) to find the source-level access flags. Only the values of
 629    the low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be
 630    valid. */
 631 JNIEXPORT jint JNICALL
 632 JVM_GetClassAccessFlags(JNIEnv *env, jclass cls);
 633 
 634 /* Nestmates - since JDK 11 */
 635 
 636 JNIEXPORT jboolean JNICALL
 637 JVM_AreNestMates(JNIEnv *env, jclass current, jclass member);
 638 
 639 JNIEXPORT jclass JNICALL
 640 JVM_GetNestHost(JNIEnv *env, jclass current);
 641 
 642 JNIEXPORT jobjectArray JNICALL
 643 JVM_GetNestMembers(JNIEnv *env, jclass current);
 644 
 645 /* Records - since JDK 16 */
 646 
 647 JNIEXPORT jboolean JNICALL
 648 JVM_IsRecord(JNIEnv *env, jclass cls);
 649 
 650 JNIEXPORT jobjectArray JNICALL
 651 JVM_GetRecordComponents(JNIEnv *env, jclass ofClass);
 652 
 653 /* Sealed classes - since JDK 17 */
 654 
 655 JNIEXPORT jobjectArray JNICALL
 656 JVM_GetPermittedSubclasses(JNIEnv *env, jclass current);
 657 
 658 /* The following two reflection routines are still needed due to startup time issues */
 659 /*
 660  * java.lang.reflect.Method
 661  */
 662 JNIEXPORT jobject JNICALL
 663 JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0);
 664 
 665 /*
 666  * java.lang.reflect.Constructor
 667  */
 668 JNIEXPORT jobject JNICALL
 669 JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0);
 670 
 671 /*
 672  * Constant pool access; currently used to implement reflective access to annotations (JDK 1.5)
 673  */
 674 
 675 JNIEXPORT jobject JNICALL
 676 JVM_GetClassConstantPool(JNIEnv *env, jclass cls);
 677 
 678 JNIEXPORT jint JNICALL JVM_ConstantPoolGetSize
 679 (JNIEnv *env, jobject unused, jobject jcpool);
 680 
 681 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAt
 682 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 683 
 684 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAtIfLoaded
 685 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 686 
 687 JNIEXPORT jint JNICALL JVM_ConstantPoolGetClassRefIndexAt
 688 (JNIEnv *env, jobject obj, jobject unused, jint index);
 689 
 690 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAt
 691 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 692 
 693 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAtIfLoaded
 694 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 695 
 696 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAt
 697 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 698 
 699 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAtIfLoaded
 700 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 701 
 702 JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetMemberRefInfoAt
 703 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 704 
 705 JNIEXPORT jint JNICALL JVM_ConstantPoolGetNameAndTypeRefIndexAt
 706 (JNIEnv *env, jobject obj, jobject unused, jint index);
 707 
 708 JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetNameAndTypeRefInfoAt
 709 (JNIEnv *env, jobject obj, jobject unused, jint index);
 710 
 711 JNIEXPORT jint JNICALL JVM_ConstantPoolGetIntAt
 712 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 713 
 714 JNIEXPORT jlong JNICALL JVM_ConstantPoolGetLongAt
 715 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 716 
 717 JNIEXPORT jfloat JNICALL JVM_ConstantPoolGetFloatAt
 718 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 719 
 720 JNIEXPORT jdouble JNICALL JVM_ConstantPoolGetDoubleAt
 721 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 722 
 723 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetStringAt
 724 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 725 
 726 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetUTF8At
 727 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 728 
 729 JNIEXPORT jbyte JNICALL JVM_ConstantPoolGetTagAt
 730 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 731 
 732 /*
 733  * Parameter reflection
 734  */
 735 
 736 JNIEXPORT jobjectArray JNICALL
 737 JVM_GetMethodParameters(JNIEnv *env, jobject method);
 738 
 739 /*
 740  * java.security.*
 741  */
 742 
 743 JNIEXPORT jobject JNICALL
 744 JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls);
 745 
 746 /*
 747  * Ensure that code doing a stackwalk and using javaVFrame::locals() to
 748  * get the value will see a materialized value and not a scalar-replaced
 749  * null value.
 750  */
 751 #define JVM_EnsureMaterializedForStackWalk(env, value) \
 752     do {} while(0) // Nothing to do.  The fact that the value escaped
 753                    // through a native method is enough.
 754 JNIEXPORT void JNICALL
 755 JVM_EnsureMaterializedForStackWalk_func(JNIEnv* env, jobject vthread, jobject value);
 756 
 757 JNIEXPORT jobject JNICALL
 758 JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls);
 759 
 760 /*
 761  * Signal support, used to implement the shutdown sequence.  Every VM must
 762  * support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts
 763  * (^C) and the latter for external termination (kill, system shutdown, etc.).
 764  * Other platform-dependent signal values may also be supported.
 765  */
 766 
 767 JNIEXPORT void * JNICALL
 768 JVM_RegisterSignal(jint sig, void *handler);
 769 
 770 JNIEXPORT jboolean JNICALL
 771 JVM_RaiseSignal(jint sig);
 772 
 773 JNIEXPORT jint JNICALL
 774 JVM_FindSignal(const char *name);
 775 
 776 /*
 777  * Retrieve the assertion directives for the specified class.
 778  */
 779 JNIEXPORT jboolean JNICALL
 780 JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls);
 781 
 782 /*
 783  * Retrieve the assertion directives from the VM.
 784  */
 785 JNIEXPORT jobject JNICALL
 786 JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused);
 787 
 788 /*
 789  * java.util.concurrent.atomic.AtomicLong
 790  */
 791 JNIEXPORT jboolean JNICALL
 792 JVM_SupportsCX8(void);
 793 
 794 /*
 795  * java.lang.ref.Finalizer
 796  */
 797 JNIEXPORT void JNICALL
 798 JVM_ReportFinalizationComplete(JNIEnv *env, jobject finalizee);
 799 
 800 JNIEXPORT jboolean JNICALL
 801 JVM_IsFinalizationEnabled(JNIEnv *env);
 802 
 803 /*************************************************************************
 804  PART 2: Support for the Verifier and Class File Format Checker
 805  ************************************************************************/
 806 /*
 807  * Return the class name in UTF format. The result is valid
 808  * until JVM_ReleaseUTf is called.
 809  *
 810  * The caller must treat the string as a constant and not modify it
 811  * in any way.
 812  */
 813 JNIEXPORT const char * JNICALL
 814 JVM_GetClassNameUTF(JNIEnv *env, jclass cb);
 815 
 816 /*
 817  * Returns the constant pool types in the buffer provided by "types."
 818  */
 819 JNIEXPORT void JNICALL
 820 JVM_GetClassCPTypes(JNIEnv *env, jclass cb, unsigned char *types);
 821 
 822 /*
 823  * Returns the number of Constant Pool entries.
 824  */
 825 JNIEXPORT jint JNICALL
 826 JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cb);
 827 
 828 /*
 829  * Returns the number of *declared* fields or methods.
 830  */
 831 JNIEXPORT jint JNICALL
 832 JVM_GetClassFieldsCount(JNIEnv *env, jclass cb);
 833 
 834 JNIEXPORT jint JNICALL
 835 JVM_GetClassMethodsCount(JNIEnv *env, jclass cb);
 836 
 837 /*
 838  * Returns the CP indexes of exceptions raised by 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_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cb, jint method_index,
 845                                 unsigned short *exceptions);
 846 /*
 847  * Returns the number of exceptions raised by a given method.
 848  * The method is identified by method_index.
 849  */
 850 JNIEXPORT jint JNICALL
 851 JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cb, jint method_index);
 852 
 853 /*
 854  * Returns the byte code sequence of a given method.
 855  * Places the result in the given buffer.
 856  *
 857  * The method is identified by method_index.
 858  */
 859 JNIEXPORT void JNICALL
 860 JVM_GetMethodIxByteCode(JNIEnv *env, jclass cb, jint method_index,
 861                         unsigned char *code);
 862 
 863 /*
 864  * Returns the length of the byte code sequence of a given method.
 865  * The method is identified by method_index.
 866  */
 867 JNIEXPORT jint JNICALL
 868 JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cb, jint method_index);
 869 
 870 /*
 871  * A structure used to a capture exception table entry in a Java method.
 872  */
 873 typedef struct {
 874     jint start_pc;
 875     jint end_pc;
 876     jint handler_pc;
 877     jint catchType;
 878 } JVM_ExceptionTableEntryType;
 879 
 880 /*
 881  * Returns the exception table entry at entry_index of a given method.
 882  * Places the result in the given buffer.
 883  *
 884  * The method is identified by method_index.
 885  */
 886 JNIEXPORT void JNICALL
 887 JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cb, jint method_index,
 888                                    jint entry_index,
 889                                    JVM_ExceptionTableEntryType *entry);
 890 
 891 /*
 892  * Returns the length of the exception table of a given method.
 893  * The method is identified by method_index.
 894  */
 895 JNIEXPORT jint JNICALL
 896 JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cb, int index);
 897 
 898 /*
 899  * Returns the modifiers of a given field.
 900  * The field is identified by field_index.
 901  */
 902 JNIEXPORT jint JNICALL
 903 JVM_GetFieldIxModifiers(JNIEnv *env, jclass cb, int index);
 904 
 905 /*
 906  * Returns the modifiers of a given method.
 907  * The method is identified by method_index.
 908  */
 909 JNIEXPORT jint JNICALL
 910 JVM_GetMethodIxModifiers(JNIEnv *env, jclass cb, int index);
 911 
 912 /*
 913  * Returns the number of local variables of a given method.
 914  * The method is identified by method_index.
 915  */
 916 JNIEXPORT jint JNICALL
 917 JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cb, int index);
 918 
 919 /*
 920  * Returns the number of arguments (including this pointer) of a given method.
 921  * The method is identified by method_index.
 922  */
 923 JNIEXPORT jint JNICALL
 924 JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cb, int index);
 925 
 926 /*
 927  * Returns the maximum amount of stack (in words) used by a given method.
 928  * The method is identified by method_index.
 929  */
 930 JNIEXPORT jint JNICALL
 931 JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cb, int index);
 932 
 933 /*
 934  * Is a given method a constructor.
 935  * The method is identified by method_index.
 936  */
 937 JNIEXPORT jboolean JNICALL
 938 JVM_IsConstructorIx(JNIEnv *env, jclass cb, int index);
 939 
 940 /*
 941  * Is the given method generated by the VM.
 942  * The method is identified by method_index.
 943  */
 944 JNIEXPORT jboolean JNICALL
 945 JVM_IsVMGeneratedMethodIx(JNIEnv *env, jclass cb, int index);
 946 
 947 /*
 948  * Returns the name of a given method in UTF format.
 949  * The result remains valid until JVM_ReleaseUTF is called.
 950  *
 951  * The caller must treat the string as a constant and not modify it
 952  * in any way.
 953  */
 954 JNIEXPORT const char * JNICALL
 955 JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cb, jint index);
 956 
 957 /*
 958  * Returns the signature of a given method in UTF format.
 959  * The result remains valid until JVM_ReleaseUTF is called.
 960  *
 961  * The caller must treat the string as a constant and not modify it
 962  * in any way.
 963  */
 964 JNIEXPORT const char * JNICALL
 965 JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cb, jint index);
 966 
 967 /*
 968  * Returns the name of the field referred to at a given constant pool
 969  * index.
 970  *
 971  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 972  * is called.
 973  *
 974  * The caller must treat the string as a constant and not modify it
 975  * in any way.
 976  */
 977 JNIEXPORT const char * JNICALL
 978 JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cb, jint index);
 979 
 980 /*
 981  * Returns the name of the method referred to at a given constant pool
 982  * index.
 983  *
 984  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 985  * is called.
 986  *
 987  * The caller must treat the string as a constant and not modify it
 988  * in any way.
 989  */
 990 JNIEXPORT const char * JNICALL
 991 JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cb, jint index);
 992 
 993 /*
 994  * Returns the signature of the method referred to at a given constant pool
 995  * index.
 996  *
 997  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 998  * is called.
 999  *
1000  * The caller must treat the string as a constant and not modify it
1001  * in any way.
1002  */
1003 JNIEXPORT const char * JNICALL
1004 JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cb, jint index);
1005 
1006 /*
1007  * Returns the signature of the field referred to at a given constant pool
1008  * index.
1009  *
1010  * The result is in UTF format and remains valid until JVM_ReleaseUTF
1011  * is called.
1012  *
1013  * The caller must treat the string as a constant and not modify it
1014  * in any way.
1015  */
1016 JNIEXPORT const char * JNICALL
1017 JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cb, jint index);
1018 
1019 /*
1020  * Returns the class name referred to at a given constant pool index.
1021  *
1022  * The result is in UTF format and remains valid until JVM_ReleaseUTF
1023  * is called.
1024  *
1025  * The caller must treat the string as a constant and not modify it
1026  * in any way.
1027  */
1028 JNIEXPORT const char * JNICALL
1029 JVM_GetCPClassNameUTF(JNIEnv *env, jclass cb, jint index);
1030 
1031 /*
1032  * Returns the class name referred to at a given constant pool index.
1033  *
1034  * The constant pool entry must refer to a CONSTANT_Fieldref.
1035  *
1036  * The result is in UTF format and remains valid until JVM_ReleaseUTF
1037  * is called.
1038  *
1039  * The caller must treat the string as a constant and not modify it
1040  * in any way.
1041  */
1042 JNIEXPORT const char * JNICALL
1043 JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cb, jint index);
1044 
1045 /*
1046  * Returns the class name referred to at a given constant pool index.
1047  *
1048  * The constant pool entry must refer to CONSTANT_Methodref or
1049  * CONSTANT_InterfaceMethodref.
1050  *
1051  * The result is in UTF format and remains valid until JVM_ReleaseUTF
1052  * is called.
1053  *
1054  * The caller must treat the string as a constant and not modify it
1055  * in any way.
1056  */
1057 JNIEXPORT const char * JNICALL
1058 JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cb, jint index);
1059 
1060 /*
1061  * Returns the modifiers of a field in calledClass. The field is
1062  * referred to in class cb at constant pool entry index.
1063  *
1064  * The caller must treat the string as a constant and not modify it
1065  * in any way.
1066  *
1067  * Returns -1 if the field does not exist in calledClass.
1068  */
1069 JNIEXPORT jint JNICALL
1070 JVM_GetCPFieldModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
1071 
1072 /*
1073  * Returns the modifiers of a method in calledClass. The method is
1074  * referred to in class cb at constant pool entry index.
1075  *
1076  * Returns -1 if the method does not exist in calledClass.
1077  */
1078 JNIEXPORT jint JNICALL
1079 JVM_GetCPMethodModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
1080 
1081 /*
1082  * Releases the UTF string obtained from the VM.
1083  */
1084 JNIEXPORT void JNICALL
1085 JVM_ReleaseUTF(const char *utf);
1086 
1087 /*
1088  * Compare if two classes are in the same package.
1089  */
1090 JNIEXPORT jboolean JNICALL
1091 JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2);
1092 
1093 
1094 /*************************************************************************
1095  PART 3: I/O and Network Support
1096  ************************************************************************/
1097 
1098 /*
1099  * Convert a pathname into native format.  This function does syntactic
1100  * cleanup, such as removing redundant separator characters.  It modifies
1101  * the given pathname string in place.
1102  */
1103 JNIEXPORT char * JNICALL
1104 JVM_NativePath(char *);
1105 
1106 JNIEXPORT void * JNICALL
1107 JVM_RawMonitorCreate(void);
1108 
1109 JNIEXPORT void JNICALL
1110 JVM_RawMonitorDestroy(void *mon);
1111 
1112 JNIEXPORT jint JNICALL
1113 JVM_RawMonitorEnter(void *mon);
1114 
1115 JNIEXPORT void JNICALL
1116 JVM_RawMonitorExit(void *mon);
1117 
1118 /*
1119  * java.lang.management support
1120  */
1121 JNIEXPORT void* JNICALL
1122 JVM_GetManagement(jint version);
1123 
1124 /*
1125  * com.sun.tools.attach.VirtualMachine support
1126  *
1127  * Initialize the agent properties with the properties maintained in the VM.
1128  */
1129 JNIEXPORT jobject JNICALL
1130 JVM_InitAgentProperties(JNIEnv *env, jobject agent_props);
1131 
1132 JNIEXPORT jstring JNICALL
1133 JVM_GetTemporaryDirectory(JNIEnv *env);
1134 
1135 /* Generics reflection support.
1136  *
1137  * Returns information about the given class's EnclosingMethod
1138  * attribute, if present, or null if the class had no enclosing
1139  * method.
1140  *
1141  * If non-null, the returned array contains three elements. Element 0
1142  * is the java.lang.Class of which the enclosing method is a member,
1143  * and elements 1 and 2 are the java.lang.Strings for the enclosing
1144  * method's name and descriptor, respectively.
1145  */
1146 JNIEXPORT jobjectArray JNICALL
1147 JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass);
1148 
1149 /*
1150  * Virtual thread support.
1151  */
1152 JNIEXPORT void JNICALL
1153 JVM_VirtualThreadStart(JNIEnv* env, jobject vthread);
1154 
1155 JNIEXPORT void JNICALL
1156 JVM_VirtualThreadEnd(JNIEnv* env, jobject vthread);
1157 
1158 JNIEXPORT void JNICALL
1159 JVM_VirtualThreadMount(JNIEnv* env, jobject vthread, jboolean hide);
1160 
1161 JNIEXPORT void JNICALL
1162 JVM_VirtualThreadUnmount(JNIEnv* env, jobject vthread, jboolean hide);
1163 
1164 JNIEXPORT void JNICALL
1165 JVM_VirtualThreadHideFrames(JNIEnv* env, jobject vthread, jboolean hide);
1166 
1167 /*
1168  * Core reflection support.
1169  */
1170 JNIEXPORT jint JNICALL
1171 JVM_GetClassFileVersion(JNIEnv *env, jclass current);
1172 
1173 /*
1174  * Return JNI_TRUE if warnings are printed when agents are dynamically loaded.
1175  */
1176 JNIEXPORT jboolean JNICALL
1177 JVM_PrintWarningAtDynamicAgentLoad(void);
1178 
1179 /*
1180  * This structure is used by the launcher to get the default thread
1181  * stack size from the VM using JNI_GetDefaultJavaVMInitArgs() with a
1182  * version of 1.1.  As it is not supported otherwise, it has been removed
1183  * from jni.h
1184  */
1185 typedef struct JDK1_1InitArgs {
1186     jint version;
1187 
1188     char **properties;
1189     jint checkSource;
1190     jint nativeStackSize;
1191     jint javaStackSize;
1192     jint minHeapSize;
1193     jint maxHeapSize;
1194     jint verifyMode;
1195     char *classpath;
1196 
1197     jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args);
1198     void (JNICALL *exit)(jint code);
1199     void (JNICALL *abort)(void);
1200 
1201     jint enableClassGC;
1202     jint enableVerboseGC;
1203     jint disableAsyncGC;
1204     jint verbose;
1205     jboolean debugging;
1206     jint debugPort;
1207 } JDK1_1InitArgs;
1208 
1209 
1210 #ifdef __cplusplus
1211 } /* extern "C" */
1212 
1213 #endif /* __cplusplus */
1214 
1215 #endif /* !_JAVASOFT_JVM_H_ */