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