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