1/* 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26#ifndef _JAVASOFT_JVM_H_ 27#define _JAVASOFT_JVM_H_ 28 29#include <sys/stat.h> 30 31#include "jni.h" 32#include "jvm_md.h" 33 34#ifdef __cplusplus 35extern "C" { 36#endif 37 38/* 39 * This file contains additional functions exported from the VM. 40 * These functions are complementary to the standard JNI support. 41 * There are three parts to this file: 42 * 43 * First, this file contains the VM-related functions needed by native 44 * libraries in the standard Java API. For example, the java.lang.Object 45 * class needs VM-level functions that wait for and notify monitors. 46 * 47 * Second, this file contains the functions and constant definitions 48 * needed by the byte code verifier and class file format checker. 49 * These functions allow the verifier and format checker to be written 50 * in a VM-independent way. 51 * 52 * Third, this file contains various I/O and nerwork operations needed 53 * by the standard Java I/O and network APIs. 54 */ 55 56/* 57 * Bump the version number when either of the following happens: 58 * 59 * 1. There is a change in JVM_* functions. 60 * 61 * 2. There is a change in the contract between VM and Java classes. 62 * For example, if the VM relies on a new private field in Thread 63 * class. 64 */ 65 66#define JVM_INTERFACE_VERSION 4 67 68JNIEXPORT jint JNICALL 69JVM_GetInterfaceVersion(void); 70 71/************************************************************************* 72 PART 1: Functions for Native Libraries 73 ************************************************************************/ 74/* 75 * java.lang.Object 76 */ 77JNIEXPORT jint JNICALL 78JVM_IHashCode(JNIEnv *env, jobject obj); 79 80JNIEXPORT void JNICALL 81JVM_MonitorWait(JNIEnv *env, jobject obj, jlong ms); 82 83JNIEXPORT void JNICALL 84JVM_MonitorNotify(JNIEnv *env, jobject obj); 85 86JNIEXPORT void JNICALL 87JVM_MonitorNotifyAll(JNIEnv *env, jobject obj); 88 89JNIEXPORT jobject JNICALL 90JVM_Clone(JNIEnv *env, jobject obj); 91 92/* 93 * java.lang.String 94 */ 95JNIEXPORT jstring JNICALL 96JVM_InternString(JNIEnv *env, jstring str); 97 98/* 99 * java.lang.System 100 */ 101JNIEXPORT jlong JNICALL 102JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored); 103 104JNIEXPORT jlong JNICALL 105JVM_NanoTime(JNIEnv *env, jclass ignored); 106 107JNIEXPORT void JNICALL 108JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos, 109 jobject dst, jint dst_pos, jint length); 110 111JNIEXPORT jobject JNICALL 112JVM_InitProperties(JNIEnv *env, jobject p); 113 114/* 115 * java.io.File 116 */ 117JNIEXPORT void JNICALL 118JVM_OnExit(void (*func)(void)); 119 120/* 121 * java.lang.Runtime 122 */ 123JNIEXPORT void JNICALL 124JVM_Exit(jint code); 125 126JNIEXPORT void JNICALL 127JVM_Halt(jint code); 128 129JNIEXPORT void JNICALL 130JVM_GC(void); 131 132/* Returns the number of real-time milliseconds that have elapsed since the 133 * least-recently-inspected heap object was last inspected by the garbage 134 * collector. 135 * 136 * For simple stop-the-world collectors this value is just the time 137 * since the most recent collection. For generational collectors it is the 138 * time since the oldest generation was most recently collected. Other 139 * collectors are free to return a pessimistic estimate of the elapsed time, or 140 * simply the time since the last full collection was performed. 141 * 142 * Note that in the presence of reference objects, a given object that is no 143 * longer strongly reachable may have to be inspected multiple times before it 144 * can be reclaimed. 145 */ 146JNIEXPORT jlong JNICALL 147JVM_MaxObjectInspectionAge(void); 148 149JNIEXPORT void JNICALL 150JVM_TraceInstructions(jboolean on); 151 152JNIEXPORT void JNICALL 153JVM_TraceMethodCalls(jboolean on); 154 155JNIEXPORT jlong JNICALL 156JVM_TotalMemory(void); 157 158JNIEXPORT jlong JNICALL 159JVM_FreeMemory(void); 160 161JNIEXPORT jlong JNICALL 162JVM_MaxMemory(void); 163 164JNIEXPORT jint JNICALL 165JVM_ActiveProcessorCount(void); 166 167JNIEXPORT void * JNICALL 168JVM_LoadLibrary(const char *name); 169 170JNIEXPORT void JNICALL 171JVM_UnloadLibrary(void * handle); 172 173JNIEXPORT void * JNICALL 174JVM_FindLibraryEntry(void *handle, const char *name); 175 176JNIEXPORT jboolean JNICALL 177JVM_IsSupportedJNIVersion(jint version); 178 179/* 180 * java.lang.Float and java.lang.Double 181 */ 182JNIEXPORT jboolean JNICALL 183JVM_IsNaN(jdouble d); 184 185/* 186 * java.lang.Throwable 187 */ 188JNIEXPORT void JNICALL 189JVM_FillInStackTrace(JNIEnv *env, jobject throwable); 190 191JNIEXPORT jint JNICALL 192JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable); 193 194JNIEXPORT jobject JNICALL 195JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index); 196 197/* 198 * java.lang.Compiler 199 */ 200JNIEXPORT void JNICALL 201JVM_InitializeCompiler (JNIEnv *env, jclass compCls); 202 203JNIEXPORT jboolean JNICALL 204JVM_IsSilentCompiler(JNIEnv *env, jclass compCls); 205 206JNIEXPORT jboolean JNICALL 207JVM_CompileClass(JNIEnv *env, jclass compCls, jclass cls); 208 209JNIEXPORT jboolean JNICALL 210JVM_CompileClasses(JNIEnv *env, jclass cls, jstring jname); 211 212JNIEXPORT jobject JNICALL 213JVM_CompilerCommand(JNIEnv *env, jclass compCls, jobject arg); 214 215JNIEXPORT void JNICALL 216JVM_EnableCompiler(JNIEnv *env, jclass compCls); 217 218JNIEXPORT void JNICALL 219JVM_DisableCompiler(JNIEnv *env, jclass compCls); 220 221/* 222 * java.lang.Thread 223 */ 224JNIEXPORT void JNICALL 225JVM_StartThread(JNIEnv *env, jobject thread); 226 227JNIEXPORT void JNICALL 228JVM_StopThread(JNIEnv *env, jobject thread, jobject exception); 229 230JNIEXPORT jboolean JNICALL 231JVM_IsThreadAlive(JNIEnv *env, jobject thread); 232 233JNIEXPORT void JNICALL 234JVM_SuspendThread(JNIEnv *env, jobject thread); 235 236JNIEXPORT void JNICALL 237JVM_ResumeThread(JNIEnv *env, jobject thread); 238 239JNIEXPORT void JNICALL 240JVM_SetThreadPriority(JNIEnv *env, jobject thread, jint prio); 241 242JNIEXPORT void JNICALL 243JVM_Yield(JNIEnv *env, jclass threadClass); 244 245JNIEXPORT void JNICALL 246JVM_Sleep(JNIEnv *env, jclass threadClass, jlong millis); 247 248JNIEXPORT jobject JNICALL 249JVM_CurrentThread(JNIEnv *env, jclass threadClass); 250 251JNIEXPORT jint JNICALL 252JVM_CountStackFrames(JNIEnv *env, jobject thread); 253 254JNIEXPORT void JNICALL 255JVM_Interrupt(JNIEnv *env, jobject thread); 256 257JNIEXPORT jboolean JNICALL 258JVM_IsInterrupted(JNIEnv *env, jobject thread, jboolean clearInterrupted); 259 260JNIEXPORT jboolean JNICALL 261JVM_HoldsLock(JNIEnv *env, jclass threadClass, jobject obj); 262 263JNIEXPORT void JNICALL 264JVM_DumpAllStacks(JNIEnv *env, jclass unused); 265 266JNIEXPORT jobjectArray JNICALL 267JVM_GetAllThreads(JNIEnv *env, jclass dummy); 268 269JNIEXPORT void JNICALL 270JVM_SetNativeThreadName(JNIEnv *env, jobject jthread, jstring name); 271 272/* getStackTrace() and getAllStackTraces() method */ 273JNIEXPORT jobjectArray JNICALL 274JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads); 275 276/* 277 * java.lang.SecurityManager 278 */ 279JNIEXPORT jclass JNICALL 280JVM_CurrentLoadedClass(JNIEnv *env); 281 282JNIEXPORT jobject JNICALL 283JVM_CurrentClassLoader(JNIEnv *env); 284 285JNIEXPORT jobjectArray JNICALL 286JVM_GetClassContext(JNIEnv *env); 287 288JNIEXPORT jint JNICALL 289JVM_ClassDepth(JNIEnv *env, jstring name); 290 291JNIEXPORT jint JNICALL 292JVM_ClassLoaderDepth(JNIEnv *env); 293 294/* 295 * java.lang.Package 296 */ 297JNIEXPORT jstring JNICALL 298JVM_GetSystemPackage(JNIEnv *env, jstring name); 299 300JNIEXPORT jobjectArray JNICALL 301JVM_GetSystemPackages(JNIEnv *env); 302 303/* 304 * java.io.ObjectInputStream 305 */ 306JNIEXPORT jobject JNICALL 307JVM_AllocateNewObject(JNIEnv *env, jobject obj, jclass currClass, 308 jclass initClass); 309 310JNIEXPORT jobject JNICALL 311JVM_AllocateNewArray(JNIEnv *env, jobject obj, jclass currClass, 312 jint length); 313 314JNIEXPORT jobject JNICALL 315JVM_LatestUserDefinedLoader(JNIEnv *env); 316 317/* 318 * This function has been deprecated and should not be considered 319 * part of the specified JVM interface. 320 */ 321JNIEXPORT jclass JNICALL 322JVM_LoadClass0(JNIEnv *env, jobject obj, jclass currClass, 323 jstring currClassName); 324 325/* 326 * java.lang.reflect.Array 327 */ 328JNIEXPORT jint JNICALL 329JVM_GetArrayLength(JNIEnv *env, jobject arr); 330 331JNIEXPORT jobject JNICALL 332JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index); 333 334JNIEXPORT jvalue JNICALL 335JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode); 336 337JNIEXPORT void JNICALL 338JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val); 339 340JNIEXPORT void JNICALL 341JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v, 342 unsigned char vCode); 343 344JNIEXPORT jobject JNICALL 345JVM_NewArray(JNIEnv *env, jclass eltClass, jint length); 346 347JNIEXPORT jobject JNICALL 348JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim); 349 350/* 351 * java.lang.Class and java.lang.ClassLoader 352 */ 353 354#define JVM_CALLER_DEPTH -1 355 356/* 357 * Returns the immediate caller class of the native method invoking 358 * JVM_GetCallerClass. The Method.invoke and other frames due to 359 * reflection machinery are skipped. 360 * 361 * The depth parameter must be -1 (JVM_DEPTH). The caller is expected 362 * to be marked with sun.reflect.CallerSensitive. The JVM will throw 363 * an error if it is not marked propertly. 364 */ 365JNIEXPORT jclass JNICALL 366JVM_GetCallerClass(JNIEnv *env, int depth); 367 368 369/* 370 * Find primitive classes 371 * utf: class name 372 */ 373JNIEXPORT jclass JNICALL 374JVM_FindPrimitiveClass(JNIEnv *env, const char *utf); 375 376/* 377 * Link the class 378 */ 379JNIEXPORT void JNICALL 380JVM_ResolveClass(JNIEnv *env, jclass cls); 381 382/* 383 * Find a class from a boot class loader. Returns NULL if class not found. 384 */ 385JNIEXPORT jclass JNICALL 386JVM_FindClassFromBootLoader(JNIEnv *env, const char *name); 387 388/* 389 * Find a class from a given class loader. Throws ClassNotFoundException. 390 * name: name of class 391 * init: whether initialization is done 392 * loader: class loader to look up the class. This may not be the same as the caller's 393 * class loader. 394 * caller: initiating class. The initiating class may be null when a security 395 * manager is not installed. 396 */ 397JNIEXPORT jclass JNICALL 398JVM_FindClassFromCaller(JNIEnv *env, const char *name, jboolean init, 399 jobject loader, jclass caller); 400 401/* 402 * Find a class from a given class loader. Throw ClassNotFoundException 403 * or NoClassDefFoundError depending on the value of the last 404 * argument. 405 */ 406JNIEXPORT jclass JNICALL 407JVM_FindClassFromClassLoader(JNIEnv *env, const char *name, jboolean init, 408 jobject loader, jboolean throwError); 409 410/* 411 * Find a class from a given class. 412 */ 413JNIEXPORT jclass JNICALL 414JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init, 415 jclass from); 416 417/* Find a loaded class cached by the VM */ 418JNIEXPORT jclass JNICALL 419JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name); 420 421/* Define a class */ 422JNIEXPORT jclass JNICALL 423JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, 424 jsize len, jobject pd); 425 426/* Define a class with a source (added in JDK1.5) */ 427JNIEXPORT jclass JNICALL 428JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, 429 const jbyte *buf, jsize len, jobject pd, 430 const char *source); 431 432/* 433 * Reflection support functions 434 */ 435 436JNIEXPORT jstring JNICALL 437JVM_GetClassName(JNIEnv *env, jclass cls); 438 439JNIEXPORT jobjectArray JNICALL 440JVM_GetClassInterfaces(JNIEnv *env, jclass cls); 441 442JNIEXPORT jboolean JNICALL 443JVM_IsInterface(JNIEnv *env, jclass cls); 444 445JNIEXPORT jobjectArray JNICALL 446JVM_GetClassSigners(JNIEnv *env, jclass cls); 447 448JNIEXPORT void JNICALL 449JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers); 450 451JNIEXPORT jobject JNICALL 452JVM_GetProtectionDomain(JNIEnv *env, jclass cls); 453 454JNIEXPORT jboolean JNICALL 455JVM_IsArrayClass(JNIEnv *env, jclass cls); 456 457JNIEXPORT jboolean JNICALL 458JVM_IsPrimitiveClass(JNIEnv *env, jclass cls); 459 460JNIEXPORT jclass JNICALL 461JVM_GetComponentType(JNIEnv *env, jclass cls); 462 463JNIEXPORT jint JNICALL 464JVM_GetClassModifiers(JNIEnv *env, jclass cls); 465 466JNIEXPORT jobjectArray JNICALL 467JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass); 468 469JNIEXPORT jclass JNICALL 470JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass); 471 472/* Generics support (JDK 1.5) */ 473JNIEXPORT jstring JNICALL 474JVM_GetClassSignature(JNIEnv *env, jclass cls); 475 476/* Annotations support (JDK 1.5) */ 477JNIEXPORT jbyteArray JNICALL 478JVM_GetClassAnnotations(JNIEnv *env, jclass cls); 479 480/* Type use annotations support (JDK 1.8) */ 481 482JNIEXPORT jbyteArray JNICALL 483JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls); 484 485JNIEXPORT jbyteArray JNICALL 486JVM_GetFieldTypeAnnotations(JNIEnv *env, jobject field); 487 488JNIEXPORT jbyteArray JNICALL 489JVM_GetMethodTypeAnnotations(JNIEnv *env, jobject method); 490 491/* 492 * New (JDK 1.4) reflection implementation 493 */ 494 495JNIEXPORT jobjectArray JNICALL 496JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly); 497 498JNIEXPORT jobjectArray JNICALL 499JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly); 500 501JNIEXPORT jobjectArray JNICALL 502JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly); 503 504/* Differs from JVM_GetClassModifiers in treatment of inner classes. 505 This returns the access flags for the class as specified in the 506 class file rather than searching the InnerClasses attribute (if 507 present) to find the source-level access flags. Only the values of 508 the low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be 509 valid. */ 510JNIEXPORT jint JNICALL 511JVM_GetClassAccessFlags(JNIEnv *env, jclass cls); 512 513/* The following two reflection routines are still needed due to startup time issues */ 514/* 515 * java.lang.reflect.Method 516 */ 517JNIEXPORT jobject JNICALL 518JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0); 519 520/* 521 * java.lang.reflect.Constructor 522 */ 523JNIEXPORT jobject JNICALL 524JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0); 525 526/* 527 * Constant pool access; currently used to implement reflective access to annotations (JDK 1.5) 528 */ 529 530JNIEXPORT jobject JNICALL 531JVM_GetClassConstantPool(JNIEnv *env, jclass cls); 532 533JNIEXPORT jint JNICALL JVM_ConstantPoolGetSize 534(JNIEnv *env, jobject unused, jobject jcpool); 535 536JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAt 537(JNIEnv *env, jobject unused, jobject jcpool, jint index); 538 539JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAtIfLoaded 540(JNIEnv *env, jobject unused, jobject jcpool, jint index); 541 542JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAt 543(JNIEnv *env, jobject unused, jobject jcpool, jint index); 544 545JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAtIfLoaded 546(JNIEnv *env, jobject unused, jobject jcpool, jint index); 547 548JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAt 549(JNIEnv *env, jobject unused, jobject jcpool, jint index); 550 551JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAtIfLoaded 552(JNIEnv *env, jobject unused, jobject jcpool, jint index); 553 554JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetMemberRefInfoAt 555(JNIEnv *env, jobject unused, jobject jcpool, jint index); 556 557JNIEXPORT jint JNICALL JVM_ConstantPoolGetIntAt 558(JNIEnv *env, jobject unused, jobject jcpool, jint index); 559 560JNIEXPORT jlong JNICALL JVM_ConstantPoolGetLongAt 561(JNIEnv *env, jobject unused, jobject jcpool, jint index); 562 563JNIEXPORT jfloat JNICALL JVM_ConstantPoolGetFloatAt 564(JNIEnv *env, jobject unused, jobject jcpool, jint index); 565 566JNIEXPORT jdouble JNICALL JVM_ConstantPoolGetDoubleAt 567(JNIEnv *env, jobject unused, jobject jcpool, jint index); 568 569JNIEXPORT jstring JNICALL JVM_ConstantPoolGetStringAt 570(JNIEnv *env, jobject unused, jobject jcpool, jint index); 571 572JNIEXPORT jstring JNICALL JVM_ConstantPoolGetUTF8At 573(JNIEnv *env, jobject unused, jobject jcpool, jint index); 574 575/* 576 * Parameter reflection 577 */ 578 579JNIEXPORT jobjectArray JNICALL 580JVM_GetMethodParameters(JNIEnv *env, jobject method); 581 582/* 583 * java.security.* 584 */ 585 586JNIEXPORT jobject JNICALL 587JVM_DoPrivileged(JNIEnv *env, jclass cls, 588 jobject action, jobject context, jboolean wrapException); 589 590JNIEXPORT jobject JNICALL 591JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls); 592 593JNIEXPORT jobject JNICALL 594JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls); 595 596/* 597 * Signal support, used to implement the shutdown sequence. Every VM must 598 * support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts 599 * (^C) and the latter for external termination (kill, system shutdown, etc.). 600 * Other platform-dependent signal values may also be supported. 601 */ 602 603JNIEXPORT void * JNICALL 604JVM_RegisterSignal(jint sig, void *handler); 605 606JNIEXPORT jboolean JNICALL 607JVM_RaiseSignal(jint sig); 608 609JNIEXPORT jint JNICALL 610JVM_FindSignal(const char *name); 611 612/* 613 * Retrieve the assertion directives for the specified class. 614 */ 615JNIEXPORT jboolean JNICALL 616JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls); 617 618/* 619 * Retrieve the assertion directives from the VM. 620 */ 621JNIEXPORT jobject JNICALL 622JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused); 623 624/* 625 * java.util.concurrent.atomic.AtomicLong 626 */ 627JNIEXPORT jboolean JNICALL 628JVM_SupportsCX8(void); 629 630/* 631 * com.sun.dtrace.jsdt support 632 */ 633 634#define JVM_TRACING_DTRACE_VERSION 1 635 636/* 637 * Structure to pass one probe description to JVM 638 */ 639typedef struct { 640 jmethodID method; 641 jstring function; 642 jstring name; 643 void* reserved[4]; // for future use 644} JVM_DTraceProbe; 645 646/** 647 * Encapsulates the stability ratings for a DTrace provider field 648 */ 649typedef struct { 650 jint nameStability; 651 jint dataStability; 652 jint dependencyClass; 653} JVM_DTraceInterfaceAttributes; 654 655/* 656 * Structure to pass one provider description to JVM 657 */ 658typedef struct { 659 jstring name; 660 JVM_DTraceProbe* probes; 661 jint probe_count; 662 JVM_DTraceInterfaceAttributes providerAttributes; 663 JVM_DTraceInterfaceAttributes moduleAttributes; 664 JVM_DTraceInterfaceAttributes functionAttributes; 665 JVM_DTraceInterfaceAttributes nameAttributes; 666 JVM_DTraceInterfaceAttributes argsAttributes; 667 void* reserved[4]; // for future use 668} JVM_DTraceProvider; 669 670/* 671 * Get the version number the JVM was built with 672 */ 673JNIEXPORT jint JNICALL 674JVM_DTraceGetVersion(JNIEnv* env); 675 676/* 677 * Register new probe with given signature, return global handle 678 * 679 * The version passed in is the version that the library code was 680 * built with. 681 */ 682JNIEXPORT jlong JNICALL 683JVM_DTraceActivate(JNIEnv* env, jint version, jstring module_name, 684 jint providers_count, JVM_DTraceProvider* providers); 685 686/* 687 * Check JSDT probe 688 */ 689JNIEXPORT jboolean JNICALL 690JVM_DTraceIsProbeEnabled(JNIEnv* env, jmethodID method); 691 692/* 693 * Destroy custom DOF 694 */ 695JNIEXPORT void JNICALL 696JVM_DTraceDispose(JNIEnv* env, jlong activation_handle); 697 698/* 699 * Check to see if DTrace is supported by OS 700 */ 701JNIEXPORT jboolean JNICALL 702JVM_DTraceIsSupported(JNIEnv* env); 703 704/************************************************************************* 705 PART 2: Support for the Verifier and Class File Format Checker 706 ************************************************************************/ 707/* 708 * Return the class name in UTF format. The result is valid 709 * until JVM_ReleaseUTf is called. 710 * 711 * The caller must treat the string as a constant and not modify it 712 * in any way. 713 */ 714JNIEXPORT const char * JNICALL 715JVM_GetClassNameUTF(JNIEnv *env, jclass cb); 716 717/* 718 * Returns the constant pool types in the buffer provided by "types." 719 */ 720JNIEXPORT void JNICALL 721JVM_GetClassCPTypes(JNIEnv *env, jclass cb, unsigned char *types); 722 723/* 724 * Returns the number of Constant Pool entries. 725 */ 726JNIEXPORT jint JNICALL 727JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cb); 728 729/* 730 * Returns the number of *declared* fields or methods. 731 */ 732JNIEXPORT jint JNICALL 733JVM_GetClassFieldsCount(JNIEnv *env, jclass cb); 734 735JNIEXPORT jint JNICALL 736JVM_GetClassMethodsCount(JNIEnv *env, jclass cb); 737 738/* 739 * Returns the CP indexes of exceptions raised by a given method. 740 * Places the result in the given buffer. 741 * 742 * The method is identified by method_index. 743 */ 744JNIEXPORT void JNICALL 745JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cb, jint method_index, 746 unsigned short *exceptions); 747/* 748 * Returns the number of exceptions raised by a given method. 749 * The method is identified by method_index. 750 */ 751JNIEXPORT jint JNICALL 752JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cb, jint method_index); 753 754/* 755 * Returns the byte code sequence of a given method. 756 * Places the result in the given buffer. 757 * 758 * The method is identified by method_index. 759 */ 760JNIEXPORT void JNICALL 761JVM_GetMethodIxByteCode(JNIEnv *env, jclass cb, jint method_index, 762 unsigned char *code); 763 764/* 765 * Returns the length of the byte code sequence of a given method. 766 * The method is identified by method_index. 767 */ 768JNIEXPORT jint JNICALL 769JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cb, jint method_index); 770 771/* 772 * A structure used to a capture exception table entry in a Java method. 773 */ 774typedef struct { 775 jint start_pc; 776 jint end_pc; 777 jint handler_pc; 778 jint catchType; 779} JVM_ExceptionTableEntryType; 780 781/* 782 * Returns the exception table entry at entry_index of a given method. 783 * Places the result in the given buffer. 784 * 785 * The method is identified by method_index. 786 */ 787JNIEXPORT void JNICALL 788JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cb, jint method_index, 789 jint entry_index, 790 JVM_ExceptionTableEntryType *entry); 791 792/* 793 * Returns the length of the exception table of a given method. 794 * The method is identified by method_index. 795 */ 796JNIEXPORT jint JNICALL 797JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cb, int index); 798 799/* 800 * Returns the modifiers of a given field. 801 * The field is identified by field_index. 802 */ 803JNIEXPORT jint JNICALL 804JVM_GetFieldIxModifiers(JNIEnv *env, jclass cb, int index); 805 806/* 807 * Returns the modifiers of a given method. 808 * The method is identified by method_index. 809 */ 810JNIEXPORT jint JNICALL 811JVM_GetMethodIxModifiers(JNIEnv *env, jclass cb, int index); 812 813/* 814 * Returns the number of local variables of a given method. 815 * The method is identified by method_index. 816 */ 817JNIEXPORT jint JNICALL 818JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cb, int index); 819 820/* 821 * Returns the number of arguments (including this pointer) of a given method. 822 * The method is identified by method_index. 823 */ 824JNIEXPORT jint JNICALL 825JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cb, int index); 826 827/* 828 * Returns the maximum amount of stack (in words) used by a given method. 829 * The method is identified by method_index. 830 */ 831JNIEXPORT jint JNICALL 832JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cb, int index); 833 834/* 835 * Is a given method a constructor. 836 * The method is identified by method_index. 837 */ 838JNIEXPORT jboolean JNICALL 839JVM_IsConstructorIx(JNIEnv *env, jclass cb, int index); 840 841/* 842 * Is the given method generated by the VM. 843 * The method is identified by method_index. 844 */ 845JNIEXPORT jboolean JNICALL 846JVM_IsVMGeneratedMethodIx(JNIEnv *env, jclass cb, int index); 847 848/* 849 * Returns the name of a given method in UTF format. 850 * The result remains valid until JVM_ReleaseUTF is called. 851 * 852 * The caller must treat the string as a constant and not modify it 853 * in any way. 854 */ 855JNIEXPORT const char * JNICALL 856JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cb, jint index); 857 858/* 859 * Returns the signature of a given method in UTF format. 860 * The result remains valid until JVM_ReleaseUTF is called. 861 * 862 * The caller must treat the string as a constant and not modify it 863 * in any way. 864 */ 865JNIEXPORT const char * JNICALL 866JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cb, jint index); 867 868/* 869 * Returns the name of the field referred to at a given constant pool 870 * index. 871 * 872 * The result is in UTF format and remains valid until JVM_ReleaseUTF 873 * is called. 874 * 875 * The caller must treat the string as a constant and not modify it 876 * in any way. 877 */ 878JNIEXPORT const char * JNICALL 879JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cb, jint index); 880 881/* 882 * Returns the name of the method referred to at a given constant pool 883 * index. 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 */ 891JNIEXPORT const char * JNICALL 892JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cb, jint index); 893 894/* 895 * Returns the signature of the method referred to at a given constant pool 896 * index. 897 * 898 * The result is in UTF format and remains valid until JVM_ReleaseUTF 899 * is called. 900 * 901 * The caller must treat the string as a constant and not modify it 902 * in any way. 903 */ 904JNIEXPORT const char * JNICALL 905JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cb, jint index); 906 907/* 908 * Returns the signature of the field referred to at a given constant pool 909 * index. 910 * 911 * The result is in UTF format and remains valid until JVM_ReleaseUTF 912 * is called. 913 * 914 * The caller must treat the string as a constant and not modify it 915 * in any way. 916 */ 917JNIEXPORT const char * JNICALL 918JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cb, jint index); 919 920/* 921 * Returns the class name referred to at a given constant pool index. 922 * 923 * The result is in UTF format and remains valid until JVM_ReleaseUTF 924 * is called. 925 * 926 * The caller must treat the string as a constant and not modify it 927 * in any way. 928 */ 929JNIEXPORT const char * JNICALL 930JVM_GetCPClassNameUTF(JNIEnv *env, jclass cb, jint index); 931 932/* 933 * Returns the class name referred to at a given constant pool index. 934 * 935 * The constant pool entry must refer to a CONSTANT_Fieldref. 936 * 937 * The result is in UTF format and remains valid until JVM_ReleaseUTF 938 * is called. 939 * 940 * The caller must treat the string as a constant and not modify it 941 * in any way. 942 */ 943JNIEXPORT const char * JNICALL 944JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cb, jint index); 945 946/* 947 * Returns the class name referred to at a given constant pool index. 948 * 949 * The constant pool entry must refer to CONSTANT_Methodref or 950 * CONSTANT_InterfaceMethodref. 951 * 952 * The result is in UTF format and remains valid until JVM_ReleaseUTF 953 * is called. 954 * 955 * The caller must treat the string as a constant and not modify it 956 * in any way. 957 */ 958JNIEXPORT const char * JNICALL 959JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cb, jint index); 960 961/* 962 * Returns the modifiers of a field in calledClass. The field is 963 * referred to in class cb at constant pool entry index. 964 * 965 * The caller must treat the string as a constant and not modify it 966 * in any way. 967 * 968 * Returns -1 if the field does not exist in calledClass. 969 */ 970JNIEXPORT jint JNICALL 971JVM_GetCPFieldModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass); 972 973/* 974 * Returns the modifiers of a method in calledClass. The method is 975 * referred to in class cb at constant pool entry index. 976 * 977 * Returns -1 if the method does not exist in calledClass. 978 */ 979JNIEXPORT jint JNICALL 980JVM_GetCPMethodModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass); 981 982/* 983 * Releases the UTF string obtained from the VM. 984 */ 985JNIEXPORT void JNICALL 986JVM_ReleaseUTF(const char *utf); 987 988/* 989 * Compare if two classes are in the same package. 990 */ 991JNIEXPORT jboolean JNICALL 992JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2); 993 994/* Get classfile constants */ 995#include "classfile_constants.h" 996 997/* 998 * A function defined by the byte-code verifier and called by the VM. 999 * This is not a function implemented in the VM. 1000 * 1001 * Returns JNI_FALSE if verification fails. A detailed error message 1002 * will be places in msg_buf, whose length is specified by buf_len. 1003 */ 1004typedef jboolean (*verifier_fn_t)(JNIEnv *env, 1005 jclass cb, 1006 char * msg_buf, 1007 jint buf_len); 1008 1009 1010/* 1011 * Support for a VM-independent class format checker. 1012 */ 1013typedef struct { 1014 unsigned long code; /* byte code */ 1015 unsigned long excs; /* exceptions */ 1016 unsigned long etab; /* catch table */ 1017 unsigned long lnum; /* line number */ 1018 unsigned long lvar; /* local vars */ 1019} method_size_info; 1020 1021typedef struct { 1022 unsigned int constants; /* constant pool */ 1023 unsigned int fields; 1024 unsigned int methods; 1025 unsigned int interfaces; 1026 unsigned int fields2; /* number of static 2-word fields */ 1027 unsigned int innerclasses; /* # of records in InnerClasses attr */ 1028 1029 method_size_info clinit; /* memory used in clinit */ 1030 method_size_info main; /* used everywhere else */ 1031} class_size_info; 1032 1033/* 1034 * Functions defined in libjava.so to perform string conversions. 1035 * 1036 */ 1037 1038typedef jstring (*to_java_string_fn_t)(JNIEnv *env, char *str); 1039 1040typedef char *(*to_c_string_fn_t)(JNIEnv *env, jstring s, jboolean *b); 1041 1042/* This is the function defined in libjava.so that performs class 1043 * format checks. This functions fills in size information about 1044 * the class file and returns: 1045 * 1046 * 0: good 1047 * -1: out of memory 1048 * -2: bad format 1049 * -3: unsupported version 1050 * -4: bad class name 1051 */ 1052 1053typedef jint (*check_format_fn_t)(char *class_name, 1054 unsigned char *data, 1055 unsigned int data_size, 1056 class_size_info *class_size, 1057 char *message_buffer, 1058 jint buffer_length, 1059 jboolean measure_only, 1060 jboolean check_relaxed); 1061 1062#define JVM_RECOGNIZED_CLASS_MODIFIERS (JVM_ACC_PUBLIC | \ 1063 JVM_ACC_FINAL | \ 1064 JVM_ACC_SUPER | \ 1065 JVM_ACC_INTERFACE | \ 1066 JVM_ACC_ABSTRACT | \ 1067 JVM_ACC_ANNOTATION | \ 1068 JVM_ACC_ENUM | \ 1069 JVM_ACC_SYNTHETIC) 1070 1071#define JVM_RECOGNIZED_FIELD_MODIFIERS (JVM_ACC_PUBLIC | \ 1072 JVM_ACC_PRIVATE | \ 1073 JVM_ACC_PROTECTED | \ 1074 JVM_ACC_STATIC | \ 1075 JVM_ACC_FINAL | \ 1076 JVM_ACC_VOLATILE | \ 1077 JVM_ACC_TRANSIENT | \ 1078 JVM_ACC_ENUM | \ 1079 JVM_ACC_SYNTHETIC) 1080 1081#define JVM_RECOGNIZED_METHOD_MODIFIERS (JVM_ACC_PUBLIC | \ 1082 JVM_ACC_PRIVATE | \ 1083 JVM_ACC_PROTECTED | \ 1084 JVM_ACC_STATIC | \ 1085 JVM_ACC_FINAL | \ 1086 JVM_ACC_SYNCHRONIZED | \ 1087 JVM_ACC_BRIDGE | \ 1088 JVM_ACC_VARARGS | \ 1089 JVM_ACC_NATIVE | \ 1090 JVM_ACC_ABSTRACT | \ 1091 JVM_ACC_STRICT | \ 1092 JVM_ACC_SYNTHETIC) 1093 1094/* 1095 * This is the function defined in libjava.so to perform path 1096 * canonicalization. VM call this function before opening jar files 1097 * to load system classes. 1098 * 1099 */ 1100 1101typedef int (*canonicalize_fn_t)(JNIEnv *env, char *orig, char *out, int len); 1102 1103/************************************************************************* 1104 PART 3: I/O and Network Support 1105 ************************************************************************/ 1106 1107/* Note that the JVM IO functions are expected to return JVM_IO_ERR 1108 * when there is any kind of error. The caller can then use the 1109 * platform specific support (e.g., errno) to get the detailed 1110 * error info. The JVM_GetLastErrorString procedure may also be used 1111 * to obtain a descriptive error string. 1112 */ 1113#define JVM_IO_ERR (-1) 1114 1115/* For interruptible IO. Returning JVM_IO_INTR indicates that an IO 1116 * operation has been disrupted by Thread.interrupt. There are a 1117 * number of technical difficulties related to interruptible IO that 1118 * need to be solved. For example, most existing programs do not handle 1119 * InterruptedIOExceptions specially, they simply treat those as any 1120 * IOExceptions, which typically indicate fatal errors. 1121 * 1122 * There are also two modes of operation for interruptible IO. In the 1123 * resumption mode, an interrupted IO operation is guaranteed not to 1124 * have any side-effects, and can be restarted. In the termination mode, 1125 * an interrupted IO operation corrupts the underlying IO stream, so 1126 * that the only reasonable operation on an interrupted stream is to 1127 * close that stream. The resumption mode seems to be impossible to 1128 * implement on Win32 and Solaris. Implementing the termination mode is 1129 * easier, but it's not clear that's the right semantics. 1130 * 1131 * Interruptible IO is not supported on Win32.It can be enabled/disabled 1132 * using a compile-time flag on Solaris. Third-party JVM ports do not 1133 * need to implement interruptible IO. 1134 */ 1135#define JVM_IO_INTR (-2) 1136 1137/* Write a string into the given buffer, in the platform's local encoding, 1138 * that describes the most recent system-level error to occur in this thread. 1139 * Return the length of the string or zero if no error occurred. 1140 */ 1141JNIEXPORT jint JNICALL 1142JVM_GetLastErrorString(char *buf, int len); 1143 1144/* 1145 * Convert a pathname into native format. This function does syntactic 1146 * cleanup, such as removing redundant separator characters. It modifies 1147 * the given pathname string in place. 1148 */ 1149JNIEXPORT char * JNICALL 1150JVM_NativePath(char *); 1151 1152/* 1153 * JVM I/O error codes 1154 */ 1155#define JVM_EEXIST -100 1156 1157/* 1158 * Open a file descriptor. This function returns a negative error code 1159 * on error, and a non-negative integer that is the file descriptor on 1160 * success. 1161 */ 1162JNIEXPORT jint JNICALL 1163JVM_Open(const char *fname, jint flags, jint mode); 1164 1165/* 1166 * Close a file descriptor. This function returns -1 on error, and 0 1167 * on success. 1168 * 1169 * fd the file descriptor to close. 1170 */ 1171JNIEXPORT jint JNICALL 1172JVM_Close(jint fd); 1173 1174/* 1175 * Read data from a file decriptor into a char array. 1176 * 1177 * fd the file descriptor to read from. 1178 * buf the buffer where to put the read data. 1179 * nbytes the number of bytes to read. 1180 * 1181 * This function returns -1 on error, and 0 on success. 1182 */ 1183JNIEXPORT jint JNICALL 1184JVM_Read(jint fd, char *buf, jint nbytes); 1185 1186/* 1187 * Write data from a char array to a file decriptor. 1188 * 1189 * fd the file descriptor to read from. 1190 * buf the buffer from which to fetch the data. 1191 * nbytes the number of bytes to write. 1192 * 1193 * This function returns -1 on error, and 0 on success. 1194 */ 1195JNIEXPORT jint JNICALL 1196JVM_Write(jint fd, char *buf, jint nbytes); 1197 1198/* 1199 * Returns the number of bytes available for reading from a given file 1200 * descriptor 1201 */ 1202JNIEXPORT jint JNICALL 1203JVM_Available(jint fd, jlong *pbytes); 1204 1205/* 1206 * Move the file descriptor pointer from whence by offset. 1207 * 1208 * fd the file descriptor to move. 1209 * offset the number of bytes to move it by. 1210 * whence the start from where to move it. 1211 * 1212 * This function returns the resulting pointer location. 1213 */ 1214JNIEXPORT jlong JNICALL 1215JVM_Lseek(jint fd, jlong offset, jint whence); 1216 1217/* 1218 * Set the length of the file associated with the given descriptor to the given 1219 * length. If the new length is longer than the current length then the file 1220 * is extended; the contents of the extended portion are not defined. The 1221 * value of the file pointer is undefined after this procedure returns. 1222 */ 1223JNIEXPORT jint JNICALL 1224JVM_SetLength(jint fd, jlong length); 1225 1226/* 1227 * Synchronize the file descriptor's in memory state with that of the 1228 * physical device. Return of -1 is an error, 0 is OK. 1229 */ 1230JNIEXPORT jint JNICALL 1231JVM_Sync(jint fd); 1232 1233/* 1234 * Networking library support 1235 */ 1236 1237JNIEXPORT jint JNICALL 1238JVM_InitializeSocketLibrary(void); 1239 1240struct sockaddr; 1241 1242JNIEXPORT jint JNICALL 1243JVM_Socket(jint domain, jint type, jint protocol); 1244 1245JNIEXPORT jint JNICALL 1246JVM_SocketClose(jint fd); 1247 1248JNIEXPORT jint JNICALL 1249JVM_SocketShutdown(jint fd, jint howto); 1250 1251JNIEXPORT jint JNICALL 1252JVM_Recv(jint fd, char *buf, jint nBytes, jint flags); 1253 1254JNIEXPORT jint JNICALL 1255JVM_Send(jint fd, char *buf, jint nBytes, jint flags); 1256 1257JNIEXPORT jint JNICALL 1258JVM_Timeout(int fd, long timeout); 1259 1260JNIEXPORT jint JNICALL 1261JVM_Listen(jint fd, jint count); 1262 1263JNIEXPORT jint JNICALL 1264JVM_Connect(jint fd, struct sockaddr *him, jint len); 1265 1266JNIEXPORT jint JNICALL 1267JVM_Bind(jint fd, struct sockaddr *him, jint len); 1268 1269JNIEXPORT jint JNICALL 1270JVM_Accept(jint fd, struct sockaddr *him, jint *len); 1271 1272JNIEXPORT jint JNICALL 1273JVM_RecvFrom(jint fd, char *buf, int nBytes, 1274 int flags, struct sockaddr *from, int *fromlen); 1275 1276JNIEXPORT jint JNICALL 1277JVM_SendTo(jint fd, char *buf, int len, 1278 int flags, struct sockaddr *to, int tolen); 1279 1280JNIEXPORT jint JNICALL 1281JVM_SocketAvailable(jint fd, jint *result); 1282 1283 1284JNIEXPORT jint JNICALL 1285JVM_GetSockName(jint fd, struct sockaddr *him, int *len); 1286 1287JNIEXPORT jint JNICALL 1288JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen); 1289 1290JNIEXPORT jint JNICALL 1291JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen); 1292 1293JNIEXPORT int JNICALL 1294JVM_GetHostName(char* name, int namelen); 1295 1296/* 1297 * The standard printing functions supported by the Java VM. (Should they 1298 * be renamed to JVM_* in the future? 1299 */ 1300 1301/* 1302 * BE CAREFUL! The following functions do not implement the 1303 * full feature set of standard C printf formats. 1304 */ 1305int 1306jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args); 1307 1308int 1309jio_snprintf(char *str, size_t count, const char *fmt, ...); 1310 1311int 1312jio_fprintf(FILE *, const char *fmt, ...); 1313 1314int 1315jio_vfprintf(FILE *, const char *fmt, va_list args); 1316 1317 1318JNIEXPORT void * JNICALL 1319JVM_RawMonitorCreate(void); 1320 1321JNIEXPORT void JNICALL 1322JVM_RawMonitorDestroy(void *mon); 1323 1324JNIEXPORT jint JNICALL 1325JVM_RawMonitorEnter(void *mon); 1326 1327JNIEXPORT void JNICALL 1328JVM_RawMonitorExit(void *mon); 1329 1330/* 1331 * java.lang.management support 1332 */ 1333JNIEXPORT void* JNICALL 1334JVM_GetManagement(jint version); 1335 1336/* 1337 * com.sun.tools.attach.VirtualMachine support 1338 * 1339 * Initialize the agent properties with the properties maintained in the VM. 1340 */ 1341JNIEXPORT jobject JNICALL 1342JVM_InitAgentProperties(JNIEnv *env, jobject agent_props); 1343 1344JNIEXPORT jstring JNICALL 1345JVM_GetTemporaryDirectory(JNIEnv *env); 1346 1347/* Generics reflection support. 1348 * 1349 * Returns information about the given class's EnclosingMethod 1350 * attribute, if present, or null if the class had no enclosing 1351 * method. 1352 * 1353 * If non-null, the returned array contains three elements. Element 0 1354 * is the java.lang.Class of which the enclosing method is a member, 1355 * and elements 1 and 2 are the java.lang.Strings for the enclosing 1356 * method's name and descriptor, respectively. 1357 */ 1358JNIEXPORT jobjectArray JNICALL 1359JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass); 1360 1361/* 1362 * Java thread state support 1363 */ 1364enum { 1365 JAVA_THREAD_STATE_NEW = 0, 1366 JAVA_THREAD_STATE_RUNNABLE = 1, 1367 JAVA_THREAD_STATE_BLOCKED = 2, 1368 JAVA_THREAD_STATE_WAITING = 3, 1369 JAVA_THREAD_STATE_TIMED_WAITING = 4, 1370 JAVA_THREAD_STATE_TERMINATED = 5, 1371 JAVA_THREAD_STATE_COUNT = 6 1372}; 1373 1374/* 1375 * Returns an array of the threadStatus values representing the 1376 * given Java thread state. Returns NULL if the VM version is 1377 * incompatible with the JDK or doesn't support the given 1378 * Java thread state. 1379 */ 1380JNIEXPORT jintArray JNICALL 1381JVM_GetThreadStateValues(JNIEnv* env, jint javaThreadState); 1382 1383/* 1384 * Returns an array of the substate names representing the 1385 * given Java thread state. Returns NULL if the VM version is 1386 * incompatible with the JDK or the VM doesn't support 1387 * the given Java thread state. 1388 * values must be the jintArray returned from JVM_GetThreadStateValues 1389 * and javaThreadState. 1390 */ 1391JNIEXPORT jobjectArray JNICALL 1392JVM_GetThreadStateNames(JNIEnv* env, jint javaThreadState, jintArray values); 1393 1394/* 1395 * Returns true if the JVM's lookup cache indicates that this class is 1396 * known to NOT exist for the given loader. 1397 */ 1398JNIEXPORT jboolean JNICALL 1399JVM_KnownToNotExist(JNIEnv *env, jobject loader, const char *classname); 1400 1401/* 1402 * Returns an array of all URLs that are stored in the JVM's lookup cache 1403 * for the given loader. NULL if the lookup cache is unavailable. 1404 */ 1405JNIEXPORT jobjectArray JNICALL 1406JVM_GetResourceLookupCacheURLs(JNIEnv *env, jobject loader); 1407 1408/* 1409 * Returns an array of all URLs that *may* contain the resource_name for the 1410 * given loader. This function returns an integer array, each element 1411 * of which can be used to index into the array returned by 1412 * JVM_GetResourceLookupCacheURLs of the same loader to determine the 1413 * URLs. 1414 */ 1415JNIEXPORT jintArray JNICALL 1416JVM_GetResourceLookupCache(JNIEnv *env, jobject loader, const char *resource_name); 1417 1418 1419/* ========================================================================= 1420 * The following defines a private JVM interface that the JDK can query 1421 * for the JVM version and capabilities. sun.misc.Version defines 1422 * the methods for getting the VM version and its capabilities. 1423 * 1424 * When a new bit is added, the following should be updated to provide 1425 * access to the new capability: 1426 * HS: JVM_GetVersionInfo and Abstract_VM_Version class 1427 * SDK: Version class 1428 * 1429 * Similary, a private JDK interface JDK_GetVersionInfo0 is defined for 1430 * JVM to query for the JDK version and capabilities. 1431 * 1432 * When a new bit is added, the following should be updated to provide 1433 * access to the new capability: 1434 * HS: JDK_Version class 1435 * SDK: JDK_GetVersionInfo0 1436 * 1437 * ========================================================================== 1438 */ 1439typedef struct { 1440 /* Naming convention of RE build version string: n.n.n[_uu[c]][-<identifier>]-bxx */ 1441 unsigned int jvm_version; /* Consists of major, minor, micro (n.n.n) */ 1442 /* and build number (xx) */ 1443 unsigned int update_version : 8; /* Update release version (uu) */ 1444 unsigned int special_update_version : 8; /* Special update release version (c)*/ 1445 unsigned int reserved1 : 16; 1446 unsigned int reserved2; 1447 1448 /* The following bits represents JVM supports that JDK has dependency on. 1449 * JDK can use these bits to determine which JVM version 1450 * and support it has to maintain runtime compatibility. 1451 * 1452 * When a new bit is added in a minor or update release, make sure 1453 * the new bit is also added in the main/baseline. 1454 */ 1455 unsigned int is_attach_supported : 1; 1456 unsigned int : 31; 1457 unsigned int : 32; 1458 unsigned int : 32; 1459} jvm_version_info; 1460 1461#define JVM_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24) 1462#define JVM_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16) 1463#define JVM_VERSION_MICRO(version) ((version & 0x0000FF00) >> 8) 1464 1465/* Build number is available only for RE builds. 1466 * It will be zero for internal builds. 1467 */ 1468#define JVM_VERSION_BUILD(version) ((version & 0x000000FF)) 1469 1470JNIEXPORT void JNICALL 1471JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size); 1472 1473typedef struct { 1474 // Naming convention of RE build version string: n.n.n[_uu[c]][-<identifier>]-bxx 1475 unsigned int jdk_version; /* Consists of major, minor, micro (n.n.n) */ 1476 /* and build number (xx) */ 1477 unsigned int update_version : 8; /* Update release version (uu) */ 1478 unsigned int special_update_version : 8; /* Special update release version (c)*/ 1479 unsigned int reserved1 : 16; 1480 unsigned int reserved2; 1481 1482 /* The following bits represents new JDK supports that VM has dependency on. 1483 * VM implementation can use these bits to determine which JDK version 1484 * and support it has to maintain runtime compatibility. 1485 * 1486 * When a new bit is added in a minor or update release, make sure 1487 * the new bit is also added in the main/baseline. 1488 */ 1489 unsigned int thread_park_blocker : 1; 1490 unsigned int post_vm_init_hook_enabled : 1; 1491 unsigned int pending_list_uses_discovered_field : 1; 1492 unsigned int : 29; 1493 unsigned int : 32; 1494 unsigned int : 32; 1495} jdk_version_info; 1496 1497#define JDK_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24) 1498#define JDK_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16) 1499#define JDK_VERSION_MICRO(version) ((version & 0x0000FF00) >> 8) 1500 1501/* Build number is available only for RE build (i.e. JDK_BUILD_NUMBER is set to bNN) 1502 * It will be zero for internal builds. 1503 */ 1504#define JDK_VERSION_BUILD(version) ((version & 0x000000FF)) 1505 1506/* 1507 * This is the function JDK_GetVersionInfo0 defined in libjava.so 1508 * that is dynamically looked up by JVM. 1509 */ 1510typedef void (*jdk_version_info_fn_t)(jdk_version_info* info, size_t info_size); 1511 1512/* 1513 * This structure is used by the launcher to get the default thread 1514 * stack size from the VM using JNI_GetDefaultJavaVMInitArgs() with a 1515 * version of 1.1. As it is not supported otherwise, it has been removed 1516 * from jni.h 1517 */ 1518typedef struct JDK1_1InitArgs { 1519 jint version; 1520 1521 char **properties; 1522 jint checkSource; 1523 jint nativeStackSize; 1524 jint javaStackSize; 1525 jint minHeapSize; 1526 jint maxHeapSize; 1527 jint verifyMode; 1528 char *classpath; 1529 1530 jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args); 1531 void (JNICALL *exit)(jint code); 1532 void (JNICALL *abort)(void); 1533 1534 jint enableClassGC; 1535 jint enableVerboseGC; 1536 jint disableAsyncGC; 1537 jint verbose; 1538 jboolean debugging; 1539 jint debugPort; 1540} JDK1_1InitArgs; 1541 1542 1543#ifdef __cplusplus 1544} /* extern "C" */ 1545 1546#endif /* __cplusplus */ 1547 1548#endif /* !_JAVASOFT_JVM_H_ */ 1549