1 /*
   2  * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #ifndef _JAVASOFT_JVM_H_
  27 #define _JAVASOFT_JVM_H_
  28 
  29 #include <sys/stat.h>
  30 
  31 #include "jni.h"
  32 #include "jvm_md.h"
  33 #include "jvm_constants.h"
  34 #include "jvm_io.h"
  35 
  36 #ifdef __cplusplus
  37 extern "C" {
  38 #endif
  39 
  40 /*
  41  * This file contains additional functions exported from the VM.
  42  * These functions are complementary to the standard JNI support.
  43  * There are three parts to this file:
  44  *
  45  * First, this file contains the VM-related functions needed by native
  46  * libraries in the standard Java API. For example, the java.lang.Object
  47  * class needs VM-level functions that wait for and notify monitors.
  48  *
  49  * Second, (included from jvm_constants.h) constant definitions
  50  * needed by the byte code verifier and class file format checker.
  51  * These definitions allow the verifier and format checker to be written
  52  * in a VM-independent way.
  53  *
  54  * Third, this file contains various I/O and network operations needed
  55  * by the standard Java I/O and network APIs. A part of these APIs,
  56  * namely the jio_xxxprintf functions, are included from jvm_io.h.
  57  */
  58 
  59 
  60 /*************************************************************************
  61  PART 1: Functions for Native Libraries
  62  ************************************************************************/
  63 /*
  64  * java.lang.Object
  65  */
  66 JNIEXPORT jint JNICALL
  67 JVM_IHashCode(JNIEnv *env, jobject obj);
  68 
  69 JNIEXPORT void JNICALL
  70 JVM_MonitorWait(JNIEnv *env, jobject obj, jlong ms);
  71 
  72 JNIEXPORT void JNICALL
  73 JVM_MonitorNotify(JNIEnv *env, jobject obj);
  74 
  75 JNIEXPORT void JNICALL
  76 JVM_MonitorNotifyAll(JNIEnv *env, jobject obj);
  77 
  78 JNIEXPORT jobject JNICALL
  79 JVM_Clone(JNIEnv *env, jobject obj);
  80 
  81 /*
  82  * java.lang.String
  83  */
  84 JNIEXPORT jstring JNICALL
  85 JVM_InternString(JNIEnv *env, jstring str);
  86 
  87 /*
  88  * java.lang.System
  89  */
  90 JNIEXPORT jlong JNICALL
  91 JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored);
  92 
  93 JNIEXPORT jlong JNICALL
  94 JVM_NanoTime(JNIEnv *env, jclass ignored);
  95 
  96 JNIEXPORT jlong JNICALL
  97 JVM_GetNanoTimeAdjustment(JNIEnv *env, jclass ignored, jlong offset_secs);
  98 
  99 JNIEXPORT void JNICALL
 100 JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos,
 101               jobject dst, jint dst_pos, jint length);
 102 
 103 /*
 104  * Return an array of all properties as alternating name and value pairs.
 105  */
 106 JNIEXPORT jobjectArray JNICALL
 107 JVM_GetProperties(JNIEnv *env);
 108 
 109 /*
 110  * java.lang.Runtime
 111  */
 112 JNIEXPORT void JNICALL
 113 JVM_BeforeHalt();
 114 
 115 JNIEXPORT void JNICALL
 116 JVM_Halt(jint code);
 117 
 118 JNIEXPORT void JNICALL
 119 JVM_GC(void);
 120 
 121 /* Returns the number of real-time milliseconds that have elapsed since the
 122  * least-recently-inspected heap object was last inspected by the garbage
 123  * collector.
 124  *
 125  * For simple stop-the-world collectors this value is just the time
 126  * since the most recent collection.  For generational collectors it is the
 127  * time since the oldest generation was most recently collected.  Other
 128  * collectors are free to return a pessimistic estimate of the elapsed time, or
 129  * simply the time since the last full collection was performed.
 130  *
 131  * Note that in the presence of reference objects, a given object that is no
 132  * longer strongly reachable may have to be inspected multiple times before it
 133  * can be reclaimed.
 134  */
 135 JNIEXPORT jlong JNICALL
 136 JVM_MaxObjectInspectionAge(void);
 137 
 138 JNIEXPORT jlong JNICALL
 139 JVM_TotalMemory(void);
 140 
 141 JNIEXPORT jlong JNICALL
 142 JVM_FreeMemory(void);
 143 
 144 JNIEXPORT jlong JNICALL
 145 JVM_MaxMemory(void);
 146 
 147 JNIEXPORT jint JNICALL
 148 JVM_ActiveProcessorCount(void);
 149 
 150 JNIEXPORT jboolean JNICALL
 151 JVM_IsUseContainerSupport(void);
 152 
 153 JNIEXPORT void * JNICALL
 154 JVM_LoadZipLibrary();
 155 
 156 JNIEXPORT void * JNICALL
 157 JVM_LoadLibrary(const char *name, jboolean throwException);
 158 
 159 JNIEXPORT void JNICALL
 160 JVM_UnloadLibrary(void * handle);
 161 
 162 JNIEXPORT void * JNICALL
 163 JVM_FindLibraryEntry(void *handle, const char *name);
 164 
 165 JNIEXPORT jboolean JNICALL
 166 JVM_IsSupportedJNIVersion(jint version);
 167 
 168 JNIEXPORT jobjectArray JNICALL
 169 JVM_GetVmArguments(JNIEnv *env);
 170 
 171 JNIEXPORT jboolean JNICALL
 172 JVM_IsPreviewEnabled(void);
 173 



 174 JNIEXPORT jboolean JNICALL
 175 JVM_IsContinuationsSupported(void);
 176 
 177 JNIEXPORT jboolean JNICALL
 178 JVM_IsForeignLinkerSupported(void);
 179 
 180 JNIEXPORT void JNICALL
 181 JVM_InitializeFromArchive(JNIEnv* env, jclass cls);
 182 
 183 JNIEXPORT void JNICALL
 184 JVM_RegisterLambdaProxyClassForArchiving(JNIEnv* env, jclass caller,
 185                                          jstring interfaceMethodName,
 186                                          jobject factoryType,
 187                                          jobject interfaceMethodType,
 188                                          jobject implementationMember,
 189                                          jobject dynamicMethodType,
 190                                          jclass lambdaProxyClass);
 191 
 192 JNIEXPORT jclass JNICALL
 193 JVM_LookupLambdaProxyClassFromArchive(JNIEnv* env, jclass caller,
 194                                       jstring interfaceMethodName,
 195                                       jobject factoryType,
 196                                       jobject interfaceMethodType,
 197                                       jobject implementationMember,
 198                                       jobject dynamicMethodType);
 199 
 200 JNIEXPORT 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 void JNICALL
 273 JVM_SetThreadPriority(JNIEnv *env, jobject thread, jint prio);
 274 
 275 JNIEXPORT void JNICALL
 276 JVM_Yield(JNIEnv *env, jclass threadClass);
 277 
 278 JNIEXPORT void JNICALL
 279 JVM_Sleep(JNIEnv *env, jclass threadClass, jlong nanos);
 280 
 281 JNIEXPORT jobject JNICALL
 282 JVM_CurrentCarrierThread(JNIEnv *env, jclass threadClass);
 283 
 284 JNIEXPORT jobject JNICALL
 285 JVM_CurrentThread(JNIEnv *env, jclass threadClass);
 286 
 287 JNIEXPORT void JNICALL
 288 JVM_SetCurrentThread(JNIEnv *env, jobject thisThread, jobject theThread);
 289 
 290 JNIEXPORT void JNICALL
 291 JVM_Interrupt(JNIEnv *env, jobject thread);
 292 
 293 JNIEXPORT jboolean JNICALL
 294 JVM_HoldsLock(JNIEnv *env, jclass threadClass, jobject obj);
 295 
 296 JNIEXPORT jobject JNICALL
 297 JVM_GetStackTrace(JNIEnv *env, jobject thread);
 298 
 299 JNIEXPORT void JNICALL
 300 JVM_DumpAllStacks(JNIEnv *env, jclass unused);
 301 
 302 JNIEXPORT jobjectArray JNICALL
 303 JVM_GetAllThreads(JNIEnv *env, jclass dummy);
 304 
 305 JNIEXPORT void JNICALL
 306 JVM_SetNativeThreadName(JNIEnv *env, jobject jthread, jstring name);
 307 
 308 /* getStackTrace() and getAllStackTraces() method */
 309 JNIEXPORT jobjectArray JNICALL
 310 JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads);
 311 
 312 JNIEXPORT jobject JNICALL
 313 JVM_ScopedValueCache(JNIEnv *env, jclass threadClass);
 314 
 315 JNIEXPORT void JNICALL
 316 JVM_SetScopedValueCache(JNIEnv *env, jclass threadClass, jobject theCache);
 317 
 318 JNIEXPORT jobject JNICALL
 319 JVM_FindScopedValueBindings(JNIEnv *env, jclass threadClass);
 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 jint JNICALL
 575 JVM_GetClassModifiers(JNIEnv *env, jclass cls);
 576 
 577 JNIEXPORT jobjectArray JNICALL
 578 JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass);
 579 
 580 JNIEXPORT jclass JNICALL
 581 JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass);
 582 
 583 JNIEXPORT jstring JNICALL
 584 JVM_GetSimpleBinaryName(JNIEnv *env, jclass ofClass);
 585 
 586 /* Generics support (JDK 1.5) */
 587 JNIEXPORT jstring JNICALL
 588 JVM_GetClassSignature(JNIEnv *env, jclass cls);
 589 
 590 /* Annotations support (JDK 1.5) */
 591 JNIEXPORT jbyteArray JNICALL
 592 JVM_GetClassAnnotations(JNIEnv *env, jclass cls);
 593 
 594 /* Type use annotations support (JDK 1.8) */
 595 
 596 JNIEXPORT jbyteArray JNICALL
 597 JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls);
 598 
 599 JNIEXPORT jbyteArray JNICALL
 600 JVM_GetFieldTypeAnnotations(JNIEnv *env, jobject field);
 601 
 602 JNIEXPORT jbyteArray JNICALL
 603 JVM_GetMethodTypeAnnotations(JNIEnv *env, jobject method);
 604 
 605 /*
 606  * New (JDK 1.4) reflection implementation
 607  */
 608 
 609 JNIEXPORT jobjectArray JNICALL
 610 JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly);
 611 
 612 JNIEXPORT jobjectArray JNICALL
 613 JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly);
 614 
 615 JNIEXPORT jobjectArray JNICALL
 616 JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly);
 617 
 618 
 619 /* Differs from JVM_GetClassModifiers in treatment of inner classes.
 620    This returns the access flags for the class as specified in the
 621    class file rather than searching the InnerClasses attribute (if
 622    present) to find the source-level access flags. Only the values of
 623    the low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be
 624    valid. */
 625 JNIEXPORT jint JNICALL
 626 JVM_GetClassAccessFlags(JNIEnv *env, jclass cls);
 627 
 628 /* Nestmates - since JDK 11 */
 629 
 630 JNIEXPORT jboolean JNICALL
 631 JVM_AreNestMates(JNIEnv *env, jclass current, jclass member);
 632 
 633 JNIEXPORT jclass JNICALL
 634 JVM_GetNestHost(JNIEnv *env, jclass current);
 635 
 636 JNIEXPORT jobjectArray JNICALL
 637 JVM_GetNestMembers(JNIEnv *env, jclass current);
 638 
 639 /* Records - since JDK 16 */
 640 
 641 JNIEXPORT jboolean JNICALL
 642 JVM_IsRecord(JNIEnv *env, jclass cls);
 643 
 644 JNIEXPORT jobjectArray JNICALL
 645 JVM_GetRecordComponents(JNIEnv *env, jclass ofClass);
 646 
 647 /* Sealed classes - since JDK 17 */
 648 
 649 JNIEXPORT jobjectArray JNICALL
 650 JVM_GetPermittedSubclasses(JNIEnv *env, jclass current);
 651 
 652 /* The following two reflection routines are still needed due to startup time issues */
 653 /*
 654  * java.lang.reflect.Method
 655  */
 656 JNIEXPORT jobject JNICALL
 657 JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0);
 658 
 659 /*
 660  * java.lang.reflect.Constructor
 661  */
 662 JNIEXPORT jobject JNICALL
 663 JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0);
 664 
 665 /*
 666  * Constant pool access; currently used to implement reflective access to annotations (JDK 1.5)
 667  */
 668 
 669 JNIEXPORT jobject JNICALL
 670 JVM_GetClassConstantPool(JNIEnv *env, jclass cls);
 671 
 672 JNIEXPORT jint JNICALL JVM_ConstantPoolGetSize
 673 (JNIEnv *env, jobject unused, jobject jcpool);
 674 
 675 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAt
 676 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 677 
 678 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAtIfLoaded
 679 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 680 
 681 JNIEXPORT jint JNICALL JVM_ConstantPoolGetClassRefIndexAt
 682 (JNIEnv *env, jobject obj, jobject unused, jint index);
 683 
 684 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAt
 685 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 686 
 687 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAtIfLoaded
 688 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 689 
 690 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAt
 691 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 692 
 693 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAtIfLoaded
 694 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 695 
 696 JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetMemberRefInfoAt
 697 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 698 
 699 JNIEXPORT jint JNICALL JVM_ConstantPoolGetNameAndTypeRefIndexAt
 700 (JNIEnv *env, jobject obj, jobject unused, jint index);
 701 
 702 JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetNameAndTypeRefInfoAt
 703 (JNIEnv *env, jobject obj, jobject unused, jint index);
 704 
 705 JNIEXPORT jint JNICALL JVM_ConstantPoolGetIntAt
 706 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 707 
 708 JNIEXPORT jlong JNICALL JVM_ConstantPoolGetLongAt
 709 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 710 
 711 JNIEXPORT jfloat JNICALL JVM_ConstantPoolGetFloatAt
 712 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 713 
 714 JNIEXPORT jdouble JNICALL JVM_ConstantPoolGetDoubleAt
 715 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 716 
 717 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetStringAt
 718 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 719 
 720 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetUTF8At
 721 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 722 
 723 JNIEXPORT jbyte JNICALL JVM_ConstantPoolGetTagAt
 724 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 725 
 726 /*
 727  * Parameter reflection
 728  */
 729 
 730 JNIEXPORT jobjectArray JNICALL
 731 JVM_GetMethodParameters(JNIEnv *env, jobject method);
 732 
 733 /*
 734  * java.security.*
 735  */
 736 
 737 JNIEXPORT jobject JNICALL
 738 JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls);
 739 
 740 /*
 741  * Ensure that code doing a stackwalk and using javaVFrame::locals() to
 742  * get the value will see a materialized value and not a scalar-replaced
 743  * null value.
 744  */
 745 #define JVM_EnsureMaterializedForStackWalk(env, value) \
 746     do {} while(0) // Nothing to do.  The fact that the value escaped
 747                    // through a native method is enough.
 748 JNIEXPORT void JNICALL
 749 JVM_EnsureMaterializedForStackWalk_func(JNIEnv* env, jobject vthread, jobject value);
 750 
 751 JNIEXPORT jobject JNICALL
 752 JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls);
 753 
 754 /*
 755  * Signal support, used to implement the shutdown sequence.  Every VM must
 756  * support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts
 757  * (^C) and the latter for external termination (kill, system shutdown, etc.).
 758  * Other platform-dependent signal values may also be supported.
 759  */
 760 
 761 JNIEXPORT void * JNICALL
 762 JVM_RegisterSignal(jint sig, void *handler);
 763 
 764 JNIEXPORT jboolean JNICALL
 765 JVM_RaiseSignal(jint sig);
 766 
 767 JNIEXPORT jint JNICALL
 768 JVM_FindSignal(const char *name);
 769 
 770 /*
 771  * Retrieve the assertion directives for the specified class.
 772  */
 773 JNIEXPORT jboolean JNICALL
 774 JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls);
 775 
 776 /*
 777  * Retrieve the assertion directives from the VM.
 778  */
 779 JNIEXPORT jobject JNICALL
 780 JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused);
 781 
 782 /*
 783  * java.util.concurrent.atomic.AtomicLong
 784  */
 785 JNIEXPORT jboolean JNICALL
 786 JVM_SupportsCX8(void);
 787 
 788 /*
 789  * java.lang.ref.Finalizer
 790  */
 791 JNIEXPORT void JNICALL
 792 JVM_ReportFinalizationComplete(JNIEnv *env, jobject finalizee);
 793 
 794 JNIEXPORT jboolean JNICALL
 795 JVM_IsFinalizationEnabled(JNIEnv *env);
 796 
 797 /*************************************************************************
 798  PART 2: Support for the Verifier and Class File Format Checker
 799  ************************************************************************/
 800 /*
 801  * Return the class name in UTF format. The result is valid
 802  * until JVM_ReleaseUTf is called.
 803  *
 804  * The caller must treat the string as a constant and not modify it
 805  * in any way.
 806  */
 807 JNIEXPORT const char * JNICALL
 808 JVM_GetClassNameUTF(JNIEnv *env, jclass cb);
 809 
 810 /*
 811  * Returns the constant pool types in the buffer provided by "types."
 812  */
 813 JNIEXPORT void JNICALL
 814 JVM_GetClassCPTypes(JNIEnv *env, jclass cb, unsigned char *types);
 815 
 816 /*
 817  * Returns the number of Constant Pool entries.
 818  */
 819 JNIEXPORT jint JNICALL
 820 JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cb);
 821 
 822 /*
 823  * Returns the number of *declared* fields or methods.
 824  */
 825 JNIEXPORT jint JNICALL
 826 JVM_GetClassFieldsCount(JNIEnv *env, jclass cb);
 827 
 828 JNIEXPORT jint JNICALL
 829 JVM_GetClassMethodsCount(JNIEnv *env, jclass cb);
 830 
 831 /*
 832  * Returns the CP indexes of exceptions raised by a given method.
 833  * Places the result in the given buffer.
 834  *
 835  * The method is identified by method_index.
 836  */
 837 JNIEXPORT void JNICALL
 838 JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cb, jint method_index,
 839                                 unsigned short *exceptions);
 840 /*
 841  * Returns the number of exceptions raised by a given method.
 842  * The method is identified by method_index.
 843  */
 844 JNIEXPORT jint JNICALL
 845 JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cb, jint method_index);
 846 
 847 /*
 848  * Returns the byte code sequence of a given method.
 849  * Places the result in the given buffer.
 850  *
 851  * The method is identified by method_index.
 852  */
 853 JNIEXPORT void JNICALL
 854 JVM_GetMethodIxByteCode(JNIEnv *env, jclass cb, jint method_index,
 855                         unsigned char *code);
 856 
 857 /*
 858  * Returns the length of the byte code sequence of a given method.
 859  * The method is identified by method_index.
 860  */
 861 JNIEXPORT jint JNICALL
 862 JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cb, jint method_index);
 863 
 864 /*
 865  * A structure used to a capture exception table entry in a Java method.
 866  */
 867 typedef struct {
 868     jint start_pc;
 869     jint end_pc;
 870     jint handler_pc;
 871     jint catchType;
 872 } JVM_ExceptionTableEntryType;
 873 
 874 /*
 875  * Returns the exception table entry at entry_index of a given method.
 876  * Places the result in the given buffer.
 877  *
 878  * The method is identified by method_index.
 879  */
 880 JNIEXPORT void JNICALL
 881 JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cb, jint method_index,
 882                                    jint entry_index,
 883                                    JVM_ExceptionTableEntryType *entry);
 884 
 885 /*
 886  * Returns the length of the exception table of a given method.
 887  * The method is identified by method_index.
 888  */
 889 JNIEXPORT jint JNICALL
 890 JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cb, int index);
 891 
 892 /*
 893  * Returns the modifiers of a given field.
 894  * The field is identified by field_index.
 895  */
 896 JNIEXPORT jint JNICALL
 897 JVM_GetFieldIxModifiers(JNIEnv *env, jclass cb, int index);
 898 
 899 /*
 900  * Returns the modifiers of a given method.
 901  * The method is identified by method_index.
 902  */
 903 JNIEXPORT jint JNICALL
 904 JVM_GetMethodIxModifiers(JNIEnv *env, jclass cb, int index);
 905 
 906 /*
 907  * Returns the number of local variables of a given method.
 908  * The method is identified by method_index.
 909  */
 910 JNIEXPORT jint JNICALL
 911 JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cb, int index);
 912 
 913 /*
 914  * Returns the number of arguments (including this pointer) of a given method.
 915  * The method is identified by method_index.
 916  */
 917 JNIEXPORT jint JNICALL
 918 JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cb, int index);
 919 
 920 /*
 921  * Returns the maximum amount of stack (in words) used by a given method.
 922  * The method is identified by method_index.
 923  */
 924 JNIEXPORT jint JNICALL
 925 JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cb, int index);
 926 
 927 /*
 928  * Is a given method a constructor.
 929  * The method is identified by method_index.
 930  */
 931 JNIEXPORT jboolean JNICALL
 932 JVM_IsConstructorIx(JNIEnv *env, jclass cb, int index);
 933 
 934 /*
 935  * Is the given method generated by the VM.
 936  * The method is identified by method_index.
 937  */
 938 JNIEXPORT jboolean JNICALL
 939 JVM_IsVMGeneratedMethodIx(JNIEnv *env, jclass cb, int index);
 940 
 941 /*
 942  * Returns the name of a given method in UTF format.
 943  * The result remains valid until JVM_ReleaseUTF is called.
 944  *
 945  * The caller must treat the string as a constant and not modify it
 946  * in any way.
 947  */
 948 JNIEXPORT const char * JNICALL
 949 JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cb, jint index);
 950 
 951 /*
 952  * Returns the signature of a given method in UTF format.
 953  * The result remains valid until JVM_ReleaseUTF 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_GetMethodIxSignatureUTF(JNIEnv *env, jclass cb, jint index);
 960 
 961 /*
 962  * Returns the name of the field 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_GetCPFieldNameUTF(JNIEnv *env, jclass cb, jint index);
 973 
 974 /*
 975  * Returns the name 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_GetCPMethodNameUTF(JNIEnv *env, jclass cb, jint index);
 986 
 987 /*
 988  * Returns the signature of the method 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_GetCPMethodSignatureUTF(JNIEnv *env, jclass cb, jint index);
 999 
1000 /*
1001  * Returns the signature of the field referred to at a given constant pool
1002  * index.
1003  *
1004  * The result is in UTF format and remains valid until JVM_ReleaseUTF
1005  * is called.
1006  *
1007  * The caller must treat the string as a constant and not modify it
1008  * in any way.
1009  */
1010 JNIEXPORT const char * JNICALL
1011 JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cb, jint index);
1012 
1013 /*
1014  * Returns the class name referred to at a given constant pool index.
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_GetCPClassNameUTF(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 a CONSTANT_Fieldref.
1029  *
1030  * The result is in UTF format and remains valid until JVM_ReleaseUTF
1031  * is called.
1032  *
1033  * The caller must treat the string as a constant and not modify it
1034  * in any way.
1035  */
1036 JNIEXPORT const char * JNICALL
1037 JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cb, jint index);
1038 
1039 /*
1040  * Returns the class name referred to at a given constant pool index.
1041  *
1042  * The constant pool entry must refer to CONSTANT_Methodref or
1043  * CONSTANT_InterfaceMethodref.
1044  *
1045  * The result is in UTF format and remains valid until JVM_ReleaseUTF
1046  * is called.
1047  *
1048  * The caller must treat the string as a constant and not modify it
1049  * in any way.
1050  */
1051 JNIEXPORT const char * JNICALL
1052 JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cb, jint index);
1053 
1054 /*
1055  * Returns the modifiers of a field in calledClass. The field is
1056  * referred to in class cb at constant pool entry index.
1057  *
1058  * The caller must treat the string as a constant and not modify it
1059  * in any way.
1060  *
1061  * Returns -1 if the field does not exist in calledClass.
1062  */
1063 JNIEXPORT jint JNICALL
1064 JVM_GetCPFieldModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
1065 
1066 /*
1067  * Returns the modifiers of a method in calledClass. The method is
1068  * referred to in class cb at constant pool entry index.
1069  *
1070  * Returns -1 if the method does not exist in calledClass.
1071  */
1072 JNIEXPORT jint JNICALL
1073 JVM_GetCPMethodModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
1074 
1075 /*
1076  * Releases the UTF string obtained from the VM.
1077  */
1078 JNIEXPORT void JNICALL
1079 JVM_ReleaseUTF(const char *utf);
1080 
1081 /*
1082  * Compare if two classes are in the same package.
1083  */
1084 JNIEXPORT jboolean JNICALL
1085 JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2);
1086 
1087 
1088 /*************************************************************************
1089  PART 3: I/O and Network Support
1090  ************************************************************************/
1091 
1092 /*
1093  * Convert a pathname into native format.  This function does syntactic
1094  * cleanup, such as removing redundant separator characters.  It modifies
1095  * the given pathname string in place.
1096  */
1097 JNIEXPORT char * JNICALL
1098 JVM_NativePath(char *);
1099 
1100 JNIEXPORT void * JNICALL
1101 JVM_RawMonitorCreate(void);
1102 
1103 JNIEXPORT void JNICALL
1104 JVM_RawMonitorDestroy(void *mon);
1105 
1106 JNIEXPORT jint JNICALL
1107 JVM_RawMonitorEnter(void *mon);
1108 
1109 JNIEXPORT void JNICALL
1110 JVM_RawMonitorExit(void *mon);
1111 
1112 /*
1113  * java.lang.management support
1114  */
1115 JNIEXPORT void* JNICALL
1116 JVM_GetManagement(jint version);
1117 
1118 /*
1119  * com.sun.tools.attach.VirtualMachine support
1120  *
1121  * Initialize the agent properties with the properties maintained in the VM.
1122  */
1123 JNIEXPORT jobject JNICALL
1124 JVM_InitAgentProperties(JNIEnv *env, jobject agent_props);
1125 
1126 JNIEXPORT jstring JNICALL
1127 JVM_GetTemporaryDirectory(JNIEnv *env);
1128 
1129 /* Generics reflection support.
1130  *
1131  * Returns information about the given class's EnclosingMethod
1132  * attribute, if present, or null if the class had no enclosing
1133  * method.
1134  *
1135  * If non-null, the returned array contains three elements. Element 0
1136  * is the java.lang.Class of which the enclosing method is a member,
1137  * and elements 1 and 2 are the java.lang.Strings for the enclosing
1138  * method's name and descriptor, respectively.
1139  */
1140 JNIEXPORT jobjectArray JNICALL
1141 JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass);
1142 
1143 /*
1144  * Virtual thread support.
1145  */
1146 JNIEXPORT void JNICALL
1147 JVM_VirtualThreadStart(JNIEnv* env, jobject vthread);
1148 
1149 JNIEXPORT void JNICALL
1150 JVM_VirtualThreadEnd(JNIEnv* env, jobject vthread);
1151 
1152 JNIEXPORT void JNICALL
1153 JVM_VirtualThreadMount(JNIEnv* env, jobject vthread, jboolean hide);
1154 
1155 JNIEXPORT void JNICALL
1156 JVM_VirtualThreadUnmount(JNIEnv* env, jobject vthread, jboolean hide);
1157 
1158 JNIEXPORT void JNICALL
1159 JVM_VirtualThreadHideFrames(JNIEnv* env, jobject vthread, jboolean hide);
1160 
1161 /*
1162  * Core reflection support.
1163  */
1164 JNIEXPORT jint JNICALL
1165 JVM_GetClassFileVersion(JNIEnv *env, jclass current);
1166 
1167 /*
1168  * This structure is used by the launcher to get the default thread
1169  * stack size from the VM using JNI_GetDefaultJavaVMInitArgs() with a
1170  * version of 1.1.  As it is not supported otherwise, it has been removed
1171  * from jni.h
1172  */
1173 typedef struct JDK1_1InitArgs {
1174     jint version;
1175 
1176     char **properties;
1177     jint checkSource;
1178     jint nativeStackSize;
1179     jint javaStackSize;
1180     jint minHeapSize;
1181     jint maxHeapSize;
1182     jint verifyMode;
1183     char *classpath;
1184 
1185     jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args);
1186     void (JNICALL *exit)(jint code);
1187     void (JNICALL *abort)(void);
1188 
1189     jint enableClassGC;
1190     jint enableVerboseGC;
1191     jint disableAsyncGC;
1192     jint verbose;
1193     jboolean debugging;
1194     jint debugPort;
1195 } JDK1_1InitArgs;
1196 
1197 
1198 #ifdef __cplusplus
1199 } /* extern "C" */
1200 
1201 #endif /* __cplusplus */
1202 
1203 #endif /* !_JAVASOFT_JVM_H_ */
--- EOF ---