1 /* 2 * Copyright (c) 1997, 2017, 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. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_VM_PRIMS_JVM_H 26 #define SHARE_VM_PRIMS_JVM_H 27 28 #include "prims/jni.h" 29 #include "utilities/macros.hpp" 30 31 #include OS_HEADER_H(jvm) 32 33 #ifndef _JAVASOFT_JVM_H_ 34 #define _JAVASOFT_JVM_H_ 35 36 // HotSpot integration note: 37 // 38 // This file and jvm.h used with the JDK are identical, 39 // except for the three includes removed below 40 41 // #include <sys/stat.h> 42 // #include "jni.h" 43 // #include "jvm_md.h" 44 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 /* 51 * This file contains additional functions exported from the VM. 52 * These functions are complementary to the standard JNI support. 53 * There are three parts to this file: 54 * 55 * First, this file contains the VM-related functions needed by native 56 * libraries in the standard Java API. For example, the java.lang.Object 57 * class needs VM-level functions that wait for and notify monitors. 58 * 59 * Second, this file contains the functions and constant definitions 60 * needed by the byte code verifier and class file format checker. 61 * These functions allow the verifier and format checker to be written 62 * in a VM-independent way. 63 * 64 * Third, this file contains various I/O and nerwork operations needed 65 * by the standard Java I/O and network APIs. 66 */ 67 68 /* 69 * Bump the version number when either of the following happens: 70 * 71 * 1. There is a change in JVM_* functions. 72 * 73 * 2. There is a change in the contract between VM and Java classes. 74 * For example, if the VM relies on a new private field in Thread 75 * class. 76 */ 77 78 #define JVM_INTERFACE_VERSION 5 79 80 JNIEXPORT jobjectArray JNICALL 81 JVM_GetMethodParameters(JNIEnv *env, jobject method); 82 83 JNIEXPORT jint JNICALL 84 JVM_GetInterfaceVersion(void); 85 86 /************************************************************************* 87 PART 1: Functions for Native Libraries 88 ************************************************************************/ 89 /* 90 * java.lang.Object 91 */ 92 JNIEXPORT jint JNICALL 93 JVM_IHashCode(JNIEnv *env, jobject obj); 94 95 JNIEXPORT void JNICALL 96 JVM_MonitorWait(JNIEnv *env, jobject obj, jlong ms); 97 98 JNIEXPORT void JNICALL 99 JVM_MonitorNotify(JNIEnv *env, jobject obj); 100 101 JNIEXPORT void JNICALL 102 JVM_MonitorNotifyAll(JNIEnv *env, jobject obj); 103 104 JNIEXPORT jobject JNICALL 105 JVM_Clone(JNIEnv *env, jobject obj); 106 107 /* 108 * java.lang.String 109 */ 110 JNIEXPORT jstring JNICALL 111 JVM_InternString(JNIEnv *env, jstring str); 112 113 /* 114 * java.lang.System 115 */ 116 JNIEXPORT jlong JNICALL 117 JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored); 118 119 JNIEXPORT jlong JNICALL 120 JVM_NanoTime(JNIEnv *env, jclass ignored); 121 122 JNIEXPORT jlong JNICALL 123 JVM_GetNanoTimeAdjustment(JNIEnv *env, jclass ignored, jlong offset_secs); 124 125 JNIEXPORT void JNICALL 126 JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos, 127 jobject dst, jint dst_pos, jint length); 128 129 JNIEXPORT jobject JNICALL 130 JVM_InitProperties(JNIEnv *env, jobject p); 131 132 /* 133 * java.lang.Runtime 134 */ 135 136 JNIEXPORT void JNICALL 137 JVM_Halt(jint code); 138 139 JNIEXPORT void JNICALL 140 JVM_GC(void); 141 142 /* Returns the number of real-time milliseconds that have elapsed since the 143 * least-recently-inspected heap object was last inspected by the garbage 144 * collector. 145 * 146 * For simple stop-the-world collectors this value is just the time 147 * since the most recent collection. For generational collectors it is the 148 * time since the oldest generation was most recently collected. Other 149 * collectors are free to return a pessimistic estimate of the elapsed time, or 150 * simply the time since the last full collection was performed. 151 * 152 * Note that in the presence of reference objects, a given object that is no 153 * longer strongly reachable may have to be inspected multiple times before it 154 * can be reclaimed. 155 */ 156 JNIEXPORT jlong JNICALL 157 JVM_MaxObjectInspectionAge(void); 158 159 JNIEXPORT jlong JNICALL 160 JVM_TotalMemory(void); 161 162 JNIEXPORT jlong JNICALL 163 JVM_FreeMemory(void); 164 165 JNIEXPORT jlong JNICALL 166 JVM_MaxMemory(void); 167 168 JNIEXPORT jint JNICALL 169 JVM_ActiveProcessorCount(void); 170 171 JNIEXPORT void * JNICALL 172 JVM_LoadLibrary(const char *name); 173 174 JNIEXPORT void JNICALL 175 JVM_UnloadLibrary(void * handle); 176 177 JNIEXPORT void * JNICALL 178 JVM_FindLibraryEntry(void *handle, const char *name); 179 180 JNIEXPORT jboolean JNICALL 181 JVM_IsSupportedJNIVersion(jint version); 182 183 JNIEXPORT jobjectArray JNICALL 184 JVM_GetVmArguments(JNIEnv *env); 185 186 /* 187 * java.lang.Throwable 188 */ 189 JNIEXPORT void JNICALL 190 JVM_FillInStackTrace(JNIEnv *env, jobject throwable); 191 192 /* 193 * java.lang.StackTraceElement 194 */ 195 JNIEXPORT void JNICALL 196 JVM_InitStackTraceElementArray(JNIEnv *env, jobjectArray elements, jobject throwable); 197 198 JNIEXPORT void JNICALL 199 JVM_InitStackTraceElement(JNIEnv* env, jobject element, jobject stackFrameInfo); 200 201 /* 202 * java.lang.StackWalker 203 */ 204 enum { 205 JVM_STACKWALK_FILL_CLASS_REFS_ONLY = 0x02, 206 JVM_STACKWALK_GET_CALLER_CLASS = 0x04, 207 JVM_STACKWALK_SHOW_HIDDEN_FRAMES = 0x20, 208 JVM_STACKWALK_FILL_LIVE_STACK_FRAMES = 0x100 209 }; 210 211 JNIEXPORT jobject JNICALL 212 JVM_CallStackWalk(JNIEnv *env, jobject stackStream, jlong mode, 213 jint skip_frames, jint frame_count, jint start_index, 214 jobjectArray frames); 215 216 JNIEXPORT jint JNICALL 217 JVM_MoreStackWalk(JNIEnv *env, jobject stackStream, jlong mode, jlong anchor, 218 jint frame_count, jint start_index, 219 jobjectArray frames); 220 221 /* 222 * java.lang.Thread 223 */ 224 JNIEXPORT void JNICALL 225 JVM_StartThread(JNIEnv *env, jobject thread); 226 227 JNIEXPORT void JNICALL 228 JVM_StopThread(JNIEnv *env, jobject thread, jobject exception); 229 230 JNIEXPORT jboolean JNICALL 231 JVM_IsThreadAlive(JNIEnv *env, jobject thread); 232 233 JNIEXPORT void JNICALL 234 JVM_SuspendThread(JNIEnv *env, jobject thread); 235 236 JNIEXPORT void JNICALL 237 JVM_ResumeThread(JNIEnv *env, jobject thread); 238 239 JNIEXPORT void JNICALL 240 JVM_SetThreadPriority(JNIEnv *env, jobject thread, jint prio); 241 242 JNIEXPORT void JNICALL 243 JVM_Yield(JNIEnv *env, jclass threadClass); 244 245 JNIEXPORT void JNICALL 246 JVM_Sleep(JNIEnv *env, jclass threadClass, jlong millis); 247 248 JNIEXPORT jobject JNICALL 249 JVM_CurrentThread(JNIEnv *env, jclass threadClass); 250 251 JNIEXPORT jint JNICALL 252 JVM_CountStackFrames(JNIEnv *env, jobject thread); 253 254 JNIEXPORT void JNICALL 255 JVM_Interrupt(JNIEnv *env, jobject thread); 256 257 JNIEXPORT jboolean JNICALL 258 JVM_IsInterrupted(JNIEnv *env, jobject thread, jboolean clearInterrupted); 259 260 JNIEXPORT jboolean JNICALL 261 JVM_HoldsLock(JNIEnv *env, jclass threadClass, jobject obj); 262 263 JNIEXPORT void JNICALL 264 JVM_DumpAllStacks(JNIEnv *env, jclass unused); 265 266 JNIEXPORT jobjectArray JNICALL 267 JVM_GetAllThreads(JNIEnv *env, jclass dummy); 268 269 JNIEXPORT void JNICALL 270 JVM_SetNativeThreadName(JNIEnv *env, jobject jthread, jstring name); 271 272 /* getStackTrace() and getAllStackTraces() method */ 273 JNIEXPORT jobjectArray JNICALL 274 JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads); 275 276 /* 277 * java.lang.Continuation 278 */ 279 JNIEXPORT void JNICALL 280 JVM_RegisterContinuationMethods(JNIEnv *env, jclass cls); 281 282 /* 283 * java.lang.SecurityManager 284 */ 285 JNIEXPORT jclass JNICALL 286 JVM_CurrentLoadedClass(JNIEnv *env); 287 288 JNIEXPORT jobject JNICALL 289 JVM_CurrentClassLoader(JNIEnv *env); 290 291 JNIEXPORT jobjectArray JNICALL 292 JVM_GetClassContext(JNIEnv *env); 293 294 JNIEXPORT jint JNICALL 295 JVM_ClassDepth(JNIEnv *env, jstring name); 296 297 JNIEXPORT jint JNICALL 298 JVM_ClassLoaderDepth(JNIEnv *env); 299 300 /* 301 * java.lang.Package 302 */ 303 JNIEXPORT jstring JNICALL 304 JVM_GetSystemPackage(JNIEnv *env, jstring name); 305 306 JNIEXPORT jobjectArray JNICALL 307 JVM_GetSystemPackages(JNIEnv *env); 308 309 /* 310 * java.lang.ref.Reference 311 */ 312 JNIEXPORT jobject JNICALL 313 JVM_GetAndClearReferencePendingList(JNIEnv *env); 314 315 JNIEXPORT jboolean JNICALL 316 JVM_HasReferencePendingList(JNIEnv *env); 317 318 JNIEXPORT void JNICALL 319 JVM_WaitForReferencePendingList(JNIEnv *env); 320 321 /* 322 * java.io.ObjectInputStream 323 */ 324 JNIEXPORT jobject JNICALL 325 JVM_LatestUserDefinedLoader(JNIEnv *env); 326 327 /* 328 * java.lang.reflect.Array 329 */ 330 JNIEXPORT jint JNICALL 331 JVM_GetArrayLength(JNIEnv *env, jobject arr); 332 333 JNIEXPORT jobject JNICALL 334 JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index); 335 336 JNIEXPORT jvalue JNICALL 337 JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode); 338 339 JNIEXPORT void JNICALL 340 JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val); 341 342 JNIEXPORT void JNICALL 343 JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v, 344 unsigned char vCode); 345 346 JNIEXPORT jobject JNICALL 347 JVM_NewArray(JNIEnv *env, jclass eltClass, jint length); 348 349 JNIEXPORT jobject JNICALL 350 JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim); 351 352 /* 353 * java.lang.Class and java.lang.ClassLoader 354 */ 355 356 #define JVM_CALLER_DEPTH -1 357 358 /* 359 * Returns the class in which the code invoking the native method 360 * belongs. 361 * 362 * Note that in JDK 1.1, native methods did not create a frame. 363 * In 1.2, they do. Therefore native methods like Class.forName 364 * can no longer look at the current frame for the caller class. 365 */ 366 JNIEXPORT jclass JNICALL 367 JVM_GetCallerClass(JNIEnv *env, int n); 368 369 /* 370 * Find primitive classes 371 * utf: class name 372 */ 373 JNIEXPORT jclass JNICALL 374 JVM_FindPrimitiveClass(JNIEnv *env, const char *utf); 375 376 /* 377 * Find a class from a boot class loader. Returns NULL if class not found. 378 */ 379 JNIEXPORT jclass JNICALL 380 JVM_FindClassFromBootLoader(JNIEnv *env, const char *name); 381 382 /* 383 * Find a class from a given class loader. Throws ClassNotFoundException. 384 * name: name of class 385 * init: whether initialization is done 386 * loader: class loader to look up the class. This may not be the same as the caller's 387 * class loader. 388 * caller: initiating class. The initiating class may be null when a security 389 * manager is not installed. 390 */ 391 JNIEXPORT jclass JNICALL 392 JVM_FindClassFromCaller(JNIEnv *env, const char *name, jboolean init, 393 jobject loader, jclass caller); 394 395 /* 396 * Find a class from a given class. 397 */ 398 JNIEXPORT jclass JNICALL 399 JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init, 400 jclass from); 401 402 /* Find a loaded class cached by the VM */ 403 JNIEXPORT jclass JNICALL 404 JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name); 405 406 /* Define a class */ 407 JNIEXPORT jclass JNICALL 408 JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, 409 jsize len, jobject pd); 410 411 /* Define a class with a source (added in JDK1.5) */ 412 JNIEXPORT jclass JNICALL 413 JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, 414 const jbyte *buf, jsize len, jobject pd, 415 const char *source); 416 417 /* 418 * Module support funcions 419 */ 420 421 /* 422 * Define a module with the specified packages and bind the module to the 423 * given class loader. 424 * module: module to define 425 * is_open: specifies if module is open (currently ignored) 426 * version: the module version 427 * location: the module location 428 * packages: list of packages in the module 429 * num_packages: number of packages in the module 430 */ 431 JNIEXPORT void JNICALL 432 JVM_DefineModule(JNIEnv *env, jobject module, jboolean is_open, jstring version, 433 jstring location, const char* const* packages, jsize num_packages); 434 435 /* 436 * Set the boot loader's unnamed module. 437 * module: boot loader's unnamed module 438 */ 439 JNIEXPORT void JNICALL 440 JVM_SetBootLoaderUnnamedModule(JNIEnv *env, jobject module); 441 442 /* 443 * Do a qualified export of a package. 444 * from_module: module containing the package to export 445 * package: name of the package to export 446 * to_module: module to export the package to 447 */ 448 JNIEXPORT void JNICALL 449 JVM_AddModuleExports(JNIEnv *env, jobject from_module, const char* package, jobject to_module); 450 451 /* 452 * Do an export of a package to all unnamed modules. 453 * from_module: module containing the package to export 454 * package: name of the package to export to all unnamed modules 455 */ 456 JNIEXPORT void JNICALL 457 JVM_AddModuleExportsToAllUnnamed(JNIEnv *env, jobject from_module, const char* package); 458 459 /* 460 * Do an unqualified export of a package. 461 * from_module: module containing the package to export 462 * package: name of the package to export 463 */ 464 JNIEXPORT void JNICALL 465 JVM_AddModuleExportsToAll(JNIEnv *env, jobject from_module, const char* package); 466 467 /* 468 * Add a module to the list of modules that a given module can read. 469 * from_module: module requesting read access 470 * source_module: module that from_module wants to read 471 */ 472 JNIEXPORT void JNICALL 473 JVM_AddReadsModule(JNIEnv *env, jobject from_module, jobject source_module); 474 475 /* 476 * Reflection support functions 477 */ 478 479 JNIEXPORT jstring JNICALL 480 JVM_GetClassName(JNIEnv *env, jclass cls); 481 482 JNIEXPORT jobjectArray JNICALL 483 JVM_GetClassInterfaces(JNIEnv *env, jclass cls); 484 485 JNIEXPORT jboolean JNICALL 486 JVM_IsInterface(JNIEnv *env, jclass cls); 487 488 JNIEXPORT jobjectArray JNICALL 489 JVM_GetClassSigners(JNIEnv *env, jclass cls); 490 491 JNIEXPORT void JNICALL 492 JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers); 493 494 JNIEXPORT jobject JNICALL 495 JVM_GetProtectionDomain(JNIEnv *env, jclass cls); 496 497 JNIEXPORT jboolean JNICALL 498 JVM_IsArrayClass(JNIEnv *env, jclass cls); 499 500 JNIEXPORT jboolean JNICALL 501 JVM_IsPrimitiveClass(JNIEnv *env, jclass cls); 502 503 JNIEXPORT jint JNICALL 504 JVM_GetClassModifiers(JNIEnv *env, jclass cls); 505 506 JNIEXPORT jobjectArray JNICALL 507 JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass); 508 509 JNIEXPORT jclass JNICALL 510 JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass); 511 512 JNIEXPORT jstring JNICALL 513 JVM_GetSimpleBinaryName(JNIEnv *env, jclass ofClass); 514 515 /* Generics support (JDK 1.5) */ 516 JNIEXPORT jstring JNICALL 517 JVM_GetClassSignature(JNIEnv *env, jclass cls); 518 519 /* Annotations support (JDK 1.5) */ 520 JNIEXPORT jbyteArray JNICALL 521 JVM_GetClassAnnotations(JNIEnv *env, jclass cls); 522 523 /* Annotations support (JDK 1.6) */ 524 525 /* Type use annotations support (JDK 1.8) */ 526 527 JNIEXPORT jbyteArray JNICALL 528 JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls); 529 530 // field is a handle to a java.lang.reflect.Field object 531 JNIEXPORT jbyteArray JNICALL 532 JVM_GetFieldTypeAnnotations(JNIEnv *env, jobject field); 533 534 // method is a handle to a java.lang.reflect.Method object 535 JNIEXPORT jbyteArray JNICALL 536 JVM_GetMethodTypeAnnotations(JNIEnv *env, jobject method); 537 538 /* 539 * New (JDK 1.4) reflection implementation 540 */ 541 542 JNIEXPORT jobjectArray JNICALL 543 JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly); 544 545 JNIEXPORT jobjectArray JNICALL 546 JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly); 547 548 JNIEXPORT jobjectArray JNICALL 549 JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly); 550 551 /* Differs from JVM_GetClassModifiers in treatment of inner classes. 552 This returns the access flags for the class as specified in the 553 class file rather than searching the InnerClasses attribute (if 554 present) to find the source-level access flags. Only the values of 555 the low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be 556 valid. */ 557 JNIEXPORT jint JNICALL 558 JVM_GetClassAccessFlags(JNIEnv *env, jclass cls); 559 560 /* 561 * Constant pool access; currently used to implement reflective access to annotations (JDK 1.5) 562 */ 563 564 JNIEXPORT jobject JNICALL 565 JVM_GetClassConstantPool(JNIEnv *env, jclass cls); 566 567 JNIEXPORT jint JNICALL JVM_ConstantPoolGetSize 568 (JNIEnv *env, jobject obj, jobject unused); 569 570 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAt 571 (JNIEnv *env, jobject obj, jobject unused, jint index); 572 573 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAtIfLoaded 574 (JNIEnv *env, jobject obj, jobject unused, jint index); 575 576 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAt 577 (JNIEnv *env, jobject obj, jobject unused, jint index); 578 579 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAtIfLoaded 580 (JNIEnv *env, jobject obj, jobject unused, jint index); 581 582 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAt 583 (JNIEnv *env, jobject obj, jobject unused, jint index); 584 585 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAtIfLoaded 586 (JNIEnv *env, jobject obj, jobject unused, jint index); 587 588 JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetMemberRefInfoAt 589 (JNIEnv *env, jobject obj, jobject unused, jint index); 590 591 JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetNameAndTypeRefInfoAt 592 (JNIEnv *env, jobject obj, jobject unused, jint index); 593 594 JNIEXPORT jint JNICALL JVM_ConstantPoolGetNameAndTypeRefIndexAt 595 (JNIEnv *env, jobject obj, jobject unused, jint index); 596 597 JNIEXPORT jint JNICALL JVM_ConstantPoolGetClassRefIndexAt 598 (JNIEnv *env, jobject obj, jobject unused, jint index); 599 600 JNIEXPORT jint JNICALL JVM_ConstantPoolGetIntAt 601 (JNIEnv *env, jobject obj, jobject unused, jint index); 602 603 JNIEXPORT jlong JNICALL JVM_ConstantPoolGetLongAt 604 (JNIEnv *env, jobject obj, jobject unused, jint index); 605 606 JNIEXPORT jfloat JNICALL JVM_ConstantPoolGetFloatAt 607 (JNIEnv *env, jobject obj, jobject unused, jint index); 608 609 JNIEXPORT jdouble JNICALL JVM_ConstantPoolGetDoubleAt 610 (JNIEnv *env, jobject obj, jobject unused, jint index); 611 612 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetStringAt 613 (JNIEnv *env, jobject obj, jobject unused, jint index); 614 615 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetUTF8At 616 (JNIEnv *env, jobject obj, jobject unused, jint index); 617 618 JNIEXPORT jbyte JNICALL JVM_ConstantPoolGetTagAt 619 (JNIEnv *env, jobject unused, jobject jcpool, jint index); 620 621 /* 622 * java.security.* 623 */ 624 625 JNIEXPORT jobject JNICALL 626 JVM_DoPrivileged(JNIEnv *env, jclass cls, 627 jobject action, jobject context, jboolean wrapException); 628 629 JNIEXPORT jobject JNICALL 630 JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls); 631 632 JNIEXPORT jobject JNICALL 633 JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls); 634 635 /* 636 * Signal support, used to implement the shutdown sequence. Every VM must 637 * support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts 638 * (^C) and the latter for external termination (kill, system shutdown, etc.). 639 * Other platform-dependent signal values may also be supported. 640 */ 641 642 JNIEXPORT void * JNICALL 643 JVM_RegisterSignal(jint sig, void *handler); 644 645 JNIEXPORT jboolean JNICALL 646 JVM_RaiseSignal(jint sig); 647 648 JNIEXPORT jint JNICALL 649 JVM_FindSignal(const char *name); 650 651 /* 652 * Retrieve the assertion directives for the specified class. 653 */ 654 JNIEXPORT jboolean JNICALL 655 JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls); 656 657 /* 658 * Retrieve the assertion directives from the VM. 659 */ 660 JNIEXPORT jobject JNICALL 661 JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused); 662 663 /* 664 * java.util.concurrent.atomic.AtomicLong 665 */ 666 JNIEXPORT jboolean JNICALL 667 JVM_SupportsCX8(void); 668 669 /************************************************************************* 670 PART 2: Support for the Verifier and Class File Format Checker 671 ************************************************************************/ 672 /* 673 * Return the class name in UTF format. The result is valid 674 * until JVM_ReleaseUTf is called. 675 * 676 * The caller must treat the string as a constant and not modify it 677 * in any way. 678 */ 679 JNIEXPORT const char * JNICALL 680 JVM_GetClassNameUTF(JNIEnv *env, jclass cb); 681 682 /* 683 * Returns the constant pool types in the buffer provided by "types." 684 */ 685 JNIEXPORT void JNICALL 686 JVM_GetClassCPTypes(JNIEnv *env, jclass cb, unsigned char *types); 687 688 /* 689 * Returns the number of Constant Pool entries. 690 */ 691 JNIEXPORT jint JNICALL 692 JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cb); 693 694 /* 695 * Returns the number of *declared* fields or methods. 696 */ 697 JNIEXPORT jint JNICALL 698 JVM_GetClassFieldsCount(JNIEnv *env, jclass cb); 699 700 JNIEXPORT jint JNICALL 701 JVM_GetClassMethodsCount(JNIEnv *env, jclass cb); 702 703 /* 704 * Returns the CP indexes of exceptions raised by a given method. 705 * Places the result in the given buffer. 706 * 707 * The method is identified by method_index. 708 */ 709 JNIEXPORT void JNICALL 710 JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cb, jint method_index, 711 unsigned short *exceptions); 712 /* 713 * Returns the number of exceptions raised by a given method. 714 * The method is identified by method_index. 715 */ 716 JNIEXPORT jint JNICALL 717 JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cb, jint method_index); 718 719 /* 720 * Returns the byte code sequence of a given method. 721 * Places the result in the given buffer. 722 * 723 * The method is identified by method_index. 724 */ 725 JNIEXPORT void JNICALL 726 JVM_GetMethodIxByteCode(JNIEnv *env, jclass cb, jint method_index, 727 unsigned char *code); 728 729 /* 730 * Returns the length of the byte code sequence of a given method. 731 * The method is identified by method_index. 732 */ 733 JNIEXPORT jint JNICALL 734 JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cb, jint method_index); 735 736 /* 737 * A structure used to a capture exception table entry in a Java method. 738 */ 739 typedef struct { 740 jint start_pc; 741 jint end_pc; 742 jint handler_pc; 743 jint catchType; 744 } JVM_ExceptionTableEntryType; 745 746 /* 747 * Returns the exception table entry at entry_index of a given method. 748 * Places the result in the given buffer. 749 * 750 * The method is identified by method_index. 751 */ 752 JNIEXPORT void JNICALL 753 JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cb, jint method_index, 754 jint entry_index, 755 JVM_ExceptionTableEntryType *entry); 756 757 /* 758 * Returns the length of the exception table of a given method. 759 * The method is identified by method_index. 760 */ 761 JNIEXPORT jint JNICALL 762 JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cb, int index); 763 764 /* 765 * Returns the modifiers of a given field. 766 * The field is identified by field_index. 767 */ 768 JNIEXPORT jint JNICALL 769 JVM_GetFieldIxModifiers(JNIEnv *env, jclass cb, int index); 770 771 /* 772 * Returns the modifiers of a given method. 773 * The method is identified by method_index. 774 */ 775 JNIEXPORT jint JNICALL 776 JVM_GetMethodIxModifiers(JNIEnv *env, jclass cb, int index); 777 778 /* 779 * Returns the number of local variables of a given method. 780 * The method is identified by method_index. 781 */ 782 JNIEXPORT jint JNICALL 783 JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cb, int index); 784 785 /* 786 * Returns the number of arguments (including this pointer) of a given method. 787 * The method is identified by method_index. 788 */ 789 JNIEXPORT jint JNICALL 790 JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cb, int index); 791 792 /* 793 * Returns the maximum amount of stack (in words) used by a given method. 794 * The method is identified by method_index. 795 */ 796 JNIEXPORT jint JNICALL 797 JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cb, int index); 798 799 /* 800 * Is a given method a constructor. 801 * The method is identified by method_index. 802 */ 803 JNIEXPORT jboolean JNICALL 804 JVM_IsConstructorIx(JNIEnv *env, jclass cb, int index); 805 806 /* 807 * Is the given method generated by the VM. 808 * The method is identified by method_index. 809 */ 810 JNIEXPORT jboolean JNICALL 811 JVM_IsVMGeneratedMethodIx(JNIEnv *env, jclass cb, int index); 812 813 /* 814 * Returns the name of a given method in UTF format. 815 * The result remains valid until JVM_ReleaseUTF is called. 816 * 817 * The caller must treat the string as a constant and not modify it 818 * in any way. 819 */ 820 JNIEXPORT const char * JNICALL 821 JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cb, jint index); 822 823 /* 824 * Returns the signature of a given method in UTF format. 825 * The result remains valid until JVM_ReleaseUTF is called. 826 * 827 * The caller must treat the string as a constant and not modify it 828 * in any way. 829 */ 830 JNIEXPORT const char * JNICALL 831 JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cb, jint index); 832 833 /* 834 * Returns the name of the field refered to at a given constant pool 835 * index. 836 * 837 * The result is in UTF format and remains valid until JVM_ReleaseUTF 838 * is called. 839 * 840 * The caller must treat the string as a constant and not modify it 841 * in any way. 842 */ 843 JNIEXPORT const char * JNICALL 844 JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cb, jint index); 845 846 /* 847 * Returns the name of the method refered to at a given constant pool 848 * index. 849 * 850 * The result is in UTF format and remains valid until JVM_ReleaseUTF 851 * is called. 852 * 853 * The caller must treat the string as a constant and not modify it 854 * in any way. 855 */ 856 JNIEXPORT const char * JNICALL 857 JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cb, jint index); 858 859 /* 860 * Returns the signature of the method refered to at a given constant pool 861 * index. 862 * 863 * The result is in UTF format and remains valid until JVM_ReleaseUTF 864 * is called. 865 * 866 * The caller must treat the string as a constant and not modify it 867 * in any way. 868 */ 869 JNIEXPORT const char * JNICALL 870 JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cb, jint index); 871 872 /* 873 * Returns the signature of the field refered to at a given constant pool 874 * index. 875 * 876 * The result is in UTF format and remains valid until JVM_ReleaseUTF 877 * is called. 878 * 879 * The caller must treat the string as a constant and not modify it 880 * in any way. 881 */ 882 JNIEXPORT const char * JNICALL 883 JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cb, jint index); 884 885 /* 886 * Returns the class name refered to at a given constant pool index. 887 * 888 * The result is in UTF format and remains valid until JVM_ReleaseUTF 889 * is called. 890 * 891 * The caller must treat the string as a constant and not modify it 892 * in any way. 893 */ 894 JNIEXPORT const char * JNICALL 895 JVM_GetCPClassNameUTF(JNIEnv *env, jclass cb, jint index); 896 897 /* 898 * Returns the class name refered to at a given constant pool index. 899 * 900 * The constant pool entry must refer to a CONSTANT_Fieldref. 901 * 902 * The result is in UTF format and remains valid until JVM_ReleaseUTF 903 * is called. 904 * 905 * The caller must treat the string as a constant and not modify it 906 * in any way. 907 */ 908 JNIEXPORT const char * JNICALL 909 JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cb, jint index); 910 911 /* 912 * Returns the class name refered to at a given constant pool index. 913 * 914 * The constant pool entry must refer to CONSTANT_Methodref or 915 * CONSTANT_InterfaceMethodref. 916 * 917 * The result is in UTF format and remains valid until JVM_ReleaseUTF 918 * is called. 919 * 920 * The caller must treat the string as a constant and not modify it 921 * in any way. 922 */ 923 JNIEXPORT const char * JNICALL 924 JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cb, jint index); 925 926 /* 927 * Returns the modifiers of a field in calledClass. The field is 928 * referred to in class cb at constant pool entry index. 929 * 930 * The caller must treat the string as a constant and not modify it 931 * in any way. 932 * 933 * Returns -1 if the field does not exist in calledClass. 934 */ 935 JNIEXPORT jint JNICALL 936 JVM_GetCPFieldModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass); 937 938 /* 939 * Returns the modifiers of a method in calledClass. The method is 940 * referred to in class cb at constant pool entry index. 941 * 942 * Returns -1 if the method does not exist in calledClass. 943 */ 944 JNIEXPORT jint JNICALL 945 JVM_GetCPMethodModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass); 946 947 /* 948 * Releases the UTF string obtained from the VM. 949 */ 950 JNIEXPORT void JNICALL 951 JVM_ReleaseUTF(const char *utf); 952 953 /* 954 * Compare if two classes are in the same package. 955 */ 956 JNIEXPORT jboolean JNICALL 957 JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2); 958 959 /* Constants in class files */ 960 961 #define JVM_ACC_PUBLIC 0x0001 /* visible to everyone */ 962 #define JVM_ACC_PRIVATE 0x0002 /* visible only to the defining class */ 963 #define JVM_ACC_PROTECTED 0x0004 /* visible to subclasses */ 964 #define JVM_ACC_STATIC 0x0008 /* instance variable is static */ 965 #define JVM_ACC_FINAL 0x0010 /* no further subclassing, overriding */ 966 #define JVM_ACC_SYNCHRONIZED 0x0020 /* wrap method call in monitor lock */ 967 #define JVM_ACC_SUPER 0x0020 /* funky handling of invokespecial */ 968 #define JVM_ACC_VOLATILE 0x0040 /* can not cache in registers */ 969 #define JVM_ACC_BRIDGE 0x0040 /* bridge method generated by compiler */ 970 #define JVM_ACC_TRANSIENT 0x0080 /* not persistent */ 971 #define JVM_ACC_VARARGS 0x0080 /* method declared with variable number of args */ 972 #define JVM_ACC_NATIVE 0x0100 /* implemented in C */ 973 #define JVM_ACC_INTERFACE 0x0200 /* class is an interface */ 974 #define JVM_ACC_ABSTRACT 0x0400 /* no definition provided */ 975 #define JVM_ACC_STRICT 0x0800 /* strict floating point */ 976 #define JVM_ACC_SYNTHETIC 0x1000 /* compiler-generated class, method or field */ 977 #define JVM_ACC_ANNOTATION 0x2000 /* annotation type */ 978 #define JVM_ACC_ENUM 0x4000 /* field is declared as element of enum */ 979 #define JVM_ACC_MODULE 0x8000 /* module-info class file */ 980 981 #define JVM_ACC_PUBLIC_BIT 0 982 #define JVM_ACC_PRIVATE_BIT 1 983 #define JVM_ACC_PROTECTED_BIT 2 984 #define JVM_ACC_STATIC_BIT 3 985 #define JVM_ACC_FINAL_BIT 4 986 #define JVM_ACC_SYNCHRONIZED_BIT 5 987 #define JVM_ACC_SUPER_BIT 5 988 #define JVM_ACC_VOLATILE_BIT 6 989 #define JVM_ACC_BRIDGE_BIT 6 990 #define JVM_ACC_TRANSIENT_BIT 7 991 #define JVM_ACC_VARARGS_BIT 7 992 #define JVM_ACC_NATIVE_BIT 8 993 #define JVM_ACC_INTERFACE_BIT 9 994 #define JVM_ACC_ABSTRACT_BIT 10 995 #define JVM_ACC_STRICT_BIT 11 996 #define JVM_ACC_SYNTHETIC_BIT 12 997 #define JVM_ACC_ANNOTATION_BIT 13 998 #define JVM_ACC_ENUM_BIT 14 999 1000 // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/utilities/ConstantTag.java 1001 enum { 1002 JVM_CONSTANT_Utf8 = 1, 1003 JVM_CONSTANT_Unicode, /* unused */ 1004 JVM_CONSTANT_Integer, 1005 JVM_CONSTANT_Float, 1006 JVM_CONSTANT_Long, 1007 JVM_CONSTANT_Double, 1008 JVM_CONSTANT_Class, 1009 JVM_CONSTANT_String, 1010 JVM_CONSTANT_Fieldref, 1011 JVM_CONSTANT_Methodref, 1012 JVM_CONSTANT_InterfaceMethodref, 1013 JVM_CONSTANT_NameAndType, 1014 JVM_CONSTANT_MethodHandle = 15, // JSR 292 1015 JVM_CONSTANT_MethodType = 16, // JSR 292 1016 //JVM_CONSTANT_(unused) = 17, // JSR 292 early drafts only 1017 JVM_CONSTANT_InvokeDynamic = 18, // JSR 292 1018 JVM_CONSTANT_ExternalMax = 18 // Last tag found in classfiles 1019 }; 1020 1021 /* JVM_CONSTANT_MethodHandle subtypes */ 1022 enum { 1023 JVM_REF_getField = 1, 1024 JVM_REF_getStatic = 2, 1025 JVM_REF_putField = 3, 1026 JVM_REF_putStatic = 4, 1027 JVM_REF_invokeVirtual = 5, 1028 JVM_REF_invokeStatic = 6, 1029 JVM_REF_invokeSpecial = 7, 1030 JVM_REF_newInvokeSpecial = 8, 1031 JVM_REF_invokeInterface = 9 1032 }; 1033 1034 /* Used in the newarray instruction. */ 1035 1036 #define JVM_T_BOOLEAN 4 1037 #define JVM_T_CHAR 5 1038 #define JVM_T_FLOAT 6 1039 #define JVM_T_DOUBLE 7 1040 #define JVM_T_BYTE 8 1041 #define JVM_T_SHORT 9 1042 #define JVM_T_INT 10 1043 #define JVM_T_LONG 11 1044 1045 /* JVM method signatures */ 1046 1047 #define JVM_SIGNATURE_ARRAY '[' 1048 #define JVM_SIGNATURE_BYTE 'B' 1049 #define JVM_SIGNATURE_CHAR 'C' 1050 #define JVM_SIGNATURE_CLASS 'L' 1051 #define JVM_SIGNATURE_ENDCLASS ';' 1052 #define JVM_SIGNATURE_ENUM 'E' 1053 #define JVM_SIGNATURE_FLOAT 'F' 1054 #define JVM_SIGNATURE_DOUBLE 'D' 1055 #define JVM_SIGNATURE_FUNC '(' 1056 #define JVM_SIGNATURE_ENDFUNC ')' 1057 #define JVM_SIGNATURE_INT 'I' 1058 #define JVM_SIGNATURE_LONG 'J' 1059 #define JVM_SIGNATURE_SHORT 'S' 1060 #define JVM_SIGNATURE_VOID 'V' 1061 #define JVM_SIGNATURE_BOOLEAN 'Z' 1062 1063 /* 1064 * A function defined by the byte-code verifier and called by the VM. 1065 * This is not a function implemented in the VM. 1066 * 1067 * Returns JNI_FALSE if verification fails. A detailed error message 1068 * will be places in msg_buf, whose length is specified by buf_len. 1069 */ 1070 typedef jboolean (*verifier_fn_t)(JNIEnv *env, 1071 jclass cb, 1072 char * msg_buf, 1073 jint buf_len); 1074 1075 1076 /* 1077 * Support for a VM-independent class format checker. 1078 */ 1079 typedef struct { 1080 unsigned long code; /* byte code */ 1081 unsigned long excs; /* exceptions */ 1082 unsigned long etab; /* catch table */ 1083 unsigned long lnum; /* line number */ 1084 unsigned long lvar; /* local vars */ 1085 } method_size_info; 1086 1087 typedef struct { 1088 unsigned int constants; /* constant pool */ 1089 unsigned int fields; 1090 unsigned int methods; 1091 unsigned int interfaces; 1092 unsigned int fields2; /* number of static 2-word fields */ 1093 unsigned int innerclasses; /* # of records in InnerClasses attr */ 1094 1095 method_size_info clinit; /* memory used in clinit */ 1096 method_size_info main; /* used everywhere else */ 1097 } class_size_info; 1098 1099 /* 1100 * Functions defined in libjava.so to perform string conversions. 1101 * 1102 */ 1103 1104 typedef jstring (*to_java_string_fn_t)(JNIEnv *env, char *str); 1105 1106 typedef char *(*to_c_string_fn_t)(JNIEnv *env, jstring s, jboolean *b); 1107 1108 /* This is the function defined in libjava.so that performs class 1109 * format checks. This functions fills in size information about 1110 * the class file and returns: 1111 * 1112 * 0: good 1113 * -1: out of memory 1114 * -2: bad format 1115 * -3: unsupported version 1116 * -4: bad class name 1117 */ 1118 1119 typedef jint (*check_format_fn_t)(char *class_name, 1120 unsigned char *data, 1121 unsigned int data_size, 1122 class_size_info *class_size, 1123 char *message_buffer, 1124 jint buffer_length, 1125 jboolean measure_only, 1126 jboolean check_relaxed); 1127 1128 #define JVM_RECOGNIZED_CLASS_MODIFIERS (JVM_ACC_PUBLIC | \ 1129 JVM_ACC_FINAL | \ 1130 JVM_ACC_SUPER | \ 1131 JVM_ACC_INTERFACE | \ 1132 JVM_ACC_ABSTRACT | \ 1133 JVM_ACC_ANNOTATION | \ 1134 JVM_ACC_ENUM | \ 1135 JVM_ACC_SYNTHETIC) 1136 1137 #define JVM_RECOGNIZED_FIELD_MODIFIERS (JVM_ACC_PUBLIC | \ 1138 JVM_ACC_PRIVATE | \ 1139 JVM_ACC_PROTECTED | \ 1140 JVM_ACC_STATIC | \ 1141 JVM_ACC_FINAL | \ 1142 JVM_ACC_VOLATILE | \ 1143 JVM_ACC_TRANSIENT | \ 1144 JVM_ACC_ENUM | \ 1145 JVM_ACC_SYNTHETIC) 1146 1147 #define JVM_RECOGNIZED_METHOD_MODIFIERS (JVM_ACC_PUBLIC | \ 1148 JVM_ACC_PRIVATE | \ 1149 JVM_ACC_PROTECTED | \ 1150 JVM_ACC_STATIC | \ 1151 JVM_ACC_FINAL | \ 1152 JVM_ACC_SYNCHRONIZED | \ 1153 JVM_ACC_BRIDGE | \ 1154 JVM_ACC_VARARGS | \ 1155 JVM_ACC_NATIVE | \ 1156 JVM_ACC_ABSTRACT | \ 1157 JVM_ACC_STRICT | \ 1158 JVM_ACC_SYNTHETIC) 1159 1160 /* 1161 * This is the function defined in libjava.so to perform path 1162 * canonicalization. VM call this function before opening jar files 1163 * to load system classes. 1164 * 1165 */ 1166 1167 typedef int (*canonicalize_fn_t)(JNIEnv *env, char *orig, char *out, int len); 1168 1169 /************************************************************************* 1170 PART 3: I/O and Network Support 1171 ************************************************************************/ 1172 1173 /* 1174 * Convert a pathname into native format. This function does syntactic 1175 * cleanup, such as removing redundant separator characters. It modifies 1176 * the given pathname string in place. 1177 */ 1178 JNIEXPORT char * JNICALL 1179 JVM_NativePath(char *); 1180 1181 /* 1182 * The standard printing functions supported by the Java VM. (Should they 1183 * be renamed to JVM_* in the future? 1184 */ 1185 1186 /* jio_snprintf() and jio_vsnprintf() behave like snprintf(3) and vsnprintf(3), 1187 * respectively, with the following differences: 1188 * - The string written to str is always zero-terminated, also in case of 1189 * truncation (count is too small to hold the result string), unless count 1190 * is 0. In case of truncation count-1 characters are written and '\0' 1191 * appendend. 1192 * - If count is too small to hold the whole string, -1 is returned across 1193 * all platforms. */ 1194 JNIEXPORT int 1195 jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args); 1196 1197 JNIEXPORT int 1198 jio_snprintf(char *str, size_t count, const char *fmt, ...); 1199 1200 JNIEXPORT int 1201 jio_fprintf(FILE *, const char *fmt, ...); 1202 1203 JNIEXPORT int 1204 jio_vfprintf(FILE *, const char *fmt, va_list args); 1205 1206 1207 JNIEXPORT void * JNICALL 1208 JVM_RawMonitorCreate(void); 1209 1210 JNIEXPORT void JNICALL 1211 JVM_RawMonitorDestroy(void *mon); 1212 1213 JNIEXPORT jint JNICALL 1214 JVM_RawMonitorEnter(void *mon); 1215 1216 JNIEXPORT void JNICALL 1217 JVM_RawMonitorExit(void *mon); 1218 1219 /* 1220 * java.lang.reflect.Method 1221 */ 1222 JNIEXPORT jobject JNICALL 1223 JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0); 1224 1225 /* 1226 * java.lang.reflect.Constructor 1227 */ 1228 JNIEXPORT jobject JNICALL 1229 JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0); 1230 1231 /* 1232 * java.lang.management support 1233 */ 1234 JNIEXPORT void* JNICALL 1235 JVM_GetManagement(jint version); 1236 1237 /* 1238 * com.sun.tools.attach.VirtualMachine support 1239 * 1240 * Initialize the agent properties with the properties maintained in the VM. 1241 */ 1242 JNIEXPORT jobject JNICALL 1243 JVM_InitAgentProperties(JNIEnv *env, jobject agent_props); 1244 1245 JNIEXPORT jstring JNICALL 1246 JVM_GetTemporaryDirectory(JNIEnv *env); 1247 1248 /* Generics reflection support. 1249 * 1250 * Returns information about the given class's EnclosingMethod 1251 * attribute, if present, or null if the class had no enclosing 1252 * method. 1253 * 1254 * If non-null, the returned array contains three elements. Element 0 1255 * is the java.lang.Class of which the enclosing method is a member, 1256 * and elements 1 and 2 are the java.lang.Strings for the enclosing 1257 * method's name and descriptor, respectively. 1258 */ 1259 JNIEXPORT jobjectArray JNICALL 1260 JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass); 1261 1262 /* ========================================================================= 1263 * The following defines a private JVM interface that the JDK can query 1264 * for the JVM version and capabilities. sun.misc.Version defines 1265 * the methods for getting the VM version and its capabilities. 1266 * 1267 * When a new bit is added, the following should be updated to provide 1268 * access to the new capability: 1269 * HS: JVM_GetVersionInfo and Abstract_VM_Version class 1270 * SDK: Version class 1271 * 1272 * Similary, a private JDK interface JDK_GetVersionInfo0 is defined for 1273 * JVM to query for the JDK version and capabilities. 1274 * 1275 * When a new bit is added, the following should be updated to provide 1276 * access to the new capability: 1277 * HS: JDK_Version class 1278 * SDK: JDK_GetVersionInfo0 1279 * 1280 * ========================================================================== 1281 */ 1282 typedef struct { 1283 unsigned int jvm_version; /* Encoded $VNUM as defined by JEP-223 */ 1284 unsigned int patch_version : 8; /* JEP-223 patch version */ 1285 unsigned int reserved3 : 8; 1286 unsigned int reserved1 : 16; 1287 unsigned int reserved2; 1288 1289 /* The following bits represents JVM supports that JDK has dependency on. 1290 * JDK can use these bits to determine which JVM version 1291 * and support it has to maintain runtime compatibility. 1292 * 1293 * When a new bit is added in a minor or update release, make sure 1294 * the new bit is also added in the main/baseline. 1295 */ 1296 unsigned int is_attachable : 1; 1297 unsigned int : 31; 1298 unsigned int : 32; 1299 unsigned int : 32; 1300 } jvm_version_info; 1301 1302 #define JVM_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24) 1303 #define JVM_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16) 1304 #define JVM_VERSION_SECURITY(version) ((version & 0x0000FF00) >> 8) 1305 #define JVM_VERSION_BUILD(version) ((version & 0x000000FF)) 1306 1307 JNIEXPORT void JNICALL 1308 JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size); 1309 1310 typedef struct { 1311 unsigned int jdk_version; /* Encoded $VNUM as defined by JEP-223 */ 1312 unsigned int patch_version : 8; /* JEP-223 patch version */ 1313 unsigned int reserved3 : 8; 1314 unsigned int reserved1 : 16; 1315 unsigned int reserved2; 1316 1317 /* The following bits represents new JDK supports that VM has dependency on. 1318 * VM implementation can use these bits to determine which JDK version 1319 * and support it has to maintain runtime compatibility. 1320 * 1321 * When a new bit is added in a minor or update release, make sure 1322 * the new bit is also added in the main/baseline. 1323 */ 1324 unsigned int thread_park_blocker : 1; 1325 unsigned int post_vm_init_hook_enabled : 1; 1326 unsigned int pending_list_uses_discovered_field : 1; 1327 unsigned int : 29; 1328 unsigned int : 32; 1329 unsigned int : 32; 1330 } jdk_version_info; 1331 1332 #define JDK_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24) 1333 #define JDK_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16) 1334 #define JDK_VERSION_SECURITY(version) ((version & 0x0000FF00) >> 8) 1335 #define JDK_VERSION_BUILD(version) ((version & 0x000000FF)) 1336 1337 /* 1338 * This is the function JDK_GetVersionInfo0 defined in libjava.so 1339 * that is dynamically looked up by JVM. 1340 */ 1341 typedef void (*jdk_version_info_fn_t)(jdk_version_info* info, size_t info_size); 1342 1343 /* 1344 * This structure is used by the launcher to get the default thread 1345 * stack size from the VM using JNI_GetDefaultJavaVMInitArgs() with a 1346 * version of 1.1. As it is not supported otherwise, it has been removed 1347 * from jni.h 1348 */ 1349 typedef struct JDK1_1InitArgs { 1350 jint version; 1351 1352 char **properties; 1353 jint checkSource; 1354 jint nativeStackSize; 1355 jint javaStackSize; 1356 jint minHeapSize; 1357 jint maxHeapSize; 1358 jint verifyMode; 1359 char *classpath; 1360 1361 jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args); 1362 void (JNICALL *exit)(jint code); 1363 void (JNICALL *abort)(void); 1364 1365 jint enableClassGC; 1366 jint enableVerboseGC; 1367 jint disableAsyncGC; 1368 jint verbose; 1369 jboolean debugging; 1370 jint debugPort; 1371 } JDK1_1InitArgs; 1372 1373 #ifdef __cplusplus 1374 } /* extern "C" */ 1375 #endif /* __cplusplus */ 1376 1377 #endif /* !_JAVASOFT_JVM_H_ */ 1378 1379 #endif // SHARE_VM_PRIMS_JVM_H