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