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