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