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