home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / j2sdk / files / linux / j2sdklin.bin / jdk1.3.1 / include-old / jvm.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-05-06  |  32.0 KB  |  1,190 lines

  1. /*
  2.  * @(#)jvm.h    1.81 00/08/30
  3.  *
  4.  * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
  5.  * Copyright 2000 Sun Microsystems, Inc. Tous droits rΘservΘs.
  6.  *
  7.  * This software is the proprietary information of Sun Microsystems, Inc.  
  8.  * Use is subject to license terms.
  9.  * 
  10.  */
  11.  
  12. #ifndef _JAVASOFT_JVM_H_
  13. #define _JAVASOFT_JVM_H_
  14.  
  15. #include <sys/stat.h>
  16.  
  17. #include "jni.h"
  18. #include "jvm_md.h"
  19.  
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23.  
  24. /* 
  25.  * This file contains additional functions exported from the VM.
  26.  * These functions are complementary to the standard JNI support.
  27.  * There are three parts to this file:
  28.  * 
  29.  * First, this file contains the VM-related functions needed by native
  30.  * libraries in the standard Java API. For example, the java.lang.Object
  31.  * class needs VM-level functions that wait for and notify monitors.
  32.  * 
  33.  * Second, this file contains the functions and constant definitions
  34.  * needed by the byte code verifier and class file format checker.
  35.  * These functions allow the verifier and format checker to be written
  36.  * in a VM-independent way.
  37.  * 
  38.  * Third, this file contains various I/O and nerwork operations needed
  39.  * by the standard Java I/O and network APIs.
  40.  */
  41.  
  42. /*
  43.  * Bump the version number when either of the following happens:
  44.  *
  45.  * 1. There is a change in JVM_* functions.
  46.  *
  47.  * 2. There is a change in the contract between VM and Java classes.
  48.  *    For example, if the VM relies on a new private field in Thread
  49.  *    class.
  50.  */
  51.  
  52. #define JVM_INTERFACE_VERSION 4
  53.  
  54. JNIEXPORT jint JNICALL
  55. JVM_GetInterfaceVersion(void);
  56.  
  57. /*************************************************************************
  58.  PART 1: Functions for Native Libraries
  59.  ************************************************************************/
  60. /*
  61.  * java.lang.Object
  62.  */
  63. JNIEXPORT jint JNICALL
  64. JVM_IHashCode(JNIEnv *env, jobject obj);
  65.  
  66. JNIEXPORT void JNICALL
  67. JVM_MonitorWait(JNIEnv *env, jobject obj, jlong ms);
  68.  
  69. JNIEXPORT void JNICALL
  70. JVM_MonitorNotify(JNIEnv *env, jobject obj);
  71.  
  72. JNIEXPORT void JNICALL
  73. JVM_MonitorNotifyAll(JNIEnv *env, jobject obj);
  74.  
  75. JNIEXPORT jobject JNICALL
  76. JVM_Clone(JNIEnv *env, jobject obj);
  77.  
  78. /*
  79.  * java.lang.String
  80.  */
  81. JNIEXPORT jstring JNICALL
  82. JVM_InternString(JNIEnv *env, jstring str);
  83.  
  84. /*
  85.  * java.lang.System
  86.  */
  87. JNIEXPORT jlong JNICALL
  88. JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored);
  89.  
  90. JNIEXPORT void JNICALL
  91. JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos, 
  92.           jobject dst, jint dst_pos, jint length);
  93.  
  94. JNIEXPORT jobject JNICALL
  95. JVM_InitProperties(JNIEnv *env, jobject p);
  96.  
  97. /*
  98.  * java.io.File
  99.  */
  100. JNIEXPORT void JNICALL
  101. JVM_OnExit(void (*func)(void));
  102.  
  103. /*
  104.  * java.lang.Runtime
  105.  */
  106. JNIEXPORT void JNICALL
  107. JVM_Exit(jint code);
  108.  
  109. JNIEXPORT void JNICALL
  110. JVM_Halt(jint code);
  111.  
  112. JNIEXPORT void JNICALL
  113. JVM_GC(void);
  114.  
  115. /* Returns the number of real-time milliseconds that have elapsed since the
  116.  * least-recently-inspected heap object was last inspected by the garbage
  117.  * collector.
  118.  *
  119.  * For simple stop-the-world collectors this value is just the time
  120.  * since the most recent collection.  For generational collectors it is the
  121.  * time since the oldest generation was most recently collected.  Other
  122.  * collectors are free to return a pessimistic estimate of the elapsed time, or
  123.  * simply the time since the last full collection was performed.
  124.  *
  125.  * Note that in the presence of reference objects, a given object that is no
  126.  * longer strongly reachable may have to be inspected multiple times before it
  127.  * can be reclaimed.
  128.  */
  129. JNIEXPORT jlong JNICALL
  130. JVM_MaxObjectInspectionAge(void);
  131.  
  132. JNIEXPORT void JNICALL
  133. JVM_TraceInstructions(jboolean on);
  134.  
  135. JNIEXPORT void JNICALL
  136. JVM_TraceMethodCalls(jboolean on);
  137.  
  138. JNIEXPORT jlong JNICALL
  139. JVM_TotalMemory(void);
  140.  
  141. JNIEXPORT jlong JNICALL
  142. JVM_FreeMemory(void);
  143.  
  144. JNIEXPORT jobject JNICALL
  145. JVM_ExecInternal(JNIEnv *env, jobjectArray cmdarray0, jobjectArray envp0);
  146.  
  147. JNIEXPORT void * JNICALL 
  148. JVM_LoadLibrary(const char *name);
  149.  
  150. JNIEXPORT void JNICALL 
  151. JVM_UnloadLibrary(void * handle);
  152.  
  153. JNIEXPORT void * JNICALL 
  154. JVM_FindLibraryEntry(void *handle, const char *name);
  155.  
  156. JNIEXPORT jboolean JNICALL
  157. JVM_IsSupportedJNIVersion(jint version);
  158.  
  159. /*
  160.  * java.lang.Float and java.lang.Double
  161.  */
  162. JNIEXPORT jboolean JNICALL
  163. JVM_IsNaN(jdouble d);
  164.  
  165. /*
  166.  * java.lang.Throwable
  167.  */
  168. JNIEXPORT void JNICALL
  169. JVM_FillInStackTrace(JNIEnv *env, jobject throwable);
  170.  
  171. JNIEXPORT void JNICALL
  172. JVM_PrintStackTrace(JNIEnv *env, jobject throwable, jobject printable);
  173.  
  174. /*
  175.  * java.lang.Compiler
  176.  */
  177. JNIEXPORT void JNICALL
  178. JVM_InitializeCompiler (JNIEnv *env, jclass compCls);
  179.  
  180. JNIEXPORT jboolean JNICALL
  181. JVM_IsSilentCompiler(JNIEnv *env, jclass compCls);
  182.  
  183. JNIEXPORT jboolean JNICALL
  184. JVM_CompileClass(JNIEnv *env, jclass compCls, jclass cls);
  185.  
  186. JNIEXPORT jboolean JNICALL
  187. JVM_CompileClasses(JNIEnv *env, jclass cls, jstring jname);
  188.  
  189. JNIEXPORT jobject JNICALL
  190. JVM_CompilerCommand(JNIEnv *env, jclass compCls, jobject arg);
  191.  
  192. JNIEXPORT void JNICALL
  193. JVM_EnableCompiler(JNIEnv *env, jclass compCls);
  194.  
  195. JNIEXPORT void JNICALL
  196. JVM_DisableCompiler(JNIEnv *env, jclass compCls);
  197.  
  198. /*
  199.  * java.lang.Thread
  200.  */
  201. JNIEXPORT void JNICALL
  202. JVM_StartThread(JNIEnv *env, jobject thread);
  203.  
  204. JNIEXPORT void JNICALL
  205. JVM_StopThread(JNIEnv *env, jobject thread, jobject exception);
  206.  
  207. JNIEXPORT jboolean JNICALL
  208. JVM_IsThreadAlive(JNIEnv *env, jobject thread);
  209.  
  210. JNIEXPORT void JNICALL
  211. JVM_SuspendThread(JNIEnv *env, jobject thread);
  212.  
  213. #ifdef __solaris__
  214. #define JVM_AvailableThreadStack sysThreadAvailableStackWithSlack
  215. #else
  216.     JNIEXPORT jlong JNICALL
  217.     JVM_AvailableThreadStack(void);
  218. #endif
  219.  
  220. JNIEXPORT void JNICALL
  221. JVM_ResumeThread(JNIEnv *env, jobject thread);
  222.  
  223. JNIEXPORT void JNICALL
  224. JVM_SetThreadPriority(JNIEnv *env, jobject thread, jint prio);
  225.  
  226. JNIEXPORT void JNICALL
  227. JVM_Yield(JNIEnv *env, jclass threadClass);
  228.  
  229. JNIEXPORT void JNICALL
  230. JVM_Sleep(JNIEnv *env, jclass threadClass, jlong millis);
  231.  
  232. JNIEXPORT jobject JNICALL
  233. JVM_CurrentThread(JNIEnv *env, jclass threadClass);
  234.  
  235. JNIEXPORT jint JNICALL
  236. JVM_CountStackFrames(JNIEnv *env, jobject thread);
  237.  
  238. JNIEXPORT void JNICALL
  239. JVM_Interrupt(JNIEnv *env, jobject thread);
  240.  
  241. JNIEXPORT jboolean JNICALL
  242. JVM_IsInterrupted(JNIEnv *env, jobject thread, jboolean clearInterrupted);
  243.  
  244. /*
  245.  * java.lang.SecurityManager
  246.  */
  247. JNIEXPORT jclass JNICALL
  248. JVM_CurrentLoadedClass(JNIEnv *env);
  249.  
  250. JNIEXPORT jobject JNICALL
  251. JVM_CurrentClassLoader(JNIEnv *env);
  252.  
  253. JNIEXPORT jobjectArray JNICALL
  254. JVM_GetClassContext(JNIEnv *env);
  255.  
  256. JNIEXPORT jint JNICALL
  257. JVM_ClassDepth(JNIEnv *env, jstring name);
  258.  
  259. JNIEXPORT jint JNICALL
  260. JVM_ClassLoaderDepth(JNIEnv *env);
  261.  
  262. /*
  263.  * java.lang.Package
  264.  */
  265. JNIEXPORT jstring JNICALL
  266. JVM_GetSystemPackage(JNIEnv *env, jstring name);
  267.  
  268. JNIEXPORT jobjectArray JNICALL
  269. JVM_GetSystemPackages(JNIEnv *env);
  270.  
  271. /*
  272.  * java.io.ObjectInputStream
  273.  */
  274. JNIEXPORT jobject JNICALL
  275. JVM_AllocateNewObject(JNIEnv *env, jobject obj, jclass currClass,
  276.                       jclass initClass);
  277.  
  278. JNIEXPORT jobject JNICALL
  279. JVM_AllocateNewArray(JNIEnv *env, jobject obj, jclass currClass,
  280.                      jint length);
  281.  
  282. JNIEXPORT jobject JNICALL
  283. JVM_LatestUserDefinedLoader(JNIEnv *env);
  284.  
  285. /*
  286.  * This function has been deprecated and should not be considered
  287.  * part of the specified JVM interface.
  288.  */
  289. JNIEXPORT jclass JNICALL
  290. JVM_LoadClass0(JNIEnv *env, jobject obj, jclass currClass,
  291.                jstring currClassName);
  292.  
  293. /*
  294.  * java.lang.reflect.Array
  295.  */
  296. JNIEXPORT jint JNICALL
  297. JVM_GetArrayLength(JNIEnv *env, jobject arr);
  298.  
  299. JNIEXPORT jobject JNICALL
  300. JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index);
  301.  
  302. JNIEXPORT jvalue JNICALL
  303. JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode);
  304.  
  305. JNIEXPORT void JNICALL
  306. JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val);
  307.  
  308. JNIEXPORT void JNICALL
  309. JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v,
  310.                  unsigned char vCode);
  311.  
  312. JNIEXPORT jobject JNICALL
  313. JVM_NewArray(JNIEnv *env, jclass eltClass, jint length);
  314.  
  315. JNIEXPORT jobject JNICALL
  316. JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim);
  317.  
  318. /*
  319.  * java.lang.reflect.Field
  320.  */
  321. JNIEXPORT jobject JNICALL
  322. JVM_GetField(JNIEnv *env, jobject field, jobject obj);
  323.  
  324. JNIEXPORT jvalue JNICALL
  325. JVM_GetPrimitiveField(JNIEnv *env, jobject field, jobject obj,
  326.                       unsigned char wCode);
  327.  
  328. JNIEXPORT void JNICALL
  329. JVM_SetField(JNIEnv *env, jobject field, jobject obj, jobject val);
  330.  
  331. JNIEXPORT void JNICALL
  332. JVM_SetPrimitiveField(JNIEnv *env, jobject field, jobject obj, jvalue v,
  333.                       unsigned char vCode);
  334.  
  335.  
  336. /*
  337.  * java.lang.reflect.Method
  338.  */
  339. JNIEXPORT jobject JNICALL
  340. JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0);
  341.  
  342. /*
  343.  * java.lang.reflect.Constructor
  344.  */
  345. JNIEXPORT jobject JNICALL
  346. JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0);
  347.  
  348. /*
  349.  * java.lang.Class and java.lang.ClassLoader
  350.  */
  351. /*
  352.  * Returns the class in which the code invoking the native method
  353.  * belongs.
  354.  *
  355.  * Note that in JDK 1.1, native methods did not create a frame.
  356.  * In 1.2, they do. Therefore native methods like Class.forName
  357.  * can no longer look at the current frame for the caller class.
  358.  */
  359. JNIEXPORT jclass JNICALL
  360. JVM_GetCallerClass(JNIEnv *env, int n);
  361.  
  362. /*
  363.  * Find primitive classes
  364.  * utf: class name
  365.  */
  366. JNIEXPORT jclass JNICALL
  367. JVM_FindPrimitiveClass(JNIEnv *env, const char *utf);
  368.  
  369. /*
  370.  * Link the class
  371.  */
  372. JNIEXPORT void JNICALL
  373. JVM_ResolveClass(JNIEnv *env, jclass cls);
  374.  
  375. /*
  376.  * Find a class from a given class loader. Throw ClassNotFoundException
  377.  * or NoClassDefFoundError depending on the value of the last
  378.  * argument.
  379.  */
  380. JNIEXPORT jclass JNICALL
  381. JVM_FindClassFromClassLoader(JNIEnv *env, const char *name, jboolean init,
  382.                  jobject loader, jboolean throwError);
  383.     
  384. /*
  385.  * Find a class from a given class.
  386.  */
  387. JNIEXPORT jclass JNICALL
  388. JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init,
  389.                  jclass from);
  390.  
  391. /* Find a loaded class cached by the VM */
  392. JNIEXPORT jclass JNICALL
  393. JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name);
  394.  
  395. /* Define a class */
  396. JNIEXPORT jclass JNICALL
  397. JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf,
  398.        jsize len, jobject pd);
  399.  
  400.  
  401. /*
  402.  * Reflection support functions
  403.  */
  404.  
  405. JNIEXPORT jstring JNICALL
  406. JVM_GetClassName(JNIEnv *env, jclass cls);
  407.  
  408. JNIEXPORT jobjectArray JNICALL
  409. JVM_GetClassInterfaces(JNIEnv *env, jclass cls);
  410.  
  411. JNIEXPORT jobject JNICALL
  412. JVM_GetClassLoader(JNIEnv *env, jclass cls);
  413.  
  414. JNIEXPORT jboolean JNICALL
  415. JVM_IsInterface(JNIEnv *env, jclass cls);
  416.  
  417. JNIEXPORT jobjectArray JNICALL
  418. JVM_GetClassSigners(JNIEnv *env, jclass cls);
  419.  
  420. JNIEXPORT void JNICALL
  421. JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers);
  422.  
  423. JNIEXPORT jobject JNICALL
  424. JVM_GetProtectionDomain(JNIEnv *env, jclass cls);
  425.  
  426. JNIEXPORT void JNICALL
  427. JVM_SetProtectionDomain(JNIEnv *env, jclass cls, jobject protection_domain);
  428.  
  429. JNIEXPORT jboolean JNICALL
  430. JVM_IsArrayClass(JNIEnv *env, jclass cls);
  431.  
  432. JNIEXPORT jboolean JNICALL
  433. JVM_IsPrimitiveClass(JNIEnv *env, jclass cls);
  434.  
  435. JNIEXPORT jclass JNICALL
  436. JVM_GetComponentType(JNIEnv *env, jclass cls);
  437.  
  438. JNIEXPORT jint JNICALL
  439. JVM_GetClassModifiers(JNIEnv *env, jclass cls);
  440.  
  441. /*
  442.  * reflecting fields and methods.
  443.  * which: 0 --- MEMBER_PUBLIC
  444.  *        1 --- MEMBER_DECLARED
  445.  */
  446.  
  447. JNIEXPORT jobjectArray JNICALL
  448. JVM_GetClassFields(JNIEnv *env, jclass cls, jint which);
  449.  
  450. JNIEXPORT jobjectArray JNICALL
  451. JVM_GetClassMethods(JNIEnv *env, jclass cls, jint which);
  452.  
  453. JNIEXPORT jobjectArray JNICALL
  454. JVM_GetClassConstructors(JNIEnv *env, jclass cls, jint which);
  455.  
  456. JNIEXPORT jobject JNICALL
  457. JVM_GetClassField(JNIEnv *env, jclass cls, jstring name, jint which);
  458.  
  459. JNIEXPORT jobject JNICALL
  460. JVM_GetClassMethod(JNIEnv *env, jclass cls, jstring name, jobjectArray types,
  461.            jint which);
  462. JNIEXPORT jobject JNICALL
  463. JVM_GetClassConstructor(JNIEnv *env, jclass cls, jobjectArray types,
  464.             jint which);
  465.  
  466. JNIEXPORT jobjectArray JNICALL
  467. JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass);
  468.  
  469. JNIEXPORT jclass JNICALL
  470. JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass);
  471.  
  472. /*
  473.  * Implements Class.newInstance
  474.  */
  475. JNIEXPORT jobject JNICALL
  476. JVM_NewInstance(JNIEnv *env, jclass cls);
  477.  
  478. /*
  479.  * java.security.*
  480.  */
  481.  
  482. JNIEXPORT jobject JNICALL
  483. JVM_DoPrivileged(JNIEnv *env, jclass cls, 
  484.          jobject action, jobject context, jboolean wrapException);
  485.  
  486. JNIEXPORT jobject JNICALL
  487. JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls);
  488.  
  489. JNIEXPORT jobject JNICALL
  490. JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls);
  491.  
  492. /*
  493.  * Signal support, used to implement the shutdown sequence.  Every VM must
  494.  * support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts
  495.  * (^C) and the latter for external termination (kill, system shutdown, etc.).
  496.  * Other platform-dependent signal values may also be supported.
  497.  */
  498.  
  499. JNIEXPORT void * JNICALL
  500. JVM_RegisterSignal(jint sig, void *handler);
  501.  
  502. JNIEXPORT void JNICALL
  503. JVM_RaiseSignal(jint sig);
  504.  
  505. JNIEXPORT jint JNICALL
  506. JVM_FindSignal(const char *name);
  507.  
  508. /*************************************************************************
  509.  PART 2: Support for the Verifier and Class File Format Checker
  510.  ************************************************************************/
  511. /*
  512.  * Return the class name in UTF format. The result is valid
  513.  * until JVM_ReleaseUTf is called.
  514.  *
  515.  * The caller must treat the string as a constant and not modify it
  516.  * in any way.
  517.  */
  518. JNIEXPORT const char * JNICALL
  519. JVM_GetClassNameUTF(JNIEnv *env, jclass cb);
  520.  
  521. /*
  522.  * Returns the constant pool types in the buffer provided by "types."
  523.  */  
  524. JNIEXPORT void JNICALL
  525. JVM_GetClassCPTypes(JNIEnv *env, jclass cb, unsigned char *types);
  526.  
  527. /*
  528.  * Returns the number of Constant Pool entries.
  529.  */
  530. JNIEXPORT jint JNICALL
  531. JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cb);
  532.  
  533. /*
  534.  * Returns the number of *declared* fields or methods.
  535.  */
  536. JNIEXPORT jint JNICALL
  537. JVM_GetClassFieldsCount(JNIEnv *env, jclass cb);
  538.  
  539. JNIEXPORT jint JNICALL
  540. JVM_GetClassMethodsCount(JNIEnv *env, jclass cb);
  541.  
  542. /*
  543.  * Returns the CP indexes of exceptions raised by a given method.
  544.  * Places the result in the given buffer.
  545.  *
  546.  * The method is identified by method_index.
  547.  */
  548. JNIEXPORT void JNICALL
  549. JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cb, jint method_index,
  550.                 unsigned short *exceptions); 
  551. /*
  552.  * Returns the number of exceptions raised by a given method.
  553.  * The method is identified by method_index.
  554.  */
  555. JNIEXPORT jint JNICALL
  556. JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cb, jint method_index);
  557.  
  558. /*
  559.  * Returns the byte code sequence of a given method.
  560.  * Places the result in the given buffer.
  561.  *
  562.  * The method is identified by method_index.
  563.  */
  564. JNIEXPORT void JNICALL
  565. JVM_GetMethodIxByteCode(JNIEnv *env, jclass cb, jint method_index, 
  566.             unsigned char *code);
  567.  
  568. /*
  569.  * Returns the length of the byte code sequence of a given method.
  570.  * The method is identified by method_index.
  571.  */
  572. JNIEXPORT jint JNICALL
  573. JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cb, jint method_index);
  574.  
  575. /*
  576.  * A structure used to a capture exception table entry in a Java method.
  577.  */
  578. typedef struct {
  579.     jint start_pc;
  580.     jint end_pc;
  581.     jint handler_pc;
  582.     jint catchType;
  583. } JVM_ExceptionTableEntryType;
  584.  
  585. /*
  586.  * Returns the exception table entry at entry_index of a given method.
  587.  * Places the result in the given buffer.
  588.  *
  589.  * The method is identified by method_index.
  590.  */
  591. JNIEXPORT void JNICALL
  592. JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cb, jint method_index,
  593.                    jint entry_index,
  594.                    JVM_ExceptionTableEntryType *entry);
  595.  
  596. /*
  597.  * Returns the length of the exception table of a given method.
  598.  * The method is identified by method_index.
  599.  */
  600. JNIEXPORT jint JNICALL
  601. JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cb, int index);
  602.  
  603. /*
  604.  * Returns the modifiers of a given field.
  605.  * The field is identified by field_index.
  606.  */
  607. JNIEXPORT jint JNICALL
  608. JVM_GetFieldIxModifiers(JNIEnv *env, jclass cb, int index);
  609.  
  610. /*
  611.  * Returns the modifiers of a given method.
  612.  * The method is identified by method_index.
  613.  */
  614. JNIEXPORT jint JNICALL
  615. JVM_GetMethodIxModifiers(JNIEnv *env, jclass cb, int index);
  616.  
  617. /*
  618.  * Returns the number of local variables of a given method.
  619.  * The method is identified by method_index.
  620.  */ 
  621. JNIEXPORT jint JNICALL
  622. JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cb, int index);
  623.  
  624. /*
  625.  * Returns the number of arguments (including this pointer) of a given method.
  626.  * The method is identified by method_index.
  627.  */ 
  628. JNIEXPORT jint JNICALL
  629. JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cb, int index);
  630.  
  631. /* 
  632.  * Returns the maximum amount of stack (in words) used by a given method.
  633.  * The method is identified by method_index.
  634.  */ 
  635. JNIEXPORT jint JNICALL
  636. JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cb, int index);
  637.  
  638. /*
  639.  * Is a given method a constructor.
  640.  * The method is identified by method_index.
  641.  */ 
  642. JNIEXPORT jboolean JNICALL
  643. JVM_IsConstructorIx(JNIEnv *env, jclass cb, int index);
  644.  
  645. /*
  646.  * Returns the name of a given method in UTF format.
  647.  * The result remains valid until JVM_ReleaseUTF is called.
  648.  *
  649.  * The caller must treat the string as a constant and not modify it
  650.  * in any way.
  651.  */
  652. JNIEXPORT const char * JNICALL
  653. JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cb, jint index);
  654.  
  655. /*
  656.  * Returns the signature of a given method in UTF format.
  657.  * The result remains valid until JVM_ReleaseUTF is called.
  658.  *
  659.  * The caller must treat the string as a constant and not modify it
  660.  * in any way.
  661.  */
  662. JNIEXPORT const char * JNICALL
  663. JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cb, jint index);
  664.  
  665. /*
  666.  * Returns the name of the field refered to at a given constant pool
  667.  * index.
  668.  *
  669.  * The result is in UTF format and remains valid until JVM_ReleaseUTF
  670.  * is called.
  671.  *
  672.  * The caller must treat the string as a constant and not modify it
  673.  * in any way.
  674.  */
  675. JNIEXPORT const char * JNICALL
  676. JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cb, jint index);
  677.  
  678. /*
  679.  * Returns the name of the method refered to at a given constant pool
  680.  * index.
  681.  *
  682.  * The result is in UTF format and remains valid until JVM_ReleaseUTF
  683.  * is called.
  684.  *
  685.  * The caller must treat the string as a constant and not modify it
  686.  * in any way.
  687.  */
  688. JNIEXPORT const char * JNICALL
  689. JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cb, jint index);
  690.  
  691. /*
  692.  * Returns the signature of the method refered to at a given constant pool
  693.  * index.
  694.  *
  695.  * The result is in UTF format and remains valid until JVM_ReleaseUTF
  696.  * is called.
  697.  *
  698.  * The caller must treat the string as a constant and not modify it
  699.  * in any way.
  700.  */
  701. JNIEXPORT const char * JNICALL
  702. JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cb, jint index);
  703.  
  704. /*
  705.  * Returns the signature of the field refered to at a given constant pool
  706.  * index.
  707.  *
  708.  * The result is in UTF format and remains valid until JVM_ReleaseUTF
  709.  * is called.
  710.  *
  711.  * The caller must treat the string as a constant and not modify it
  712.  * in any way.
  713.  */
  714. JNIEXPORT const char * JNICALL
  715. JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cb, jint index);
  716.  
  717. /*
  718.  * Returns the class name refered to at a given constant pool index.
  719.  *
  720.  * The result is in UTF format and remains valid until JVM_ReleaseUTF
  721.  * is called.
  722.  *
  723.  * The caller must treat the string as a constant and not modify it
  724.  * in any way.
  725.  */
  726. JNIEXPORT const char * JNICALL
  727. JVM_GetCPClassNameUTF(JNIEnv *env, jclass cb, jint index);
  728.  
  729. /*
  730.  * Returns the class name refered to at a given constant pool index.
  731.  *
  732.  * The constant pool entry must refer to a CONSTANT_Fieldref.
  733.  *
  734.  * The result is in UTF format and remains valid until JVM_ReleaseUTF
  735.  * is called.
  736.  *
  737.  * The caller must treat the string as a constant and not modify it
  738.  * in any way.
  739.  */
  740. JNIEXPORT const char * JNICALL
  741. JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cb, jint index);
  742.  
  743. /*
  744.  * Returns the class name refered to at a given constant pool index.
  745.  *
  746.  * The constant pool entry must refer to CONSTANT_Methodref or
  747.  * CONSTANT_InterfaceMethodref.
  748.  *
  749.  * The result is in UTF format and remains valid until JVM_ReleaseUTF
  750.  * is called.
  751.  *
  752.  * The caller must treat the string as a constant and not modify it
  753.  * in any way.
  754.  */
  755. JNIEXPORT const char * JNICALL
  756. JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cb, jint index);
  757.  
  758. /*
  759.  * Returns the modifiers of a field in calledClass. The field is
  760.  * referred to in class cb at constant pool entry index.
  761.  *
  762.  * The caller must treat the string as a constant and not modify it
  763.  * in any way.
  764.  *
  765.  * Returns -1 if the field does not exist in calledClass.
  766.  */
  767. JNIEXPORT jint JNICALL
  768. JVM_GetCPFieldModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
  769.  
  770. /*
  771.  * Returns the modifiers of a method in calledClass. The method is
  772.  * referred to in class cb at constant pool entry index.
  773.  *
  774.  * Returns -1 if the method does not exist in calledClass.
  775.  */
  776. JNIEXPORT jint JNICALL
  777. JVM_GetCPMethodModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
  778.  
  779. /*
  780.  * Releases the UTF string obtained from the VM. 
  781.  */
  782. JNIEXPORT void JNICALL
  783. JVM_ReleaseUTF(const char *utf);
  784.  
  785. /*
  786.  * Compare if two classes are in the same package. 
  787.  */
  788. JNIEXPORT jboolean JNICALL
  789. JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2);
  790.  
  791. /* Constants in class files */
  792.  
  793. #define JVM_ACC_PUBLIC        0x0001  /* visible to everyone */
  794. #define JVM_ACC_PRIVATE       0x0002  /* visible only to the defining class */
  795. #define JVM_ACC_PROTECTED     0x0004  /* visible to subclasses */
  796. #define JVM_ACC_STATIC        0x0008  /* instance variable is static */
  797. #define JVM_ACC_FINAL         0x0010  /* no further subclassing, overriding */
  798. #define JVM_ACC_SYNCHRONIZED  0x0020  /* wrap method call in monitor lock */
  799. #define JVM_ACC_SUPER         0x0020  /* funky handling of invokespecial */
  800. #define JVM_ACC_VOLATILE      0x0040  /* can cache in registers */
  801. #define JVM_ACC_TRANSIENT     0x0080  /* not persistant */
  802. #define JVM_ACC_NATIVE        0x0100  /* implemented in C */
  803. #define JVM_ACC_INTERFACE     0x0200  /* class is an interface */
  804. #define JVM_ACC_ABSTRACT      0x0400  /* no definition provided */
  805. #define JVM_ACC_STRICT          0x0800  /* strict floating point */
  806.  
  807. enum {
  808.     JVM_CONSTANT_Utf8 = 1,
  809.     JVM_CONSTANT_Unicode,        /* unused */
  810.     JVM_CONSTANT_Integer,
  811.     JVM_CONSTANT_Float,
  812.     JVM_CONSTANT_Long,      
  813.     JVM_CONSTANT_Double,
  814.     JVM_CONSTANT_Class,
  815.     JVM_CONSTANT_String,
  816.     JVM_CONSTANT_Fieldref,
  817.     JVM_CONSTANT_Methodref,
  818.     JVM_CONSTANT_InterfaceMethodref,
  819.     JVM_CONSTANT_NameAndType
  820. };
  821.  
  822. /* Used in the newarray instruction. */
  823.  
  824. #define JVM_T_BOOLEAN 4
  825. #define JVM_T_CHAR    5
  826. #define JVM_T_FLOAT   6
  827. #define JVM_T_DOUBLE  7
  828. #define JVM_T_BYTE    8
  829. #define JVM_T_SHORT   9
  830. #define JVM_T_INT    10
  831. #define JVM_T_LONG   11
  832.  
  833. /* JVM method signatures */
  834.  
  835. #define JVM_SIGNATURE_ARRAY        '['
  836. #define JVM_SIGNATURE_BYTE        'B'
  837. #define JVM_SIGNATURE_CHAR        'C'
  838. #define JVM_SIGNATURE_CLASS        'L'
  839. #define JVM_SIGNATURE_ENDCLASS            ';'
  840. #define JVM_SIGNATURE_ENUM        'E'
  841. #define JVM_SIGNATURE_FLOAT        'F'
  842. #define JVM_SIGNATURE_DOUBLE            'D'
  843. #define JVM_SIGNATURE_FUNC        '('
  844. #define JVM_SIGNATURE_ENDFUNC            ')'
  845. #define JVM_SIGNATURE_INT        'I'
  846. #define JVM_SIGNATURE_LONG        'J'
  847. #define JVM_SIGNATURE_SHORT        'S'
  848. #define JVM_SIGNATURE_VOID        'V'
  849. #define JVM_SIGNATURE_BOOLEAN            'Z'
  850.  
  851. /* 
  852.  * A function defined by the byte-code verifier and called by the VM.
  853.  * This is not a function implemented in the VM.
  854.  *
  855.  * Returns JNI_FALSE if verification fails. A detailed error message
  856.  * will be places in msg_buf, whose length is specified by buf_len.
  857.  */ 
  858. typedef jboolean (*verifier_fn_t)(JNIEnv *env, 
  859.                   jclass cb,
  860.                   char * msg_buf, 
  861.                   jint buf_len);
  862.  
  863.  
  864. /*
  865.  * Support for a VM-independent class format checker.
  866.  */ 
  867. typedef struct {
  868.     unsigned long code;    /* byte code */
  869.     unsigned long excs;    /* exceptions */
  870.     unsigned long etab;    /* catch table */
  871.     unsigned long lnum;    /* line number */
  872.     unsigned long lvar;    /* local vars */
  873. } method_size_info;
  874.  
  875. typedef struct {
  876.     unsigned int constants;    /* constant pool */
  877.     unsigned int fields;
  878.     unsigned int methods;
  879.     unsigned int interfaces;
  880.     unsigned int fields2;      /* number of static 2-word fields */
  881.     unsigned int innerclasses; /* # of records in InnerClasses attr */
  882.  
  883.     method_size_info clinit;   /* memory used in clinit */
  884.     method_size_info main;     /* used everywhere else */
  885. } class_size_info;
  886.  
  887. /* 
  888.  * Functions defined in libjava.so to perform string conversions.
  889.  * 
  890.  */
  891.  
  892. typedef jstring (*to_java_string_fn_t)(JNIEnv *env, char *str);
  893.  
  894. typedef char *(*to_c_string_fn_t)(JNIEnv *env, jstring s, jboolean *b);
  895.  
  896. /* This is the function defined in libjava.so that performs class
  897.  * format checks. This functions fills in size information about
  898.  * the class file and returns:
  899.  *  
  900.  *   0: good
  901.  *  -1: out of memory
  902.  *  -2: bad format
  903.  *  -3: unsupported version
  904.  *  -4: bad class name
  905.  */
  906.  
  907. typedef jint (*check_format_fn_t)(char *class_name,
  908.                   unsigned char *data,
  909.                   unsigned int data_size,
  910.                   class_size_info *class_size,
  911.                   char *message_buffer,
  912.                   jint buffer_length,
  913.                   jboolean measure_only,
  914.                   jboolean check_relaxed);
  915.  
  916. #define JVM_RECOGNIZED_CLASS_MODIFIERS (JVM_ACC_PUBLIC | \
  917.                     JVM_ACC_FINAL | \
  918.                     JVM_ACC_SUPER | \
  919.                     JVM_ACC_INTERFACE | \
  920.                     JVM_ACC_ABSTRACT)    
  921.        
  922. #define JVM_RECOGNIZED_FIELD_MODIFIERS (JVM_ACC_PUBLIC | \
  923.                     JVM_ACC_PRIVATE | \
  924.                     JVM_ACC_PROTECTED | \
  925.                     JVM_ACC_STATIC | \
  926.                     JVM_ACC_FINAL | \
  927.                     JVM_ACC_VOLATILE | \
  928.                     JVM_ACC_TRANSIENT)
  929.  
  930. #define JVM_RECOGNIZED_METHOD_MODIFIERS (JVM_ACC_PUBLIC | \
  931.                      JVM_ACC_PRIVATE | \
  932.                      JVM_ACC_PROTECTED | \
  933.                      JVM_ACC_STATIC | \
  934.                      JVM_ACC_FINAL | \
  935.                      JVM_ACC_SYNCHRONIZED | \
  936.                      JVM_ACC_NATIVE | \
  937.                      JVM_ACC_ABSTRACT | \
  938.                      JVM_ACC_STRICT)
  939.  
  940. /* 
  941.  * This is the function defined in libjava.so to perform path 
  942.  * canonicalization. VM call this function before opening jar files
  943.  * to load system classes.
  944.  *
  945.  */
  946.  
  947. typedef int (*canonicalize_fn_t)(JNIEnv *env, char *orig, char *out, int len);
  948.  
  949. /*************************************************************************
  950.  PART 3: I/O and Network Support
  951.  ************************************************************************/
  952.  
  953. /* Note that the JVM IO functions are expected to return JVM_IO_ERR
  954.  * when there is any kind of error. The caller can then use the
  955.  * platform specific support (e.g., errno) to get the detailed 
  956.  * error info.  The JVM_GetLastErrorString procedure may also be used
  957.  * to obtain a descriptive error string.
  958.  */
  959. #define JVM_IO_ERR  (-1)
  960.  
  961. /* For interruptible IO. Returning JVM_IO_INTR indicates that an IO
  962.  * operation has been disrupted by Thread.interrupt. There are a 
  963.  * number of technical difficulties related to interruptible IO that
  964.  * need to be solved. For example, most existing programs do not handle
  965.  * InterruptedIOExceptions specially, they simply treat those as any 
  966.  * IOExceptions, which typically indicate fatal errors.
  967.  *
  968.  * There are also two modes of operation for interruptible IO. In the
  969.  * resumption mode, an interrupted IO operation is guaranteed not to
  970.  * have any side-effects, and can be restarted. In the termination mode,
  971.  * an interrupted IO operation corrupts the underlying IO stream, so
  972.  * that the only reasonable operation on an interrupted stream is to
  973.  * close that stream. The resumption mode seems to be impossible to
  974.  * implement on Win32 and Solaris. Implementing the termination mode is
  975.  * easier, but it's not clear that's the right semantics.
  976.  *
  977.  * Interruptible IO is not supported on Win32.It can be enabled/disabled
  978.  * using a compile-time flag on Solaris. Third-party JVM ports do not 
  979.  * need to implement interruptible IO.
  980.  */
  981. #define JVM_IO_INTR (-2)
  982.  
  983. /* Write a string into the given buffer, in the platform's local encoding,
  984.  * that describes the most recent system-level error to occur in this thread.
  985.  * Return the length of the string or zero if no error occurred.
  986.  */
  987. JNIEXPORT jint JNICALL
  988. JVM_GetLastErrorString(char *buf, int len);
  989.  
  990. /*
  991.  * Convert a pathname into native format.  This function does syntactic
  992.  * cleanup, such as removing redundant separator characters.  It modifies
  993.  * the given pathname string in place.
  994.  */
  995. JNIEXPORT char * JNICALL
  996. JVM_NativePath(char *);
  997.  
  998. /*
  999.  * JVM I/O error codes
  1000.  */
  1001. #define JVM_EEXIST       -100
  1002.  
  1003. /*
  1004.  * Open a file descriptor. This function returns a negative error code
  1005.  * on error, and a non-negative integer that is the file descriptor on
  1006.  * success.  
  1007.  */
  1008. JNIEXPORT jint JNICALL
  1009. JVM_Open(const char *fname, jint flags, jint mode);
  1010.  
  1011. /*
  1012.  * Close a file descriptor. This function returns -1 on error, and 0
  1013.  * on success.
  1014.  *
  1015.  * fd        the file descriptor to close.
  1016.  */
  1017. JNIEXPORT jint JNICALL
  1018. JVM_Close(jint fd);
  1019.  
  1020. /*
  1021.  * Read data from a file decriptor into a char array.
  1022.  *
  1023.  * fd        the file descriptor to read from.
  1024.  * buf       the buffer where to put the read data.
  1025.  * nbytes    the number of bytes to read.
  1026.  *
  1027.  * This function returns -1 on error, and 0 on success.
  1028.  */
  1029. JNIEXPORT jint JNICALL
  1030. JVM_Read(jint fd, char *buf, jint nbytes);
  1031.  
  1032. /*
  1033.  * Write data from a char array to a file decriptor.
  1034.  *
  1035.  * fd        the file descriptor to read from.
  1036.  * buf       the buffer from which to fetch the data.
  1037.  * nbytes    the number of bytes to write.
  1038.  *
  1039.  * This function returns -1 on error, and 0 on success.
  1040.  */
  1041. JNIEXPORT jint JNICALL
  1042. JVM_Write(jint fd, char *buf, jint nbytes);
  1043.  
  1044. /*
  1045.  * Returns the number of bytes available for reading from a given file
  1046.  * descriptor
  1047.  */
  1048. JNIEXPORT jint JNICALL
  1049. JVM_Available(jint fd, jlong *pbytes);
  1050.  
  1051. /*
  1052.  * Move the file descriptor pointer from whence by offet.
  1053.  *
  1054.  * fd        the file descriptor to move.
  1055.  * offset    the number of bytes to move it by.
  1056.  * whence    the start from where to move it.
  1057.  *
  1058.  * This function returns the resulting pointer location.
  1059.  */
  1060. JNIEXPORT jlong JNICALL
  1061. JVM_Lseek(jint fd, jlong offset, jint whence);
  1062.  
  1063. /*
  1064.  * Set the length of the file associated with the given descriptor to the given
  1065.  * length.  If the new length is longer than the current length then the file
  1066.  * is extended; the contents of the extended portion are not defined.  The
  1067.  * value of the file pointer is undefined after this procedure returns.
  1068.  */
  1069. JNIEXPORT jint JNICALL
  1070. JVM_SetLength(jint fd, jlong length);
  1071.  
  1072. /*
  1073.  * Synchronize the file descriptor's in memory state with that of the
  1074.  * physical device.  Return of -1 is an error, 0 is OK.
  1075.  */
  1076. JNIEXPORT jint JNICALL
  1077. JVM_Sync(jint fd);
  1078.  
  1079. /*
  1080.  * Networking library support
  1081.  */
  1082.  
  1083. JNIEXPORT jint JNICALL
  1084. JVM_InitializeSocketLibrary(void);
  1085.  
  1086. struct sockaddr;
  1087.  
  1088. JNIEXPORT jint JNICALL
  1089. JVM_Socket(jint domain, jint type, jint protocol);
  1090.  
  1091. JNIEXPORT jint JNICALL
  1092. JVM_SocketClose(jint fd);
  1093.  
  1094. JNIEXPORT jint JNICALL
  1095. JVM_SocketShutdown(jint fd, jint howto);
  1096.  
  1097. JNIEXPORT jint JNICALL
  1098. JVM_Recv(jint fd, char *buf, jint nBytes, jint flags);
  1099.  
  1100. JNIEXPORT jint JNICALL
  1101. JVM_Send(jint fd, char *buf, jint nBytes, jint flags);
  1102.  
  1103. JNIEXPORT jint JNICALL
  1104. JVM_Timeout(int fd, long timeout);
  1105.  
  1106. JNIEXPORT jint JNICALL
  1107. JVM_Listen(jint fd, jint count);
  1108.  
  1109. JNIEXPORT jint JNICALL
  1110. JVM_Connect(jint fd, struct sockaddr *him, jint len);
  1111.  
  1112. JNIEXPORT jint JNICALL
  1113. JVM_Bind(jint fd, struct sockaddr *him, jint len);
  1114.  
  1115. JNIEXPORT jint JNICALL
  1116. JVM_Accept(jint fd, struct sockaddr *him, jint *len);
  1117.  
  1118. JNIEXPORT jint JNICALL
  1119. JVM_RecvFrom(jint fd, char *buf, int nBytes,
  1120.                   int flags, struct sockaddr *from, int *fromlen);
  1121.  
  1122. JNIEXPORT jint JNICALL
  1123. JVM_SendTo(jint fd, char *buf, int len,
  1124.                 int flags, struct sockaddr *to, int tolen);
  1125.  
  1126. JNIEXPORT jint JNICALL
  1127. JVM_SocketAvailable(jint fd, jint *result);
  1128.  
  1129.  
  1130. JNIEXPORT jint JNICALL
  1131. JVM_GetSockName(jint fd, struct sockaddr *him, int *len);
  1132.  
  1133. JNIEXPORT jint JNICALL
  1134. JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen);
  1135.  
  1136. JNIEXPORT jint JNICALL
  1137. JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen);
  1138.  
  1139. JNIEXPORT struct protoent * JNICALL
  1140. JVM_GetProtoByName(char* name);
  1141.  
  1142. JNIEXPORT int JNICALL
  1143. JVM_GetHostName(char* name, int namelen);
  1144.  
  1145. JNIEXPORT struct hostent* JNICALL
  1146. JVM_GetHostByAddr(const char* name, int len, int type);
  1147.  
  1148. JNIEXPORT struct hostent* JNICALL
  1149. JVM_GetHostByName(char* name);
  1150.  
  1151. /* 
  1152.  * The standard printing functions supported by the Java VM. (Should they
  1153.  * be renamed to JVM_* in the future?  
  1154.  */
  1155.  
  1156. /* 
  1157.  * BE CAREFUL! The following functions do not implement the
  1158.  * full feature set of standard C printf formats.
  1159.  */
  1160. int
  1161. jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
  1162.  
  1163. int
  1164. jio_snprintf(char *str, size_t count, const char *fmt, ...);
  1165.  
  1166. int
  1167. jio_fprintf(FILE *, const char *fmt, ...);
  1168.  
  1169. int
  1170. jio_vfprintf(FILE *, const char *fmt, va_list args);
  1171.  
  1172.  
  1173. JNIEXPORT void * JNICALL
  1174. JVM_RawMonitorCreate(void);
  1175.  
  1176. JNIEXPORT void JNICALL
  1177. JVM_RawMonitorDestroy(void *mon);
  1178.  
  1179. JNIEXPORT jint JNICALL
  1180. JVM_RawMonitorEnter(void *mon);
  1181.  
  1182. JNIEXPORT void JNICALL
  1183. JVM_RawMonitorExit(void *mon);
  1184.  
  1185. #ifdef __cplusplus
  1186. } /* extern "C" */
  1187. #endif /* __cplusplus */
  1188.  
  1189. #endif /* !_JAVASOFT_JVM_H_ */
  1190.