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