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, jboolean throwException);
 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  * java.lang.ref.Finalizer
 782  */
 783 JNIEXPORT void JNICALL
 784 JVM_ReportFinalizationComplete(JNIEnv *env, jobject finalizee);
 785 
 786 /*************************************************************************
 787  PART 2: Support for the Verifier and Class File Format Checker
 788  ************************************************************************/
 789 /*
 790  * Return the class name in UTF format. The result is valid
 791  * until JVM_ReleaseUTf is called.
 792  *
 793  * The caller must treat the string as a constant and not modify it
 794  * in any way.
 795  */
 796 JNIEXPORT const char * JNICALL
 797 JVM_GetClassNameUTF(JNIEnv *env, jclass cb);
 798 
 799 /*
 800  * Returns the constant pool types in the buffer provided by "types."
 801  */
 802 JNIEXPORT void JNICALL
 803 JVM_GetClassCPTypes(JNIEnv *env, jclass cb, unsigned char *types);
 804 
 805 /*
 806  * Returns the number of Constant Pool entries.
 807  */
 808 JNIEXPORT jint JNICALL
 809 JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cb);
 810 
 811 /*
 812  * Returns the number of *declared* fields or methods.
 813  */
 814 JNIEXPORT jint JNICALL
 815 JVM_GetClassFieldsCount(JNIEnv *env, jclass cb);
 816 
 817 JNIEXPORT jint JNICALL
 818 JVM_GetClassMethodsCount(JNIEnv *env, jclass cb);
 819 
 820 /*
 821  * Returns the CP indexes of exceptions raised by a given method.
 822  * Places the result in the given buffer.
 823  *
 824  * The method is identified by method_index.
 825  */
 826 JNIEXPORT void JNICALL
 827 JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cb, jint method_index,
 828                                 unsigned short *exceptions);
 829 /*
 830  * Returns the number of exceptions raised by a given method.
 831  * The method is identified by method_index.
 832  */
 833 JNIEXPORT jint JNICALL
 834 JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cb, jint method_index);
 835 
 836 /*
 837  * Returns the byte code sequence of a given method.
 838  * Places the result in the given buffer.
 839  *
 840  * The method is identified by method_index.
 841  */
 842 JNIEXPORT void JNICALL
 843 JVM_GetMethodIxByteCode(JNIEnv *env, jclass cb, jint method_index,
 844                         unsigned char *code);
 845 
 846 /*
 847  * Returns the length of the byte code sequence of a given method.
 848  * The method is identified by method_index.
 849  */
 850 JNIEXPORT jint JNICALL
 851 JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cb, jint method_index);
 852 
 853 /*
 854  * A structure used to a capture exception table entry in a Java method.
 855  */
 856 typedef struct {
 857     jint start_pc;
 858     jint end_pc;
 859     jint handler_pc;
 860     jint catchType;
 861 } JVM_ExceptionTableEntryType;
 862 
 863 /*
 864  * Returns the exception table entry at entry_index of a given method.
 865  * Places the result in the given buffer.
 866  *
 867  * The method is identified by method_index.
 868  */
 869 JNIEXPORT void JNICALL
 870 JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cb, jint method_index,
 871                                    jint entry_index,
 872                                    JVM_ExceptionTableEntryType *entry);
 873 
 874 /*
 875  * Returns the length of the exception table of a given method.
 876  * The method is identified by method_index.
 877  */
 878 JNIEXPORT jint JNICALL
 879 JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cb, int index);
 880 
 881 /*
 882  * Returns the modifiers of a given field.
 883  * The field is identified by field_index.
 884  */
 885 JNIEXPORT jint JNICALL
 886 JVM_GetFieldIxModifiers(JNIEnv *env, jclass cb, int index);
 887 
 888 /*
 889  * Returns the modifiers of a given method.
 890  * The method is identified by method_index.
 891  */
 892 JNIEXPORT jint JNICALL
 893 JVM_GetMethodIxModifiers(JNIEnv *env, jclass cb, int index);
 894 
 895 /*
 896  * Returns the number of local variables of a given method.
 897  * The method is identified by method_index.
 898  */
 899 JNIEXPORT jint JNICALL
 900 JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cb, int index);
 901 
 902 /*
 903  * Returns the number of arguments (including this pointer) of a given method.
 904  * The method is identified by method_index.
 905  */
 906 JNIEXPORT jint JNICALL
 907 JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cb, int index);
 908 
 909 /*
 910  * Returns the maximum amount of stack (in words) used by a given method.
 911  * The method is identified by method_index.
 912  */
 913 JNIEXPORT jint JNICALL
 914 JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cb, int index);
 915 
 916 /*
 917  * Is a given method a constructor.
 918  * The method is identified by method_index.
 919  */
 920 JNIEXPORT jboolean JNICALL
 921 JVM_IsConstructorIx(JNIEnv *env, jclass cb, int index);
 922 
 923 /*
 924  * Is the given method generated by the VM.
 925  * The method is identified by method_index.
 926  */
 927 JNIEXPORT jboolean JNICALL
 928 JVM_IsVMGeneratedMethodIx(JNIEnv *env, jclass cb, int index);
 929 
 930 /*
 931  * Returns the name of a given method in UTF format.
 932  * The result remains valid until JVM_ReleaseUTF is called.
 933  *
 934  * The caller must treat the string as a constant and not modify it
 935  * in any way.
 936  */
 937 JNIEXPORT const char * JNICALL
 938 JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cb, jint index);
 939 
 940 /*
 941  * Returns the signature of a given method in UTF format.
 942  * The result remains valid until JVM_ReleaseUTF is called.
 943  *
 944  * The caller must treat the string as a constant and not modify it
 945  * in any way.
 946  */
 947 JNIEXPORT const char * JNICALL
 948 JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cb, jint index);
 949 
 950 /*
 951  * Returns the name of the field referred to at a given constant pool
 952  * index.
 953  *
 954  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 955  * is called.
 956  *
 957  * The caller must treat the string as a constant and not modify it
 958  * in any way.
 959  */
 960 JNIEXPORT const char * JNICALL
 961 JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cb, jint index);
 962 
 963 /*
 964  * Returns the name of the method referred to at a given constant pool
 965  * index.
 966  *
 967  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 968  * is called.
 969  *
 970  * The caller must treat the string as a constant and not modify it
 971  * in any way.
 972  */
 973 JNIEXPORT const char * JNICALL
 974 JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cb, jint index);
 975 
 976 /*
 977  * Returns the signature of the method referred to at a given constant pool
 978  * index.
 979  *
 980  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 981  * is called.
 982  *
 983  * The caller must treat the string as a constant and not modify it
 984  * in any way.
 985  */
 986 JNIEXPORT const char * JNICALL
 987 JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cb, jint index);
 988 
 989 /*
 990  * Returns the signature of the field referred to at a given constant pool
 991  * index.
 992  *
 993  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 994  * is called.
 995  *
 996  * The caller must treat the string as a constant and not modify it
 997  * in any way.
 998  */
 999 JNIEXPORT const char * JNICALL
