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