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