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
  35 extern "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 
  68 JNIEXPORT jint JNICALL
  69 JVM_GetInterfaceVersion(void);
  70 
  71 /*************************************************************************
  72  PART 1: Functions for Native Libraries
  73  ************************************************************************/
  74 /*
  75  * java.lang.Object
  76  */
  77 JNIEXPORT jint JNICALL
  78 JVM_IHashCode(JNIEnv *env, jobject obj);
  79 
  80 JNIEXPORT void JNICALL
  81 JVM_MonitorWait(JNIEnv *env, jobject obj, jlong ms);
  82 
  83 JNIEXPORT void JNICALL
  84 JVM_MonitorNotify(JNIEnv *env, jobject obj);
  85 
  86 JNIEXPORT void JNICALL
  87 JVM_MonitorNotifyAll(JNIEnv *env, jobject obj);
  88 
  89 JNIEXPORT jobject JNICALL
  90 JVM_Clone(JNIEnv *env, jobject obj);
  91 
  92 /*
  93  * java.lang.String
  94  */
  95 JNIEXPORT jstring JNICALL
  96 JVM_InternString(JNIEnv *env, jstring str);
  97 
  98 /*
  99  * java.lang.System
 100  */
 101 JNIEXPORT jlong JNICALL
 102 JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored);
 103 
 104 JNIEXPORT jlong JNICALL
 105 JVM_NanoTime(JNIEnv *env, jclass ignored);
 106 
 107 JNIEXPORT void JNICALL
 108 JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos,
 109               jobject dst, jint dst_pos, jint length);
 110 
 111 JNIEXPORT jobject JNICALL
 112 JVM_InitProperties(JNIEnv *env, jobject p);
 113 
 114 
 115 /*
 116  * java.lang.Runtime
 117  */
 118 JNIEXPORT void JNICALL
 119 JVM_Halt(jint code);
 120 
 121 JNIEXPORT void JNICALL
 122 JVM_GC(void);
 123 
 124 /* Returns the number of real-time milliseconds that have elapsed since the
 125  * least-recently-inspected heap object was last inspected by the garbage
 126  * collector.
 127  *
 128  * For simple stop-the-world collectors this value is just the time
 129  * since the most recent collection.  For generational collectors it is the
 130  * time since the oldest generation was most recently collected.  Other
 131  * collectors are free to return a pessimistic estimate of the elapsed time, or
 132  * simply the time since the last full collection was performed.
 133  *
 134  * Note that in the presence of reference objects, a given object that is no
 135  * longer strongly reachable may have to be inspected multiple times before it
 136  * can be reclaimed.
 137  */
 138 JNIEXPORT jlong JNICALL
 139 JVM_MaxObjectInspectionAge(void);
 140 
 141 JNIEXPORT jlong JNICALL
 142 JVM_TotalMemory(void);
 143 
 144 JNIEXPORT jlong JNICALL
 145 JVM_FreeMemory(void);
 146 
 147 JNIEXPORT jlong JNICALL
 148 JVM_MaxMemory(void);
 149 
 150 JNIEXPORT jint JNICALL
 151 JVM_ActiveProcessorCount(void);
 152 
 153 JNIEXPORT void * JNICALL
 154 JVM_LoadLibrary(const char *name);
 155 
 156 JNIEXPORT void JNICALL
 157 JVM_UnloadLibrary(void * handle);
 158 
 159 JNIEXPORT void * JNICALL
 160 JVM_FindLibraryEntry(void *handle, const char *name);
 161 
 162 JNIEXPORT jboolean JNICALL
 163 JVM_IsSupportedJNIVersion(jint version);
 164 
 165 /*
 166  * java.lang.Throwable
 167  */
 168 JNIEXPORT void JNICALL
 169 JVM_FillInStackTrace(JNIEnv *env, jobject throwable);
 170 
 171 JNIEXPORT jint JNICALL
 172 JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable);
 173 
 174 JNIEXPORT jobject JNICALL
 175 JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index);
 176 
 177 /*
 178  * java.lang.Thread
 179  */
 180 JNIEXPORT void JNICALL
 181 JVM_StartThread(JNIEnv *env, jobject thread);
 182 
 183 JNIEXPORT void JNICALL
 184 JVM_StopThread(JNIEnv *env, jobject thread, jobject exception);
 185 
 186 JNIEXPORT jboolean JNICALL
 187 JVM_IsThreadAlive(JNIEnv *env, jobject thread);
 188 
 189 JNIEXPORT void JNICALL
 190 JVM_SuspendThread(JNIEnv *env, jobject thread);
 191 
 192 JNIEXPORT void JNICALL
 193 JVM_ResumeThread(JNIEnv *env, jobject thread);
 194 
 195 JNIEXPORT void JNICALL
 196 JVM_SetThreadPriority(JNIEnv *env, jobject thread, jint prio);
 197 
 198 JNIEXPORT void JNICALL
 199 JVM_Yield(JNIEnv *env, jclass threadClass);
 200 
 201 JNIEXPORT void JNICALL
 202 JVM_Sleep(JNIEnv *env, jclass threadClass, jlong millis);
 203 
 204 JNIEXPORT jobject JNICALL
 205 JVM_CurrentThread(JNIEnv *env, jclass threadClass);
 206 
 207 JNIEXPORT jint JNICALL
 208 JVM_CountStackFrames(JNIEnv *env, jobject thread);
 209 
 210 JNIEXPORT void JNICALL
 211 JVM_Interrupt(JNIEnv *env, jobject thread);
 212 
 213 JNIEXPORT jboolean JNICALL
 214 JVM_IsInterrupted(JNIEnv *env, jobject thread, jboolean clearInterrupted);
 215 
 216 JNIEXPORT jboolean JNICALL
 217 JVM_HoldsLock(JNIEnv *env, jclass threadClass, jobject obj);
 218 
 219 JNIEXPORT void JNICALL
 220 JVM_DumpAllStacks(JNIEnv *env, jclass unused);
 221 
 222 JNIEXPORT jobjectArray JNICALL
 223 JVM_GetAllThreads(JNIEnv *env, jclass dummy);
 224 
 225 JNIEXPORT void JNICALL
 226 JVM_SetNativeThreadName(JNIEnv *env, jobject jthread, jstring name);
 227 
 228 /* getStackTrace() and getAllStackTraces() method */
 229 JNIEXPORT jobjectArray JNICALL
 230 JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads);
 231 
 232 /*
 233  * java.lang.SecurityManager
 234  */
 235 JNIEXPORT jclass JNICALL
 236 JVM_CurrentLoadedClass(JNIEnv *env);
 237 
 238 JNIEXPORT jobject JNICALL
 239 JVM_CurrentClassLoader(JNIEnv *env);
 240 
 241 JNIEXPORT jobjectArray JNICALL
 242 JVM_GetClassContext(JNIEnv *env);
 243 
 244 JNIEXPORT jint JNICALL
 245 JVM_ClassDepth(JNIEnv *env, jstring name);
 246 
 247 JNIEXPORT jint JNICALL
 248 JVM_ClassLoaderDepth(JNIEnv *env);
 249 
 250 /*
 251  * java.lang.Package
 252  */
 253 JNIEXPORT jstring JNICALL
 254 JVM_GetSystemPackage(JNIEnv *env, jstring name);
 255 
 256 JNIEXPORT jobjectArray JNICALL
 257 JVM_GetSystemPackages(JNIEnv *env);
 258 
 259 /*
 260  * java.io.ObjectInputStream
 261  */
 262 JNIEXPORT jobject JNICALL
 263 JVM_LatestUserDefinedLoader(JNIEnv *env);
 264 
 265 /*
 266  * java.lang.reflect.Array
 267  */
 268 JNIEXPORT jint JNICALL
 269 JVM_GetArrayLength(JNIEnv *env, jobject arr);
 270 
 271 JNIEXPORT jobject JNICALL
 272 JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index);
 273 
 274 JNIEXPORT jvalue JNICALL
 275 JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode);
 276 
 277 JNIEXPORT void JNICALL
 278 JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val);
 279 
 280 JNIEXPORT void JNICALL
 281 JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v,
 282                              unsigned char vCode);
 283 
 284 JNIEXPORT jobject JNICALL
 285 JVM_NewArray(JNIEnv *env, jclass eltClass, jint length);
 286 
 287 JNIEXPORT jobject JNICALL
 288 JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim);
 289 
 290 /*
 291  * java.lang.Class and java.lang.ClassLoader
 292  */
 293 
 294 #define JVM_CALLER_DEPTH -1
 295 
 296 /*
 297  * Returns the immediate caller class of the native method invoking
 298  * JVM_GetCallerClass.  The Method.invoke and other frames due to
 299  * reflection machinery are skipped.
 300  *
 301  * The depth parameter must be -1 (JVM_DEPTH). The caller is expected
 302  * to be marked with sun.reflect.CallerSensitive.  The JVM will throw
 303  * an error if it is not marked propertly.
 304  */
 305 JNIEXPORT jclass JNICALL
 306 JVM_GetCallerClass(JNIEnv *env, int depth);
 307 
 308 
 309 /*
 310  * Find primitive classes
 311  * utf: class name
 312  */
 313 JNIEXPORT jclass JNICALL
 314 JVM_FindPrimitiveClass(JNIEnv *env, const char *utf);
 315 
 316 
 317 /*
 318  * Find a class from a boot class loader. Returns NULL if class not found.
 319  */
 320 JNIEXPORT jclass JNICALL
 321 JVM_FindClassFromBootLoader(JNIEnv *env, const char *name);
 322 
 323 /*
 324  * Find a class from a given class loader. Throw ClassNotFoundException
 325  * or NoClassDefFoundError depending on the value of the last
 326  * argument.
 327  */
 328 JNIEXPORT jclass JNICALL
 329 JVM_FindClassFromClassLoader(JNIEnv *env, const char *name, jboolean init,
 330                              jobject loader, jboolean throwError);
 331 
 332 /*
 333  * Find a class from a given class.
 334  */
 335 JNIEXPORT jclass JNICALL
 336 JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init,
 337                              jclass from);
 338 
 339 /* Find a loaded class cached by the VM */
 340 JNIEXPORT jclass JNICALL
 341 JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name);
 342 
 343 /* Define a class */
 344 JNIEXPORT jclass JNICALL
 345 JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf,
 346                 jsize len, jobject pd);
 347 
 348 /* Define a class with a source (added in JDK1.5) */
 349 JNIEXPORT jclass JNICALL
 350 JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader,
 351                           const jbyte *buf, jsize len, jobject pd,
 352                           const char *source);
 353 
 354 /*
 355  * Reflection support functions
 356  */
 357 
 358 JNIEXPORT jstring JNICALL
 359 JVM_GetClassName(JNIEnv *env, jclass cls);
 360 
 361 JNIEXPORT jobjectArray JNICALL
 362 JVM_GetClassInterfaces(JNIEnv *env, jclass cls);
 363 
 364 JNIEXPORT jboolean JNICALL
 365 JVM_IsInterface(JNIEnv *env, jclass cls);
 366 
 367 JNIEXPORT jobjectArray JNICALL
 368 JVM_GetClassSigners(JNIEnv *env, jclass cls);
 369 
 370 JNIEXPORT void JNICALL
 371 JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers);
 372 
 373 JNIEXPORT jobject JNICALL
 374 JVM_GetProtectionDomain(JNIEnv *env, jclass cls);
 375 
 376 JNIEXPORT jboolean JNICALL
 377 JVM_IsArrayClass(JNIEnv *env, jclass cls);
 378 
 379 JNIEXPORT jboolean JNICALL
 380 JVM_IsPrimitiveClass(JNIEnv *env, jclass cls);
 381 
 382 JNIEXPORT jint JNICALL
 383 JVM_GetClassModifiers(JNIEnv *env, jclass cls);
 384 
 385 JNIEXPORT jobjectArray JNICALL
 386 JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass);
 387 
 388 JNIEXPORT jclass JNICALL
 389 JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass);
 390 
 391 /* Generics support (JDK 1.5) */
 392 JNIEXPORT jstring JNICALL
 393 JVM_GetClassSignature(JNIEnv *env, jclass cls);
 394 
 395 /* Annotations support (JDK 1.5) */
 396 JNIEXPORT jbyteArray JNICALL
 397 JVM_GetClassAnnotations(JNIEnv *env, jclass cls);
 398 
 399 /* Type use annotations support (JDK 1.8) */
 400 
 401 JNIEXPORT jbyteArray JNICALL
 402 JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls);
 403 
 404 JNIEXPORT jbyteArray JNICALL
 405 JVM_GetFieldTypeAnnotations(JNIEnv *env, jobject field);
 406 
 407 JNIEXPORT jbyteArray JNICALL
 408 JVM_GetMethodTypeAnnotations(JNIEnv *env, jobject method);
 409 
 410 /*
 411  * New (JDK 1.4) reflection implementation
 412  */
 413 
 414 JNIEXPORT jobjectArray JNICALL
 415 JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly);
 416 
 417 JNIEXPORT jobjectArray JNICALL
 418 JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly);
 419 
 420 JNIEXPORT jobjectArray JNICALL
 421 JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly);
 422 
 423 /* Differs from JVM_GetClassModifiers in treatment of inner classes.
 424    This returns the access flags for the class as specified in the
 425    class file rather than searching the InnerClasses attribute (if
 426    present) to find the source-level access flags. Only the values of
 427    the low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be
 428    valid. */
 429 JNIEXPORT jint JNICALL
 430 JVM_GetClassAccessFlags(JNIEnv *env, jclass cls);
 431 
 432 /* The following two reflection routines are still needed due to startup time issues */
 433 /*
 434  * java.lang.reflect.Method
 435  */
 436 JNIEXPORT jobject JNICALL
 437 JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0);
 438 
 439 /*
 440  * java.lang.reflect.Constructor
 441  */
 442 JNIEXPORT jobject JNICALL
 443 JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0);
 444 
 445 /*
 446  * Constant pool access; currently used to implement reflective access to annotations (JDK 1.5)
 447  */
 448 
 449 JNIEXPORT jobject JNICALL
 450 JVM_GetClassConstantPool(JNIEnv *env, jclass cls);
 451 
 452 JNIEXPORT jint JNICALL JVM_ConstantPoolGetSize
 453 (JNIEnv *env, jobject unused, jobject jcpool);
 454 
 455 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAt
 456 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 457 
 458 JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAtIfLoaded
 459 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 460 
 461 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAt
 462 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 463 
 464 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAtIfLoaded
 465 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 466 
 467 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAt
 468 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 469 
 470 JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAtIfLoaded
 471 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 472 
 473 JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetMemberRefInfoAt
 474 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 475 
 476 JNIEXPORT jint JNICALL JVM_ConstantPoolGetIntAt
 477 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 478 
 479 JNIEXPORT jlong JNICALL JVM_ConstantPoolGetLongAt
 480 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 481 
 482 JNIEXPORT jfloat JNICALL JVM_ConstantPoolGetFloatAt
 483 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 484 
 485 JNIEXPORT jdouble JNICALL JVM_ConstantPoolGetDoubleAt
 486 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 487 
 488 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetStringAt
 489 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 490 
 491 JNIEXPORT jstring JNICALL JVM_ConstantPoolGetUTF8At
 492 (JNIEnv *env, jobject unused, jobject jcpool, jint index);
 493 
 494 /*
 495  * Parameter reflection
 496  */
 497 
 498 JNIEXPORT jobjectArray JNICALL
 499 JVM_GetMethodParameters(JNIEnv *env, jobject method);
 500 
 501 /*
 502  * java.security.*
 503  */
 504 
 505 JNIEXPORT jobject JNICALL
 506 JVM_DoPrivileged(JNIEnv *env, jclass cls,
 507                  jobject action, jobject context, jboolean wrapException);
 508 
 509 JNIEXPORT jobject JNICALL
 510 JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls);
 511 
 512 JNIEXPORT jobject JNICALL
 513 JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls);
 514 
 515 /*
 516  * Signal support, used to implement the shutdown sequence.  Every VM must
 517  * support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts
 518  * (^C) and the latter for external termination (kill, system shutdown, etc.).
 519  * Other platform-dependent signal values may also be supported.
 520  */
 521 
 522 JNIEXPORT void * JNICALL
 523 JVM_RegisterSignal(jint sig, void *handler);
 524 
 525 JNIEXPORT jboolean JNICALL
 526 JVM_RaiseSignal(jint sig);
 527 
 528 JNIEXPORT jint JNICALL
 529 JVM_FindSignal(const char *name);
 530 
 531 /*
 532  * Retrieve the assertion directives for the specified class.
 533  */
 534 JNIEXPORT jboolean JNICALL
 535 JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls);
 536 
 537 /*
 538  * Retrieve the assertion directives from the VM.
 539  */
 540 JNIEXPORT jobject JNICALL
 541 JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused);
 542 
 543 /*
 544  * java.util.concurrent.atomic.AtomicLong
 545  */
 546 JNIEXPORT jboolean JNICALL
 547 JVM_SupportsCX8(void);
 548 
 549 /*
 550  * com.sun.dtrace.jsdt support
 551  */
 552 
 553 #define JVM_TRACING_DTRACE_VERSION 1
 554 
 555 /*
 556  * Structure to pass one probe description to JVM
 557  */
 558 typedef struct {
 559     jmethodID method;
 560     jstring   function;
 561     jstring   name;
 562     void*            reserved[4];     // for future use
 563 } JVM_DTraceProbe;
 564 
 565 /**
 566  * Encapsulates the stability ratings for a DTrace provider field
 567  */
 568 typedef struct {
 569     jint nameStability;
 570     jint dataStability;
 571     jint dependencyClass;
 572 } JVM_DTraceInterfaceAttributes;
 573 
 574 /*
 575  * Structure to pass one provider description to JVM
 576  */
 577 typedef struct {
 578     jstring                       name;
 579     JVM_DTraceProbe*              probes;
 580     jint                          probe_count;
 581     JVM_DTraceInterfaceAttributes providerAttributes;
 582     JVM_DTraceInterfaceAttributes moduleAttributes;
 583     JVM_DTraceInterfaceAttributes functionAttributes;
 584     JVM_DTraceInterfaceAttributes nameAttributes;
 585     JVM_DTraceInterfaceAttributes argsAttributes;
 586     void*                         reserved[4]; // for future use
 587 } JVM_DTraceProvider;
 588 
 589 /*
 590  * Get the version number the JVM was built with
 591  */
 592 JNIEXPORT jint JNICALL
 593 JVM_DTraceGetVersion(JNIEnv* env);
 594 
 595 /*
 596  * Register new probe with given signature, return global handle
 597  *
 598  * The version passed in is the version that the library code was
 599  * built with.
 600  */
 601 JNIEXPORT jlong JNICALL
 602 JVM_DTraceActivate(JNIEnv* env, jint version, jstring module_name,
 603   jint providers_count, JVM_DTraceProvider* providers);
 604 
 605 /*
 606  * Check JSDT probe
 607  */
 608 JNIEXPORT jboolean JNICALL
 609 JVM_DTraceIsProbeEnabled(JNIEnv* env, jmethodID method);
 610 
 611 /*
 612  * Destroy custom DOF
 613  */
 614 JNIEXPORT void JNICALL
 615 JVM_DTraceDispose(JNIEnv* env, jlong activation_handle);
 616 
 617 /*
 618  * Check to see if DTrace is supported by OS
 619  */
 620 JNIEXPORT jboolean JNICALL
 621 JVM_DTraceIsSupported(JNIEnv* env);
 622 
 623 /*************************************************************************
 624  PART 2: Support for the Verifier and Class File Format Checker
 625  ************************************************************************/
 626 /*
 627  * Return the class name in UTF format. The result is valid
 628  * until JVM_ReleaseUTf is called.
 629  *
 630  * The caller must treat the string as a constant and not modify it
 631  * in any way.
 632  */
 633 JNIEXPORT const char * JNICALL
 634 JVM_GetClassNameUTF(JNIEnv *env, jclass cb);
 635 
 636 /*
 637  * Returns the constant pool types in the buffer provided by "types."
 638  */
 639 JNIEXPORT void JNICALL
 640 JVM_GetClassCPTypes(JNIEnv *env, jclass cb, unsigned char *types);
 641 
 642 /*
 643  * Returns the number of Constant Pool entries.
 644  */
 645 JNIEXPORT jint JNICALL
 646 JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cb);
 647 
 648 /*
 649  * Returns the number of *declared* fields or methods.
 650  */
 651 JNIEXPORT jint JNICALL
 652 JVM_GetClassFieldsCount(JNIEnv *env, jclass cb);
 653 
 654 JNIEXPORT jint JNICALL
 655 JVM_GetClassMethodsCount(JNIEnv *env, jclass cb);
 656 
 657 /*
 658  * Returns the CP indexes of exceptions raised by a given method.
 659  * Places the result in the given buffer.
 660  *
 661  * The method is identified by method_index.
 662  */
 663 JNIEXPORT void JNICALL
 664 JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cb, jint method_index,
 665                                 unsigned short *exceptions);
 666 /*
 667  * Returns the number of exceptions raised by a given method.
 668  * The method is identified by method_index.
 669  */
 670 JNIEXPORT jint JNICALL
 671 JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cb, jint method_index);
 672 
 673 /*
 674  * Returns the byte code sequence of a given method.
 675  * Places the result in the given buffer.
 676  *
 677  * The method is identified by method_index.
 678  */
 679 JNIEXPORT void JNICALL
 680 JVM_GetMethodIxByteCode(JNIEnv *env, jclass cb, jint method_index,
 681                         unsigned char *code);
 682 
 683 /*
 684  * Returns the length of the byte code sequence of a given method.
 685  * The method is identified by method_index.
 686  */
 687 JNIEXPORT jint JNICALL
 688 JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cb, jint method_index);
 689 
 690 /*
 691  * A structure used to a capture exception table entry in a Java method.
 692  */
 693 typedef struct {
 694     jint start_pc;
 695     jint end_pc;
 696     jint handler_pc;
 697     jint catchType;
 698 } JVM_ExceptionTableEntryType;
 699 
 700 /*
 701  * Returns the exception table entry at entry_index of a given method.
 702  * Places the result in the given buffer.
 703  *
 704  * The method is identified by method_index.
 705  */
 706 JNIEXPORT void JNICALL
 707 JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cb, jint method_index,
 708                                    jint entry_index,
 709                                    JVM_ExceptionTableEntryType *entry);
 710 
 711 /*
 712  * Returns the length of the exception table of a given method.
 713  * The method is identified by method_index.
 714  */
 715 JNIEXPORT jint JNICALL
 716 JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cb, int index);
 717 
 718 /*
 719  * Returns the modifiers of a given field.
 720  * The field is identified by field_index.
 721  */
 722 JNIEXPORT jint JNICALL
 723 JVM_GetFieldIxModifiers(JNIEnv *env, jclass cb, int index);
 724 
 725 /*
 726  * Returns the modifiers of a given method.
 727  * The method is identified by method_index.
 728  */
 729 JNIEXPORT jint JNICALL
 730 JVM_GetMethodIxModifiers(JNIEnv *env, jclass cb, int index);
 731 
 732 /*
 733  * Returns the number of local variables of a given method.
 734  * The method is identified by method_index.
 735  */
 736 JNIEXPORT jint JNICALL
 737 JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cb, int index);
 738 
 739 /*
 740  * Returns the number of arguments (including this pointer) of a given method.
 741  * The method is identified by method_index.
 742  */
 743 JNIEXPORT jint JNICALL
 744 JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cb, int index);
 745 
 746 /*
 747  * Returns the maximum amount of stack (in words) used by a given method.
 748  * The method is identified by method_index.
 749  */
 750 JNIEXPORT jint JNICALL
 751 JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cb, int index);
 752 
 753 /*
 754  * Is a given method a constructor.
 755  * The method is identified by method_index.
 756  */
 757 JNIEXPORT jboolean JNICALL
 758 JVM_IsConstructorIx(JNIEnv *env, jclass cb, int index);
 759 
 760 /*
 761  * Is the given method generated by the VM.
 762  * The method is identified by method_index.
 763  */
 764 JNIEXPORT jboolean JNICALL
 765 JVM_IsVMGeneratedMethodIx(JNIEnv *env, jclass cb, int index);
 766 
 767 /*
 768  * Returns the name of a given method in UTF format.
 769  * The result remains valid until JVM_ReleaseUTF is called.
 770  *
 771  * The caller must treat the string as a constant and not modify it
 772  * in any way.
 773  */
 774 JNIEXPORT const char * JNICALL
 775 JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cb, jint index);
 776 
 777 /*
 778  * Returns the signature of a given method in UTF format.
 779  * The result remains valid until JVM_ReleaseUTF is called.
 780  *
 781  * The caller must treat the string as a constant and not modify it
 782  * in any way.
 783  */
 784 JNIEXPORT const char * JNICALL
 785 JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cb, jint index);
 786 
 787 /*
 788  * Returns the name of the field referred to at a given constant pool
 789  * index.
 790  *
 791  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 792  * is called.
 793  *
 794  * The caller must treat the string as a constant and not modify it
 795  * in any way.
 796  */
 797 JNIEXPORT const char * JNICALL
 798 JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cb, jint index);
 799 
 800 /*
 801  * Returns the name of the method referred to at a given constant pool
 802  * index.
 803  *
 804  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 805  * is called.
 806  *
 807  * The caller must treat the string as a constant and not modify it
 808  * in any way.
 809  */
 810 JNIEXPORT const char * JNICALL
 811 JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cb, jint index);
 812 
 813 /*
 814  * Returns the signature of the method referred to at a given constant pool
 815  * index.
 816  *
 817  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 818  * is called.
 819  *
 820  * The caller must treat the string as a constant and not modify it
 821  * in any way.
 822  */
 823 JNIEXPORT const char * JNICALL
 824 JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cb, jint index);
 825 
 826 /*
 827  * Returns the signature of the field referred to at a given constant pool
 828  * index.
 829  *
 830  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 831  * is called.
 832  *
 833  * The caller must treat the string as a constant and not modify it
 834  * in any way.
 835  */
 836 JNIEXPORT const char * JNICALL
 837 JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cb, jint index);
 838 
 839 /*
 840  * Returns the class name referred to at a given constant pool index.
 841  *
 842  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 843  * is called.
 844  *
 845  * The caller must treat the string as a constant and not modify it
 846  * in any way.
 847  */
 848 JNIEXPORT const char * JNICALL
 849 JVM_GetCPClassNameUTF(JNIEnv *env, jclass cb, jint index);
 850 
 851 /*
 852  * Returns the class name referred to at a given constant pool index.
 853  *
 854  * The constant pool entry must refer to a CONSTANT_Fieldref.
 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_GetCPFieldClassNameUTF(JNIEnv *env, jclass cb, jint index);
 864 
 865 /*
 866  * Returns the class name referred to at a given constant pool index.
 867  *
 868  * The constant pool entry must refer to CONSTANT_Methodref or
 869  * CONSTANT_InterfaceMethodref.
 870  *
 871  * The result is in UTF format and remains valid until JVM_ReleaseUTF
 872  * is called.
 873  *
 874  * The caller must treat the string as a constant and not modify it
 875  * in any way.
 876  */
 877 JNIEXPORT const char * JNICALL
 878 JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cb, jint index);
 879 
 880 /*
 881  * Returns the modifiers of a field in calledClass. The field is
 882  * referred to in class cb at constant pool entry index.
 883  *
 884  * The caller must treat the string as a constant and not modify it
 885  * in any way.
 886  *
 887  * Returns -1 if the field does not exist in calledClass.
 888  */
 889 JNIEXPORT jint JNICALL
 890 JVM_GetCPFieldModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
 891 
 892 /*
 893  * Returns the modifiers of a method in calledClass. The method is
 894  * referred to in class cb at constant pool entry index.
 895  *
 896  * Returns -1 if the method does not exist in calledClass.
 897  */
 898 JNIEXPORT jint JNICALL
 899 JVM_GetCPMethodModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
 900 
 901 /*
 902  * Releases the UTF string obtained from the VM.
 903  */
 904 JNIEXPORT void JNICALL
 905 JVM_ReleaseUTF(const char *utf);
 906 
 907 /*
 908  * Compare if two classes are in the same package.
 909  */
 910 JNIEXPORT jboolean JNICALL
 911 JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2);
 912 
 913 /* Get classfile constants */
 914 #include "classfile_constants.h"
 915 
 916 /*
 917  * A function defined by the byte-code verifier and called by the VM.
 918  * This is not a function implemented in the VM.
 919  *
 920  * Returns JNI_FALSE if verification fails. A detailed error message
 921  * will be places in msg_buf, whose length is specified by buf_len.
 922  */
 923 typedef jboolean (*verifier_fn_t)(JNIEnv *env,
 924                                   jclass cb,
 925                                   char * msg_buf,
 926                                   jint buf_len);
 927 
 928 
 929 /*
 930  * Support for a VM-independent class format checker.
 931  */
 932 typedef struct {
 933     unsigned long code;    /* byte code */
 934     unsigned long excs;    /* exceptions */
 935     unsigned long etab;    /* catch table */
 936     unsigned long lnum;    /* line number */
 937     unsigned long lvar;    /* local vars */
 938 } method_size_info;
 939 
 940 typedef struct {
 941     unsigned int constants;    /* constant pool */
 942     unsigned int fields;
 943     unsigned int methods;
 944     unsigned int interfaces;
 945     unsigned int fields2;      /* number of static 2-word fields */
 946     unsigned int innerclasses; /* # of records in InnerClasses attr */
 947 
 948     method_size_info clinit;   /* memory used in clinit */
 949     method_size_info main;     /* used everywhere else */
 950 } class_size_info;
 951 
 952 /*
 953  * Functions defined in libjava.so to perform string conversions.
 954  *
 955  */
 956 
 957 typedef jstring (*to_java_string_fn_t)(JNIEnv *env, char *str);
 958 
 959 typedef char *(*to_c_string_fn_t)(JNIEnv *env, jstring s, jboolean *b);
 960 
 961 /* This is the function defined in libjava.so that performs class
 962  * format checks. This functions fills in size information about
 963  * the class file and returns:
 964  *
 965  *   0: good
 966  *  -1: out of memory
 967  *  -2: bad format
 968  *  -3: unsupported version
 969  *  -4: bad class name
 970  */
 971 
 972 typedef jint (*check_format_fn_t)(char *class_name,
 973                                   unsigned char *data,
 974                                   unsigned int data_size,
 975                                   class_size_info *class_size,
 976                                   char *message_buffer,
 977                                   jint buffer_length,
 978                                   jboolean measure_only,
 979                                   jboolean check_relaxed);
 980 
 981 #define JVM_RECOGNIZED_CLASS_MODIFIERS (JVM_ACC_PUBLIC | \
 982                                         JVM_ACC_FINAL | \
 983                                         JVM_ACC_SUPER | \
 984                                         JVM_ACC_INTERFACE | \
 985                                         JVM_ACC_ABSTRACT | \
 986                                         JVM_ACC_ANNOTATION | \
 987                                         JVM_ACC_ENUM | \
 988                                         JVM_ACC_SYNTHETIC)
 989 
 990 #define JVM_RECOGNIZED_FIELD_MODIFIERS (JVM_ACC_PUBLIC | \
 991                                         JVM_ACC_PRIVATE | \
 992                                         JVM_ACC_PROTECTED | \
 993                                         JVM_ACC_STATIC | \
 994                                         JVM_ACC_FINAL | \
 995                                         JVM_ACC_VOLATILE | \
 996                                         JVM_ACC_TRANSIENT | \
 997                                         JVM_ACC_ENUM | \
 998                                         JVM_ACC_SYNTHETIC)
 999 
