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