1000 JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cb, jint index);
1001 
1002 /*
1003  * Returns the class name referred to at a given constant pool index.
1004  *
1005  * The result is in UTF format and remains valid until JVM_ReleaseUTF
1006  * is called.
1007  *
1008  * The caller must treat the string as a constant and not modify it
1009  * in any way.
1010  */
1011 JNIEXPORT const char * JNICALL
1012 JVM_GetCPClassNameUTF(JNIEnv *env, jclass cb, jint index);
1013 
1014 /*
1015  * Returns the class name referred to at a given constant pool index.
1016  *
1017  * The constant pool entry must refer to a CONSTANT_Fieldref.
1018  *
1019  * The result is in UTF format and remains valid until JVM_ReleaseUTF
1020  * is called.
1021  *
1022  * The caller must treat the string as a constant and not modify it
1023  * in any way.
1024  */
1025 JNIEXPORT const char * JNICALL
1026 JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cb, jint index);
1027 
1028 /*
1029  * Returns the class name referred to at a given constant pool index.
1030  *
1031  * The constant pool entry must refer to CONSTANT_Methodref or
1032  * CONSTANT_InterfaceMethodref.
1033  *
1034  * The result is in UTF format and remains valid until JVM_ReleaseUTF
1035  * is called.
1036  *
1037  * The caller must treat the string as a constant and not modify it
1038  * in any way.
1039  */
1040 JNIEXPORT const char * JNICALL
1041 JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cb, jint index);
1042 
1043 /*
1044  * Returns the modifiers of a field in calledClass. The field is
1045  * referred to in class cb at constant pool entry index.
1046  *
1047  * The caller must treat the string as a constant and not modify it
1048  * in any way.
1049  *
1050  * Returns -1 if the field does not exist in calledClass.
1051  */
1052 JNIEXPORT jint JNICALL
1053 JVM_GetCPFieldModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
1054 
1055 /*
1056  * Returns the modifiers of a method in calledClass. The method is
1057  * referred to in class cb at constant pool entry index.
1058  *
1059  * Returns -1 if the method does not exist in calledClass.
1060  */
1061 JNIEXPORT jint JNICALL
1062 JVM_GetCPMethodModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
1063 
1064 /*
1065  * Releases the UTF string obtained from the VM.
1066  */
1067 JNIEXPORT void JNICALL
1068 JVM_ReleaseUTF(const char *utf);
1069 
1070 /*
1071  * Compare if two classes are in the same package.
1072  */
1073 JNIEXPORT jboolean JNICALL
1074 JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2);
1075 
1076 
1077 /*************************************************************************
1078  PART 3: I/O and Network Support
1079  ************************************************************************/
1080 
1081 /*
1082  * Convert a pathname into native format.  This function does syntactic
1083  * cleanup, such as removing redundant separator characters.  It modifies
1084  * the given pathname string in place.
1085  */
1086 JNIEXPORT char * JNICALL
1087 JVM_NativePath(char *);
1088 
1089 JNIEXPORT void * JNICALL
1090 JVM_RawMonitorCreate(void);
1091 
1092 JNIEXPORT void JNICALL
1093 JVM_RawMonitorDestroy(void *mon);
1094 
1095 JNIEXPORT jint JNICALL
1096 JVM_RawMonitorEnter(void *mon);
1097 
1098 JNIEXPORT void JNICALL
1099 JVM_RawMonitorExit(void *mon);
1100 
1101 /*
1102  * java.lang.management support
1103  */
1104 JNIEXPORT void* JNICALL
1105 JVM_GetManagement(jint version);
1106 
1107 /*
1108  * com.sun.tools.attach.VirtualMachine support
1109  *
1110  * Initialize the agent properties with the properties maintained in the VM.
1111  */
1112 JNIEXPORT jobject JNICALL
1113 JVM_InitAgentProperties(JNIEnv *env, jobject agent_props);
1114 
1115 JNIEXPORT jstring JNICALL
1116 JVM_GetTemporaryDirectory(JNIEnv *env);
1117 
1118 /* Generics reflection support.
1119  *
1120  * Returns information about the given class's EnclosingMethod
1121  * attribute, if present, or null if the class had no enclosing
1122  * method.
1123  *
1124  * If non-null, the returned array contains three elements. Element 0
1125  * is the java.lang.Class of which the enclosing method is a member,
1126  * and elements 1 and 2 are the java.lang.Strings for the enclosing
1127  * method's name and descriptor, respectively.
1128  */
1129 JNIEXPORT jobjectArray JNICALL
1130 JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass);
1131     
1132 /* Virtual thread support.
1133  */
1134 JNIEXPORT void JNICALL
1135 JVM_VirtualThreadMountBegin(JNIEnv* env, jobject vthread, jboolean first_mount);
1136 
1137 JNIEXPORT void JNICALL
1138 JVM_VirtualThreadMountEnd(JNIEnv* env, jobject vthread, jboolean first_mount);
1139 
1140 JNIEXPORT void JNICALL
1141 JVM_VirtualThreadUnmountBegin(JNIEnv* env, jobject vthread, jboolean last_unmount);
1142 
1143 JNIEXPORT void JNICALL
1144 JVM_VirtualThreadUnmountEnd(JNIEnv* env, jobject vthread, jboolean last_unmount);
1145 
1146 /*
1147  * This structure is used by the launcher to get the default thread
1148  * stack size from the VM using JNI_GetDefaultJavaVMInitArgs() with a
1149  * version of 1.1.  As it is not supported otherwise, it has been removed
1150  * from jni.h
1151  */
1152 typedef struct JDK1_1InitArgs {
1153     jint version;
1154 
1155     char **properties;
1156     jint checkSource;
1157     jint nativeStackSize;
1158     jint javaStackSize;
1159     jint minHeapSize;
1160     jint maxHeapSize;
1161     jint verifyMode;
1162     char *classpath;
1163 
1164     jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args);
1165     void (JNICALL *exit)(jint code);
1166     void (JNICALL *abort)(void);
1167 
1168     jint enableClassGC;
1169     jint enableVerboseGC;
1170     jint disableAsyncGC;
1171     jint verbose;
1172     jboolean debugging;
1173     jint debugPort;
1174 } JDK1_1InitArgs;
1175 
1176 
1177 #ifdef __cplusplus
1178 } /* extern "C" */
1179 
1180 #endif /* __cplusplus */
1181 
1182 #endif /* !_JAVASOFT_JVM_H_ */
--- EOF ---