1000 #define JVM_RECOGNIZED_METHOD_MODIFIERS (JVM_ACC_PUBLIC | \
1001                                          JVM_ACC_PRIVATE | \
1002                                          JVM_ACC_PROTECTED | \
1003                                          JVM_ACC_STATIC | \
1004                                          JVM_ACC_FINAL | \
1005                                          JVM_ACC_SYNCHRONIZED | \
1006                                          JVM_ACC_BRIDGE | \
1007                                          JVM_ACC_VARARGS | \
1008                                          JVM_ACC_NATIVE | \
1009                                          JVM_ACC_ABSTRACT | \
1010                                          JVM_ACC_STRICT | \
1011                                          JVM_ACC_SYNTHETIC)
1012 
1013 /*
1014  * This is the function defined in libjava.so to perform path
1015  * canonicalization. VM call this function before opening jar files
1016  * to load system classes.
1017  *
1018  */
1019 
1020 typedef int (*canonicalize_fn_t)(JNIEnv *env, char *orig, char *out, int len);
1021 
1022 /*************************************************************************
1023  PART 3: I/O and Network Support
1024  ************************************************************************/
1025 
1026 /*
1027  * Convert a pathname into native format.  This function does syntactic
1028  * cleanup, such as removing redundant separator characters.  It modifies
1029  * the given pathname string in place.
1030  */
1031 JNIEXPORT char * JNICALL
1032 JVM_NativePath(char *);
1033 
1034 /*
1035  * The standard printing functions supported by the Java VM. (Should they
1036  * be renamed to JVM_* in the future?
1037  */
1038 
1039 /*
1040  * BE CAREFUL! The following functions do not implement the
1041  * full feature set of standard C printf formats.
1042  */
1043 int
1044 jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
1045 
1046 int
1047 jio_snprintf(char *str, size_t count, const char *fmt, ...);
1048 
1049 int
1050 jio_fprintf(FILE *, const char *fmt, ...);
1051 
1052 int
1053 jio_vfprintf(FILE *, const char *fmt, va_list args);
1054 
1055 
1056 JNIEXPORT void * JNICALL
1057 JVM_RawMonitorCreate(void);
1058 
1059 JNIEXPORT void JNICALL
1060 JVM_RawMonitorDestroy(void *mon);
1061 
1062 JNIEXPORT jint JNICALL
1063 JVM_RawMonitorEnter(void *mon);
1064 
1065 JNIEXPORT void JNICALL
1066 JVM_RawMonitorExit(void *mon);
1067 
1068 /*
1069  * java.lang.management support
1070  */
1071 JNIEXPORT void* JNICALL
1072 JVM_GetManagement(jint version);
1073 
1074 /*
1075  * com.sun.tools.attach.VirtualMachine support
1076  *
1077  * Initialize the agent properties with the properties maintained in the VM.
1078  */
1079 JNIEXPORT jobject JNICALL
1080 JVM_InitAgentProperties(JNIEnv *env, jobject agent_props);
1081 
1082 JNIEXPORT jstring JNICALL
1083 JVM_GetTemporaryDirectory(JNIEnv *env);
1084 
1085 /* Generics reflection support.
1086  *
1087  * Returns information about the given class's EnclosingMethod
1088  * attribute, if present, or null if the class had no enclosing
1089  * method.
1090  *
1091  * If non-null, the returned array contains three elements. Element 0
1092  * is the java.lang.Class of which the enclosing method is a member,
1093  * and elements 1 and 2 are the java.lang.Strings for the enclosing
1094  * method's name and descriptor, respectively.
1095  */
1096 JNIEXPORT jobjectArray JNICALL
1097 JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass);
1098 
1099 /* =========================================================================
1100  * The following defines a private JVM interface that the JDK can query
1101  * for the JVM version and capabilities.  sun.misc.Version defines
1102  * the methods for getting the VM version and its capabilities.
1103  *
1104  * When a new bit is added, the following should be updated to provide
1105  * access to the new capability:
1106  *    HS:   JVM_GetVersionInfo and Abstract_VM_Version class
1107  *    SDK:  Version class
1108  *
1109  * Similary, a private JDK interface JDK_GetVersionInfo0 is defined for
1110  * JVM to query for the JDK version and capabilities.
1111  *
1112  * When a new bit is added, the following should be updated to provide
1113  * access to the new capability:
1114  *    HS:   JDK_Version class
1115  *    SDK:  JDK_GetVersionInfo0
1116  *
1117  * ==========================================================================
1118  */
1119 typedef struct {
1120     /* Naming convention of RE build version string: n.n.n[_uu[c]][-<identifier>]-bxx */
1121     unsigned int jvm_version;   /* Consists of major, minor, micro (n.n.n) */
1122                                 /* and build number (xx) */
1123     unsigned int update_version : 8;         /* Update release version (uu) */
1124     unsigned int special_update_version : 8; /* Special update release version (c)*/
1125     unsigned int reserved1 : 16;
1126     unsigned int reserved2;
1127 
1128     /* The following bits represents JVM supports that JDK has dependency on.
1129      * JDK can use these bits to determine which JVM version
1130      * and support it has to maintain runtime compatibility.
1131      *
1132      * When a new bit is added in a minor or update release, make sure
1133      * the new bit is also added in the main/baseline.
1134      */
1135     unsigned int is_attach_supported : 1;
1136     unsigned int : 31;
1137     unsigned int : 32;
1138     unsigned int : 32;
1139 } jvm_version_info;
1140 
1141 #define JVM_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24)
1142 #define JVM_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16)
1143 #define JVM_VERSION_MICRO(version) ((version & 0x0000FF00) >> 8)
1144 
1145 /* Build number is available only for RE builds.
1146  * It will be zero for internal builds.
1147  */
1148 #define JVM_VERSION_BUILD(version) ((version & 0x000000FF))
1149 
1150 JNIEXPORT void JNICALL
1151 JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size);
1152 
1153 typedef struct {
1154     // Naming convention of RE build version string: n.n.n[_uu[c]][-<identifier>]-bxx
1155     unsigned int jdk_version;   /* Consists of major, minor, micro (n.n.n) */
1156                                 /* and build number (xx) */
1157     unsigned int update_version : 8;         /* Update release version (uu) */
1158     unsigned int special_update_version : 8; /* Special update release version (c)*/
1159     unsigned int reserved1 : 16;
1160     unsigned int reserved2;
1161 
1162     /* The following bits represents new JDK supports that VM has dependency on.
1163      * VM implementation can use these bits to determine which JDK version
1164      * and support it has to maintain runtime compatibility.
1165      *
1166      * When a new bit is added in a minor or update release, make sure
1167      * the new bit is also added in the main/baseline.
1168      */
1169     unsigned int thread_park_blocker : 1;
1170     unsigned int post_vm_init_hook_enabled : 1;
1171     unsigned int pending_list_uses_discovered_field : 1;
1172     unsigned int : 29;
1173     unsigned int : 32;
1174     unsigned int : 32;
1175 } jdk_version_info;
1176 
1177 #define JDK_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24)
1178 #define JDK_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16)
1179 #define JDK_VERSION_MICRO(version) ((version & 0x0000FF00) >> 8)
1180 
1181 /* Build number is available only for RE build (i.e. JDK_BUILD_NUMBER is set to bNN)
1182  * It will be zero for internal builds.
1183  */
1184 #define JDK_VERSION_BUILD(version) ((version & 0x000000FF))
1185 
1186 /*
1187  * This is the function JDK_GetVersionInfo0 defined in libjava.so
1188  * that is dynamically looked up by JVM.
1189  */
1190 typedef void (*jdk_version_info_fn_t)(jdk_version_info* info, size_t info_size);
1191 
1192 /*
1193  * This structure is used by the launcher to get the default thread
1194  * stack size from the VM using JNI_GetDefaultJavaVMInitArgs() with a
1195  * version of 1.1.  As it is not supported otherwise, it has been removed
1196  * from jni.h
1197  */
1198 typedef struct JDK1_1InitArgs {
1199     jint version;
1200 
1201     char **properties;
1202     jint checkSource;
1203     jint nativeStackSize;
1204     jint javaStackSize;
1205     jint minHeapSize;
1206     jint maxHeapSize;
1207     jint verifyMode;
1208     char *classpath;
1209 
1210     jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args);
1211     void (JNICALL *exit)(jint code);
1212     void (JNICALL *abort)(void);
1213 
1214     jint enableClassGC;
1215     jint enableVerboseGC;
1216     jint disableAsyncGC;
1217     jint verbose;
1218     jboolean debugging;
1219     jint debugPort;
1220 } JDK1_1InitArgs;
1221 
1222 
1223 #ifdef __cplusplus
1224 } /* extern "C" */
1225 
1226 #endif /* __cplusplus */
1227 
1228 #endif /* !_JAVASOFT_JVM_H_ */