jvm.h revision 1879:f95d63e2154a
150477Speter/*
235388Smjacob * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
335388Smjacob * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
435388Smjacob *
566189Smjacob * This code is free software; you can redistribute it and/or modify it
635388Smjacob * under the terms of the GNU General Public License version 2 only, as
752347Smjacob * published by the Free Software Foundation.
835388Smjacob *
935388Smjacob * This code is distributed in the hope that it will be useful, but WITHOUT
1035388Smjacob * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1135388Smjacob * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1235388Smjacob * version 2 for more details (a copy is included in the LICENSE file that
1335388Smjacob * accompanied this code).
1466189Smjacob *
1535388Smjacob * You should have received a copy of the GNU General Public License version
1635388Smjacob * 2 along with this work; if not, write to the Free Software Foundation,
1735388Smjacob * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1835388Smjacob *
1935388Smjacob * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2035388Smjacob * or visit www.oracle.com if you need additional information or have any
2135388Smjacob * questions.
2235388Smjacob *
2335388Smjacob */
2435388Smjacob
2535388Smjacob#ifndef SHARE_VM_PRIMS_JVM_H
2635388Smjacob#define SHARE_VM_PRIMS_JVM_H
2735388Smjacob
2835388Smjacob#include "prims/jni.h"
2935388Smjacob#include "runtime/reflectionCompat.hpp"
3035388Smjacob#include "utilities/globalDefinitions.hpp"
3135388Smjacob#ifdef TARGET_OS_FAMILY_linux
3235388Smjacob# include "jvm_linux.h"
3335388Smjacob#endif
3444819Smjacob#ifdef TARGET_OS_FAMILY_solaris
3535388Smjacob# include "jvm_solaris.h"
3653487Smjacob#endif
3753487Smjacob#ifdef TARGET_OS_FAMILY_windows
3856004Smjacob# include "jvm_windows.h"
3935388Smjacob#endif
4053487Smjacob
4135388Smjacob#ifndef _JAVASOFT_JVM_H_
4235388Smjacob#define _JAVASOFT_JVM_H_
4353487Smjacob
4453487Smjacob// HotSpot integration note:
4556004Smjacob//
4635388Smjacob// This file and jvm.h used with the JDK are identical,
4753487Smjacob// except for the three includes removed below and the
4835388Smjacob// SUPPORT_OLD_REFLECTION sections cut out of the JDK's jvm.h.
4942131Smjacob
5053487Smjacob// #include <sys/stat.h>
5153487Smjacob// #include "jni.h"
5256004Smjacob// #include "jvm_md.h"
5335388Smjacob
5453487Smjacob
5535388Smjacob#ifdef __cplusplus
5664087Smjacobextern "C" {
5787635Smjacob#endif
5839235Sgibbs
5935388Smjacob/*
6043420Smjacob * This file contains additional functions exported from the VM.
6135388Smjacob * These functions are complementary to the standard JNI support.
6235388Smjacob * There are three parts to this file:
6335388Smjacob *
6482689Smjacob * First, this file contains the VM-related functions needed by native
6582689Smjacob * libraries in the standard Java API. For example, the java.lang.Object
6674229Smjacob * class needs VM-level functions that wait for and notify monitors.
6774229Smjacob *
6874229Smjacob * Second, this file contains the functions and constant definitions
6974229Smjacob * needed by the byte code verifier and class file format checker.
7082689Smjacob * These functions allow the verifier and format checker to be written
7135388Smjacob * in a VM-independent way.
7282689Smjacob *
7374229Smjacob * Third, this file contains various I/O and nerwork operations needed
7474229Smjacob * by the standard Java I/O and network APIs.
7574229Smjacob */
7690224Smjacob
7735388Smjacob/*
7835388Smjacob * Bump the version number when either of the following happens:
7935388Smjacob *
8035388Smjacob * 1. There is a change in JVM_* functions.
8164087Smjacob *
8264087Smjacob * 2. There is a change in the contract between VM and Java classes.
8364087Smjacob *    For example, if the VM relies on a new private field in Thread
8482689Smjacob *    class.
8582689Smjacob */
8649909Smjacob
8761772Smjacob#define JVM_INTERFACE_VERSION 4
8849909Smjacob
8982689Smjacob
9082689SmjacobJNIEXPORT jint JNICALL
9182689SmjacobJVM_GetInterfaceVersion(void);
9282689Smjacob
9382689Smjacob/*************************************************************************
9482689Smjacob PART 1: Functions for Native Libraries
9553487Smjacob ************************************************************************/
9653487Smjacob/*
9764087Smjacob * java.lang.Object
9864087Smjacob */
9953487SmjacobJNIEXPORT jint JNICALL
10082689SmjacobJVM_IHashCode(JNIEnv *env, jobject obj);
10182689Smjacob
10253487SmjacobJNIEXPORT void JNICALL
10353487SmjacobJVM_MonitorWait(JNIEnv *env, jobject obj, jlong ms);
10453487Smjacob
10553487SmjacobJNIEXPORT void JNICALL
10653487SmjacobJVM_MonitorNotify(JNIEnv *env, jobject obj);
10753487Smjacob
10853487SmjacobJNIEXPORT void JNICALL
10953487SmjacobJVM_MonitorNotifyAll(JNIEnv *env, jobject obj);
11053487Smjacob
11153487SmjacobJNIEXPORT jobject JNICALL
11253487SmjacobJVM_Clone(JNIEnv *env, jobject obj);
11353487Smjacob
11453487Smjacob/*
11553487Smjacob * java.lang.String
11653487Smjacob */
11753487SmjacobJNIEXPORT jstring JNICALL
11853487SmjacobJVM_InternString(JNIEnv *env, jstring str);
11953487Smjacob
12053487Smjacob/*
12153487Smjacob * java.lang.System
12253487Smjacob */
12364087SmjacobJNIEXPORT jlong JNICALL
12464087SmjacobJVM_CurrentTimeMillis(JNIEnv *env, jclass ignored);
12553487Smjacob
12653487SmjacobJNIEXPORT jlong JNICALL
12753487SmjacobJVM_NanoTime(JNIEnv *env, jclass ignored);
12853487Smjacob
12953487SmjacobJNIEXPORT void JNICALL
13053487SmjacobJVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos,
13153487Smjacob              jobject dst, jint dst_pos, jint length);
13264087Smjacob
13364087SmjacobJNIEXPORT jobject JNICALL
13464087SmjacobJVM_InitProperties(JNIEnv *env, jobject p);
13564087Smjacob
13664087Smjacob/*
13764087Smjacob * java.io.File
13864087Smjacob */
13964087SmjacobJNIEXPORT void JNICALL
14064087SmjacobJVM_OnExit(void (*func)(void));
14164087Smjacob
14264087Smjacob/*
14364087Smjacob * java.lang.Runtime
14464087Smjacob */
14564087SmjacobJNIEXPORT void JNICALL
14664087SmjacobJVM_Exit(jint code);
14764087Smjacob
14864087SmjacobJNIEXPORT void JNICALL
14939235SgibbsJVM_Halt(jint code);
15064087Smjacob
15164087SmjacobJNIEXPORT void JNICALL
15264087SmjacobJVM_GC(void);
15364087Smjacob
15439235Sgibbs/* Returns the number of real-time milliseconds that have elapsed since the
15539235Sgibbs * least-recently-inspected heap object was last inspected by the garbage
15639235Sgibbs * collector.
15765140Smjacob *
15839235Sgibbs * For simple stop-the-world collectors this value is just the time
15952347Smjacob * since the most recent collection.  For generational collectors it is the
16065140Smjacob * time since the oldest generation was most recently collected.  Other
16165140Smjacob * collectors are free to return a pessimistic estimate of the elapsed time, or
16253487Smjacob * simply the time since the last full collection was performed.
16387635Smjacob *
16487635Smjacob * Note that in the presence of reference objects, a given object that is no
16587635Smjacob * longer strongly reachable may have to be inspected multiple times before it
16687635Smjacob * can be reclaimed.
16753487Smjacob */
16835388SmjacobJNIEXPORT jlong JNICALL
16946968SmjacobJVM_MaxObjectInspectionAge(void);
17035388Smjacob
17135388SmjacobJNIEXPORT void JNICALL
17235388SmjacobJVM_TraceInstructions(jboolean on);
17346968Smjacob
17452347SmjacobJNIEXPORT void JNICALL
17552347SmjacobJVM_TraceMethodCalls(jboolean on);
17635388Smjacob
17735388SmjacobJNIEXPORT jlong JNICALL
17842461SmjacobJVM_TotalMemory(void);
17943420Smjacob
18035388SmjacobJNIEXPORT jlong JNICALL
18145040SmjacobJVM_FreeMemory(void);
18265140Smjacob
18335388SmjacobJNIEXPORT jlong JNICALL
18452347SmjacobJVM_MaxMemory(void);
18552347Smjacob
18652347SmjacobJNIEXPORT jint JNICALL
18735388SmjacobJVM_ActiveProcessorCount(void);
18852347Smjacob
18952347SmjacobJNIEXPORT void * JNICALL
19052347SmjacobJVM_LoadLibrary(const char *name);
19135388Smjacob
19280582SmjacobJNIEXPORT void JNICALL
19380582SmjacobJVM_UnloadLibrary(void * handle);
19446968Smjacob
19580582SmjacobJNIEXPORT void * JNICALL
19643420SmjacobJVM_FindLibraryEntry(void *handle, const char *name);
19743420Smjacob
19880582SmjacobJNIEXPORT jboolean JNICALL
19980582SmjacobJVM_IsSupportedJNIVersion(jint version);
20080582Smjacob
20180582Smjacob/*
20280582Smjacob * java.lang.Float and java.lang.Double
20380582Smjacob */
20480582SmjacobJNIEXPORT jboolean JNICALL
20580582SmjacobJVM_IsNaN(jdouble d);
20680582Smjacob
20735388Smjacob/*
20846968Smjacob * java.lang.Throwable
20935388Smjacob */
21035388SmjacobJNIEXPORT void JNICALL
21135388SmjacobJVM_FillInStackTrace(JNIEnv *env, jobject throwable);
21235388Smjacob
21339235SgibbsJNIEXPORT void JNICALL
21439235SgibbsJVM_PrintStackTrace(JNIEnv *env, jobject throwable, jobject printable);
21539235Sgibbs
21639235SgibbsJNIEXPORT jint JNICALL
21739235SgibbsJVM_GetStackTraceDepth(JNIEnv *env, jobject throwable);
21839235Sgibbs
21939235SgibbsJNIEXPORT jobject JNICALL
22039235SgibbsJVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index);
22165140Smjacob
22265140Smjacob/*
22365140Smjacob * java.lang.Compiler
22443793Smjacob */
22539235SgibbsJNIEXPORT void JNICALL
22635388SmjacobJVM_InitializeCompiler (JNIEnv *env, jclass compCls);
22739235Sgibbs
22845040SmjacobJNIEXPORT jboolean JNICALL
22965140SmjacobJVM_IsSilentCompiler(JNIEnv *env, jclass compCls);
23065140Smjacob
23165140SmjacobJNIEXPORT jboolean JNICALL
23265140SmjacobJVM_CompileClass(JNIEnv *env, jclass compCls, jclass cls);
23352347Smjacob
23452347SmjacobJNIEXPORT jboolean JNICALL
23552347SmjacobJVM_CompileClasses(JNIEnv *env, jclass cls, jstring jname);
23652347Smjacob
23735388SmjacobJNIEXPORT jobject JNICALL
23835388SmjacobJVM_CompilerCommand(JNIEnv *env, jclass compCls, jobject arg);
23935388Smjacob
24035388SmjacobJNIEXPORT void JNICALL
24152347SmjacobJVM_EnableCompiler(JNIEnv *env, jclass compCls);
24252347Smjacob
24352347SmjacobJNIEXPORT void JNICALL
24452347SmjacobJVM_DisableCompiler(JNIEnv *env, jclass compCls);
24535388Smjacob
24652347Smjacob/*
24784241Smjacob * java.lang.Thread
24872355Smjacob */
24948484SmjacobJNIEXPORT void JNICALL
25077776SmjacobJVM_StartThread(JNIEnv *env, jobject thread);
25148484Smjacob
25248484SmjacobJNIEXPORT void JNICALL
25359454SmjacobJVM_StopThread(JNIEnv *env, jobject thread, jobject exception);
25448484Smjacob
25572355SmjacobJNIEXPORT jboolean JNICALL
25639235SgibbsJVM_IsThreadAlive(JNIEnv *env, jobject thread);
25739235Sgibbs
25872355SmjacobJNIEXPORT void JNICALL
25952347SmjacobJVM_SuspendThread(JNIEnv *env, jobject thread);
26082841Smjacob
26139235SgibbsJNIEXPORT void JNICALL
26252347SmjacobJVM_ResumeThread(JNIEnv *env, jobject thread);
26352347Smjacob
26452347SmjacobJNIEXPORT void JNICALL
26539235SgibbsJVM_SetThreadPriority(JNIEnv *env, jobject thread, jint prio);
26639235Sgibbs
26748484SmjacobJNIEXPORT void JNICALL
26848484SmjacobJVM_Yield(JNIEnv *env, jclass threadClass);
26935388Smjacob
27048484SmjacobJNIEXPORT void JNICALL
27148484SmjacobJVM_Sleep(JNIEnv *env, jclass threadClass, jlong millis);
27248484Smjacob
27348484SmjacobJNIEXPORT jobject JNICALL
27448484SmjacobJVM_CurrentThread(JNIEnv *env, jclass threadClass);
27548484Smjacob
27648484SmjacobJNIEXPORT jint JNICALL
27744819SmjacobJVM_CountStackFrames(JNIEnv *env, jobject thread);
27848484Smjacob
27952347SmjacobJNIEXPORT void JNICALL
28060221SmjacobJVM_Interrupt(JNIEnv *env, jobject thread);
28177776Smjacob
28277776SmjacobJNIEXPORT jboolean JNICALL
28371079SmjacobJVM_IsInterrupted(JNIEnv *env, jobject thread, jboolean clearInterrupted);
28471079Smjacob
28560221SmjacobJNIEXPORT jboolean JNICALL
28660221SmjacobJVM_HoldsLock(JNIEnv *env, jclass threadClass, jobject obj);
28760221Smjacob
28852347SmjacobJNIEXPORT void JNICALL
28948484SmjacobJVM_DumpAllStacks(JNIEnv *env, jclass unused);
29048484Smjacob
29172355SmjacobJNIEXPORT jobjectArray JNICALL
29244819SmjacobJVM_GetAllThreads(JNIEnv *env, jclass dummy);
29344819Smjacob
29435388Smjacob/* getStackTrace() and getAllStackTraces() method */
29535388SmjacobJNIEXPORT jobjectArray JNICALL
29648195SmjacobJVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads);
29782689Smjacob
29835388Smjacob/*
29935388Smjacob * java.lang.SecurityManager
30048484Smjacob */
30148484SmjacobJNIEXPORT jclass JNICALL
30248484SmjacobJVM_CurrentLoadedClass(JNIEnv *env);
30348484Smjacob
30448484SmjacobJNIEXPORT jobject JNICALL
30548484SmjacobJVM_CurrentClassLoader(JNIEnv *env);
30648484Smjacob
30748484SmjacobJNIEXPORT jobjectArray JNICALL
30835388SmjacobJVM_GetClassContext(JNIEnv *env);
30948484Smjacob
31048484SmjacobJNIEXPORT jint JNICALL
31148484SmjacobJVM_ClassDepth(JNIEnv *env, jstring name);
31272355Smjacob
31372355SmjacobJNIEXPORT jint JNICALL
31472355SmjacobJVM_ClassLoaderDepth(JNIEnv *env);
31577776Smjacob
31677776Smjacob/*
31777776Smjacob * java.lang.Package
31835388Smjacob */
31959454SmjacobJNIEXPORT jstring JNICALL
32059454SmjacobJVM_GetSystemPackage(JNIEnv *env, jstring name);
32159454Smjacob
32259454SmjacobJNIEXPORT jobjectArray JNICALL
32359454SmjacobJVM_GetSystemPackages(JNIEnv *env);
32459454Smjacob
32542131Smjacob/*
32635388Smjacob * java.io.ObjectInputStream
32735388Smjacob */
32865140SmjacobJNIEXPORT jobject JNICALL
32935388SmjacobJVM_AllocateNewObject(JNIEnv *env, jobject obj, jclass currClass,
33035388Smjacob                      jclass initClass);
33135388Smjacob
33235388SmjacobJNIEXPORT jobject JNICALL
33335388SmjacobJVM_AllocateNewArray(JNIEnv *env, jobject obj, jclass currClass,
33435388Smjacob                     jint length);
33553487Smjacob
33635388SmjacobJNIEXPORT jobject JNICALL
33735388SmjacobJVM_LatestUserDefinedLoader(JNIEnv *env);
33835388Smjacob
33935388Smjacob/*
34053487Smjacob * This function has been deprecated and should not be considered
34153487Smjacob * part of the specified JVM interface.
34235388Smjacob */
34335388SmjacobJNIEXPORT jclass JNICALL
34453487SmjacobJVM_LoadClass0(JNIEnv *env, jobject obj, jclass currClass,
34553487Smjacob               jstring currClassName);
34653487Smjacob
34753487Smjacob/*
34853487Smjacob * java.lang.reflect.Array
34953487Smjacob */
35061772SmjacobJNIEXPORT jint JNICALL
35135388SmjacobJVM_GetArrayLength(JNIEnv *env, jobject arr);
35271079Smjacob
35390224SmjacobJNIEXPORT jobject JNICALL
35490224SmjacobJVM_GetArrayElement(JNIEnv *env, jobject arr, jint index);
35587635Smjacob
35687635SmjacobJNIEXPORT jvalue JNICALL
35753487SmjacobJVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode);
35853487Smjacob
35965140SmjacobJNIEXPORT void JNICALL
36087635SmjacobJVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val);
36171079Smjacob
36271079SmjacobJNIEXPORT void JNICALL
36371079SmjacobJVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v,
36471079Smjacob                             unsigned char vCode);
36582689Smjacob
36682689SmjacobJNIEXPORT jobject JNICALL
36782689SmjacobJVM_NewArray(JNIEnv *env, jclass eltClass, jint length);
36882689Smjacob
36982689SmjacobJNIEXPORT jobject JNICALL
37069522SmjacobJVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim);
37169522Smjacob
37269522Smjacob/*
37369522Smjacob * java.lang.Class and java.lang.ClassLoader
37469522Smjacob */
37588855Smjacob/*
37688855Smjacob * Returns the class in which the code invoking the native method
37788855Smjacob * belongs.
37888855Smjacob *
37988855Smjacob * Note that in JDK 1.1, native methods did not create a frame.
38088855Smjacob * In 1.2, they do. Therefore native methods like Class.forName
38139235Sgibbs * can no longer look at the current frame for the caller class.
38235388Smjacob */
38339235SgibbsJNIEXPORT jclass JNICALL
38435388SmjacobJVM_GetCallerClass(JNIEnv *env, int n);
38535388Smjacob
38662171Smjacob/*
38787635Smjacob * Find primitive classes
38887635Smjacob * utf: class name
38939235Sgibbs */
39046968SmjacobJNIEXPORT jclass JNICALL
39146968SmjacobJVM_FindPrimitiveClass(JNIEnv *env, const char *utf);
39252347Smjacob
39352347Smjacob/*
39452347Smjacob * Link the class
39552347Smjacob */
39652347SmjacobJNIEXPORT void JNICALL
39762171SmjacobJVM_ResolveClass(JNIEnv *env, jclass cls);
39871079Smjacob
39990224Smjacob/*
40090224Smjacob * Find a class from a given class loader. Throw ClassNotFoundException
40190224Smjacob * or NoClassDefFoundError depending on the value of the last
40290224Smjacob * argument.
40335388Smjacob */
40435388SmjacobJNIEXPORT jclass JNICALL
40553487SmjacobJVM_FindClassFromClassLoader(JNIEnv *env, const char *name, jboolean init,
40635388Smjacob                             jobject loader, jboolean throwError);
40764087Smjacob
40835388Smjacob/*
40935388Smjacob * Find a class from a boot class loader. Returns NULL if class not found.
41052347Smjacob */
41135388SmjacobJNIEXPORT jclass JNICALL
41248195SmjacobJVM_FindClassFromBootLoader(JNIEnv *env, const char *name);
41348195Smjacob
41482689Smjacob/*
41582689Smjacob * Find a class from a given class.
41665140Smjacob */
41735388SmjacobJNIEXPORT jclass JNICALL
41849909SmjacobJVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init,
41949909Smjacob                             jclass from);
42049909Smjacob
42135388Smjacob/* Find a loaded class cached by the VM */
42264087SmjacobJNIEXPORT jclass JNICALL
42335388SmjacobJVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name);
42435388Smjacob
42535388Smjacob/* Define a class */
42635388SmjacobJNIEXPORT jclass JNICALL
42735388SmjacobJVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf,
42835388Smjacob                jsize len, jobject pd);
42935388Smjacob
43035388Smjacob/* Define a class with a source (added in JDK1.5) */
43135388SmjacobJNIEXPORT jclass JNICALL
43235388SmjacobJVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader,
43343793Smjacob                          const jbyte *buf, jsize len, jobject pd,
43484241Smjacob                          const char *source);
43584241Smjacob
43653487Smjacob/* Define a class with a source with conditional verification (added HSX 14)
43753487Smjacob * -Xverify:all will verify anyway, -Xverify:none will not verify,
43869522Smjacob * -Xverify:remote (default) will obey this conditional
43969522Smjacob * i.e. true = should_verify_class
44069522Smjacob */
44169522SmjacobJNIEXPORT jclass JNICALL
44269522SmjacobJVM_DefineClassWithSourceCond(JNIEnv *env, const char *name,
44335388Smjacob                              jobject loader, const jbyte *buf,
44464087Smjacob                              jsize len, jobject pd, const char *source,
44571079Smjacob                              jboolean verify);
44671079Smjacob
44771079Smjacob/* Define a class with a source (MLVM) */
44871079SmjacobJNIEXPORT jclass JNICALL
44971079SmjacobJVM_DefineClassWithCP(JNIEnv *env, const char *name, jobject loader,
45071079Smjacob                      const jbyte *buf, jsize len, jobject pd,
45171079Smjacob                      const char *source,
45271079Smjacob                      // same args as JVM_DefineClassWithSource to this point
45371079Smjacob                      jobjectArray constants);
45471079Smjacob
45571079Smjacob/*
45671079Smjacob * Reflection support functions
45771079Smjacob */
45871079Smjacob
45971079SmjacobJNIEXPORT jstring JNICALL
46071079SmjacobJVM_GetClassName(JNIEnv *env, jclass cls);
46171079Smjacob
46271079SmjacobJNIEXPORT jobjectArray JNICALL
46379235SmjacobJVM_GetClassInterfaces(JNIEnv *env, jclass cls);
46471079Smjacob
46571079SmjacobJNIEXPORT jobject JNICALL
46671079SmjacobJVM_GetClassLoader(JNIEnv *env, jclass cls);
46771079Smjacob
46871079SmjacobJNIEXPORT jboolean JNICALL
46971079SmjacobJVM_IsInterface(JNIEnv *env, jclass cls);
47071079Smjacob
47171079SmjacobJNIEXPORT jobjectArray JNICALL
47271079SmjacobJVM_GetClassSigners(JNIEnv *env, jclass cls);
47371079Smjacob
47471079SmjacobJNIEXPORT void JNICALL
47571079SmjacobJVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers);
47664087Smjacob
47764087SmjacobJNIEXPORT jobject JNICALL
47871079SmjacobJVM_GetProtectionDomain(JNIEnv *env, jclass cls);
47982689Smjacob
48045282SmjacobJNIEXPORT void JNICALL
48182841SmjacobJVM_SetProtectionDomain(JNIEnv *env, jclass cls, jobject protection_domain);
48282841Smjacob
48382841SmjacobJNIEXPORT jboolean JNICALL
48471079SmjacobJVM_IsArrayClass(JNIEnv *env, jclass cls);
48582841Smjacob
48682841SmjacobJNIEXPORT jboolean JNICALL
48782841SmjacobJVM_IsPrimitiveClass(JNIEnv *env, jclass cls);
48839235Sgibbs
48935388SmjacobJNIEXPORT jclass JNICALL
49039235SgibbsJVM_GetComponentType(JNIEnv *env, jclass cls);
49135388Smjacob
49239235SgibbsJNIEXPORT jint JNICALL
49339235SgibbsJVM_GetClassModifiers(JNIEnv *env, jclass cls);
49439235Sgibbs
49539235SgibbsJNIEXPORT jobjectArray JNICALL
49687635SmjacobJVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass);
49787635Smjacob
49887635SmjacobJNIEXPORT jclass JNICALL
49987635SmjacobJVM_GetDeclaringClass(JNIEnv *env, jclass ofClass);
50087635Smjacob
50187635Smjacob/* Generics support (JDK 1.5) */
50287635SmjacobJNIEXPORT jstring JNICALL
50387635SmjacobJVM_GetClassSignature(JNIEnv *env, jclass cls);
50439235Sgibbs
50539235Sgibbs/* Annotations support (JDK 1.5) */
50635388SmjacobJNIEXPORT jbyteArray JNICALL
50739235SgibbsJVM_GetClassAnnotations(JNIEnv *env, jclass cls);
50839235Sgibbs
50939235Sgibbs/* Annotations support (JDK 1.6) */
51039235Sgibbs
51139235Sgibbs// field is a handle to a java.lang.reflect.Field object
51239235SgibbsJNIEXPORT jbyteArray JNICALL
51345282SmjacobJVM_GetFieldAnnotations(JNIEnv *env, jobject field);
51454671Smjacob
51554671Smjacob// method is a handle to a java.lang.reflect.Method object
51654671SmjacobJNIEXPORT jbyteArray JNICALL
51757145SmjacobJVM_GetMethodAnnotations(JNIEnv *env, jobject method);
51835388Smjacob
51935388Smjacob// method is a handle to a java.lang.reflect.Method object
52048484SmjacobJNIEXPORT jbyteArray JNICALL
52177365SmjacobJVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method);
52288855Smjacob
52335388Smjacob// method is a handle to a java.lang.reflect.Method object
52444819SmjacobJNIEXPORT jbyteArray JNICALL
52554671SmjacobJVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method);
52644819Smjacob
52754671Smjacob
52857145Smjacob/*
52957145Smjacob * New (JDK 1.4) reflection implementation
53057145Smjacob */
53157145Smjacob
53257145SmjacobJNIEXPORT jobjectArray JNICALL
53357145SmjacobJVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly);
53457145Smjacob
53577365SmjacobJNIEXPORT jobjectArray JNICALL
53677365SmjacobJVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly);
53777365Smjacob
53888855SmjacobJNIEXPORT jobjectArray JNICALL
53988855SmjacobJVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly);
54088855Smjacob
54144819Smjacob/* Differs from JVM_GetClassModifiers in treatment of inner classes.
54264087Smjacob   This returns the access flags for the class as specified in the
54364087Smjacob   class file rather than searching the InnerClasses attribute (if
54464087Smjacob   present) to find the source-level access flags. Only the values of
54582689Smjacob   the low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be
54682689Smjacob   valid. */
54782689SmjacobJNIEXPORT jint JNICALL
54882689SmjacobJVM_GetClassAccessFlags(JNIEnv *env, jclass cls);
54957145Smjacob
55035388Smjacob/*
55164087Smjacob * Constant pool access; currently used to implement reflective access to annotations (JDK 1.5)
55235388Smjacob */
55335388Smjacob
55435388SmjacobJNIEXPORT jobject JNICALL
55539235SgibbsJVM_GetClassConstantPool(JNIEnv *env, jclass cls);
55639235Sgibbs
55735388SmjacobJNIEXPORT jint JNICALL JVM_ConstantPoolGetSize
55874229Smjacob(JNIEnv *env, jobject unused, jobject jcpool);
55935388Smjacob
56035388SmjacobJNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAt
56135388Smjacob(JNIEnv *env, jobject unused, jobject jcpool, jint index);
56235388Smjacob
56374229SmjacobJNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAtIfLoaded
56435388Smjacob(JNIEnv *env, jobject unused, jobject jcpool, jint index);
56535388Smjacob
56639235SgibbsJNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAt
56739235Sgibbs(JNIEnv *env, jobject unused, jobject jcpool, jint index);
56874229Smjacob
56939235SgibbsJNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAtIfLoaded
57039235Sgibbs(JNIEnv *env, jobject unused, jobject jcpool, jint index);
57182689Smjacob
57282689SmjacobJNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAt
57382689Smjacob(JNIEnv *env, jobject unused, jobject jcpool, jint index);
57482689Smjacob
57582689SmjacobJNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAtIfLoaded
57635388Smjacob(JNIEnv *env, jobject unused, jobject jcpool, jint index);
57782689Smjacob
57835388SmjacobJNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetMemberRefInfoAt
57982689Smjacob(JNIEnv *env, jobject unused, jobject jcpool, jint index);
58035388Smjacob
58164087SmjacobJNIEXPORT jint JNICALL JVM_ConstantPoolGetIntAt
58235388Smjacob(JNIEnv *env, jobject unused, jobject jcpool, jint index);
58374229Smjacob
58464087SmjacobJNIEXPORT jlong JNICALL JVM_ConstantPoolGetLongAt
58564087Smjacob(JNIEnv *env, jobject unused, jobject jcpool, jint index);
58664087Smjacob
58764087SmjacobJNIEXPORT jfloat JNICALL JVM_ConstantPoolGetFloatAt
58864087Smjacob(JNIEnv *env, jobject unused, jobject jcpool, jint index);
58935388Smjacob
59039235SgibbsJNIEXPORT jdouble JNICALL JVM_ConstantPoolGetDoubleAt
59164087Smjacob(JNIEnv *env, jobject unused, jobject jcpool, jint index);
59264087Smjacob
59374229SmjacobJNIEXPORT jstring JNICALL JVM_ConstantPoolGetStringAt
59464087Smjacob(JNIEnv *env, jobject unused, jobject jcpool, jint index);
59564087Smjacob
59643420SmjacobJNIEXPORT jstring JNICALL JVM_ConstantPoolGetUTF8At
59739235Sgibbs(JNIEnv *env, jobject unused, jobject jcpool, jint index);
59872355Smjacob
59972355Smjacob/*
60039235Sgibbs * java.security.*
60172355Smjacob */
60272355Smjacob
60372355SmjacobJNIEXPORT jobject JNICALL
60472355SmjacobJVM_DoPrivileged(JNIEnv *env, jclass cls,
60572355Smjacob                 jobject action, jobject context, jboolean wrapException);
60672355Smjacob
60772355SmjacobJNIEXPORT jobject JNICALL
60872355SmjacobJVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls);
60972355Smjacob
61072355SmjacobJNIEXPORT jobject JNICALL
61172355SmjacobJVM_GetStackAccessControlContext(JNIEnv *env, jclass cls);
61272355Smjacob
61372355Smjacob/*
61472355Smjacob * Signal support, used to implement the shutdown sequence.  Every VM must
61572355Smjacob * support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts
61672355Smjacob * (^C) and the latter for external termination (kill, system shutdown, etc.).
61772355Smjacob * Other platform-dependent signal values may also be supported.
61872355Smjacob */
61972355Smjacob
62072355SmjacobJNIEXPORT void * JNICALL
62172355SmjacobJVM_RegisterSignal(jint sig, void *handler);
62272355Smjacob
62372355SmjacobJNIEXPORT jboolean JNICALL
62472355SmjacobJVM_RaiseSignal(jint sig);
62572355Smjacob
62672355SmjacobJNIEXPORT jint JNICALL
62781794SmjacobJVM_FindSignal(const char *name);
62839235Sgibbs
62939235Sgibbs/*
63048484Smjacob * Retrieve the assertion directives for the specified class.
63148484Smjacob */
63248484SmjacobJNIEXPORT jboolean JNICALL
63372355SmjacobJVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls);
63455364Smjacob
63572355Smjacob/*
63672355Smjacob * Retrieve the assertion directives from the VM.
63755364Smjacob */
63872355SmjacobJNIEXPORT jobject JNICALL
63972355SmjacobJVM_AssertionStatusDirectives(JNIEnv *env, jclass unused);
64072938Smjacob
64155364Smjacob/*
64239235Sgibbs * sun.misc.AtomicLong
64374229Smjacob */
64439235SgibbsJNIEXPORT jboolean JNICALL
64543420SmjacobJVM_SupportsCX8(void);
64639235Sgibbs
64743420SmjacobJNIEXPORT jboolean JNICALL
64843420SmjacobJVM_CX8Field(JNIEnv *env, jobject obj, jfieldID fldID, jlong oldVal, jlong newVal);
64943420Smjacob
65072355Smjacob/*
65172355Smjacob * com.sun.dtrace.jsdt support
65272355Smjacob */
65372355Smjacob
65472355Smjacob#define JVM_TRACING_DTRACE_VERSION 1
65572355Smjacob
65672355Smjacob/*
65772355Smjacob * Structure to pass one probe description to JVM.
65872355Smjacob *
65972355Smjacob * The VM will overwrite the definition of the referenced method with
66072355Smjacob * code that will fire the probe.
66172355Smjacob */
66272355Smjacobtypedef struct {
66372355Smjacob    jmethodID method;
66472355Smjacob    jstring   function;
66572355Smjacob    jstring   name;
66672355Smjacob    void*     reserved[4];     // for future use
66772355Smjacob} JVM_DTraceProbe;
66872355Smjacob
66972355Smjacob/**
67072355Smjacob * Encapsulates the stability ratings for a DTrace provider field
67172355Smjacob */
67272355Smjacobtypedef struct {
67372355Smjacob    jint nameStability;
67472355Smjacob    jint dataStability;
67572355Smjacob    jint dependencyClass;
67672355Smjacob} JVM_DTraceInterfaceAttributes;
67772355Smjacob
67872355Smjacob/*
67972938Smjacob * Structure to pass one provider description to JVM
68072938Smjacob */
68172938Smjacobtypedef struct {
68287635Smjacob    jstring                       name;
68387635Smjacob    JVM_DTraceProbe*              probes;
68443420Smjacob    jint                          probe_count;
68543420Smjacob    JVM_DTraceInterfaceAttributes providerAttributes;
68643420Smjacob    JVM_DTraceInterfaceAttributes moduleAttributes;
68772355Smjacob    JVM_DTraceInterfaceAttributes functionAttributes;
68848484Smjacob    JVM_DTraceInterfaceAttributes nameAttributes;
68948484Smjacob    JVM_DTraceInterfaceAttributes argsAttributes;
69048484Smjacob    void*                         reserved[4]; // for future use
69177365Smjacob} JVM_DTraceProvider;
69277365Smjacob
69372355Smjacob/*
69472355Smjacob * Get the version number the JVM was built with
69572355Smjacob */
69655364SmjacobJNIEXPORT jint JNICALL
69755364SmjacobJVM_DTraceGetVersion(JNIEnv* env);
69872355Smjacob
69972938Smjacob/*
70079235Smjacob * Register new probe with given signature, return global handle
70179235Smjacob *
70243420Smjacob * The version passed in is the version that the library code was
70374229Smjacob * built with.
70443420Smjacob */
70572355SmjacobJNIEXPORT jlong JNICALL
70672355SmjacobJVM_DTraceActivate(JNIEnv* env, jint version, jstring module_name,
70772355Smjacob  jint providers_count, JVM_DTraceProvider* providers);
70872355Smjacob
70943420Smjacob/*
71064087Smjacob * Check JSDT probe
71139235Sgibbs */
71270490SmjacobJNIEXPORT jboolean JNICALL
71374229SmjacobJVM_DTraceIsProbeEnabled(JNIEnv* env, jmethodID method);
71470490Smjacob
71570490Smjacob/*
71674229Smjacob * Destroy custom DOF
71770490Smjacob */
71870490SmjacobJNIEXPORT void JNICALL
71964087SmjacobJVM_DTraceDispose(JNIEnv* env, jlong handle);
72064087Smjacob
72164087Smjacob/*
72264087Smjacob * Check to see if DTrace is supported by OS
72364087Smjacob */
72464087SmjacobJNIEXPORT jboolean JNICALL
72564087SmjacobJVM_DTraceIsSupported(JNIEnv* env);
72664087Smjacob
72779235Smjacob/*************************************************************************
72879235Smjacob PART 2: Support for the Verifier and Class File Format Checker
72964087Smjacob ************************************************************************/
73064087Smjacob/*
73164087Smjacob * Return the class name in UTF format. The result is valid
73239235Sgibbs * until JVM_ReleaseUTf is called.
73364087Smjacob *
73464087Smjacob * The caller must treat the string as a constant and not modify it
73564087Smjacob * in any way.
73664087Smjacob */
73764087SmjacobJNIEXPORT const char * JNICALL
73864087SmjacobJVM_GetClassNameUTF(JNIEnv *env, jclass cb);
73964087Smjacob
74064087Smjacob/*
74164087Smjacob * Returns the constant pool types in the buffer provided by "types."
74282689Smjacob */
74382689SmjacobJNIEXPORT void JNICALL
74482689SmjacobJVM_GetClassCPTypes(JNIEnv *env, jclass cb, unsigned char *types);
74582689Smjacob
74682689Smjacob/*
74764087Smjacob * Returns the number of Constant Pool entries.
74864087Smjacob */
74964087SmjacobJNIEXPORT jint JNICALL
75064087SmjacobJVM_GetClassCPEntriesCount(JNIEnv *env, jclass cb);
75164087Smjacob
75264087Smjacob/*
75364087Smjacob * Returns the number of *declared* fields or methods.
75469522Smjacob */
75564087SmjacobJNIEXPORT jint JNICALL
75664087SmjacobJVM_GetClassFieldsCount(JNIEnv *env, jclass cb);
75764087Smjacob
75864087SmjacobJNIEXPORT jint JNICALL
75964087SmjacobJVM_GetClassMethodsCount(JNIEnv *env, jclass cb);
76064087Smjacob
76164087Smjacob/*
76264087Smjacob * Returns the CP indexes of exceptions raised by a given method.
76364087Smjacob * Places the result in the given buffer.
76464087Smjacob *
76564087Smjacob * The method is identified by method_index.
76664087Smjacob */
76764087SmjacobJNIEXPORT void JNICALL
76864087SmjacobJVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cb, jint method_index,
76964087Smjacob                                unsigned short *exceptions);
77064087Smjacob/*
77164087Smjacob * Returns the number of exceptions raised by a given method.
77264087Smjacob * The method is identified by method_index.
77364087Smjacob */
77464087SmjacobJNIEXPORT jint JNICALL
77564087SmjacobJVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cb, jint method_index);
77664087Smjacob
77764087Smjacob/*
77864087Smjacob * Returns the byte code sequence of a given method.
77964087Smjacob * Places the result in the given buffer.
78090224Smjacob *
78190224Smjacob * The method is identified by method_index.
78272355Smjacob */
78364087SmjacobJNIEXPORT void JNICALL
78464087SmjacobJVM_GetMethodIxByteCode(JNIEnv *env, jclass cb, jint method_index,
78564087Smjacob                        unsigned char *code);
78664087Smjacob
78764087Smjacob/*
78864087Smjacob * Returns the length of the byte code sequence of a given method.
78964087Smjacob * The method is identified by method_index.
79064087Smjacob */
79164087SmjacobJNIEXPORT jint JNICALL
79264087SmjacobJVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cb, jint method_index);
79364087Smjacob
79464087Smjacob/*
79564087Smjacob * A structure used to a capture exception table entry in a Java method.
79664087Smjacob */
79764087Smjacobtypedef struct {
79864087Smjacob    jint start_pc;
79964087Smjacob    jint end_pc;
80064087Smjacob    jint handler_pc;
80164087Smjacob    jint catchType;
80264087Smjacob} JVM_ExceptionTableEntryType;
80364087Smjacob
80464087Smjacob/*
80564087Smjacob * Returns the exception table entry at entry_index of a given method.
80664087Smjacob * Places the result in the given buffer.
80764087Smjacob *
80864087Smjacob * The method is identified by method_index.
80964087Smjacob */
81064087SmjacobJNIEXPORT void JNICALL
81164087SmjacobJVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cb, jint method_index,
81264087Smjacob                                   jint entry_index,
81364087Smjacob                                   JVM_ExceptionTableEntryType *entry);
81464087Smjacob
81564087Smjacob/*
81664087Smjacob * Returns the length of the exception table of a given method.
81764087Smjacob * The method is identified by method_index.
81864087Smjacob */
81964087SmjacobJNIEXPORT jint JNICALL
82064087SmjacobJVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cb, int index);
82164087Smjacob
82264087Smjacob/*
82364087Smjacob * Returns the modifiers of a given field.
82464087Smjacob * The field is identified by field_index.
82564087Smjacob */
82664087SmjacobJNIEXPORT jint JNICALL
82764087SmjacobJVM_GetFieldIxModifiers(JNIEnv *env, jclass cb, int index);
82867047Smjacob
82967047Smjacob/*
83067047Smjacob * Returns the modifiers of a given method.
83167047Smjacob * The method is identified by method_index.
83267047Smjacob */
83364087SmjacobJNIEXPORT jint JNICALL
83467047SmjacobJVM_GetMethodIxModifiers(JNIEnv *env, jclass cb, int index);
83567047Smjacob
83664087Smjacob/*
83767047Smjacob * Returns the number of local variables of a given method.
83867047Smjacob * The method is identified by method_index.
83967047Smjacob */
84067047SmjacobJNIEXPORT jint JNICALL
84167047SmjacobJVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cb, int index);
84267047Smjacob
84367047Smjacob/*
84464087Smjacob * Returns the number of arguments (including this pointer) of a given method.
84564087Smjacob * The method is identified by method_index.
84687635Smjacob */
84787635SmjacobJNIEXPORT jint JNICALL
84887635SmjacobJVM_GetMethodIxArgsSize(JNIEnv *env, jclass cb, int index);
84987635Smjacob
85087635Smjacob/*
85187635Smjacob * Returns the maximum amount of stack (in words) used by a given method.
85287635Smjacob * The method is identified by method_index.
85387635Smjacob */
85487635SmjacobJNIEXPORT jint JNICALL
85587635SmjacobJVM_GetMethodIxMaxStack(JNIEnv *env, jclass cb, int index);
85664087Smjacob
85777365Smjacob/*
85835388Smjacob * Is a given method a constructor.
859 * The method is identified by method_index.
860 */
861JNIEXPORT jboolean JNICALL
862JVM_IsConstructorIx(JNIEnv *env, jclass cb, int index);
863
864/*
865 * Returns the name of a given method in UTF format.
866 * The result remains valid until JVM_ReleaseUTF is called.
867 *
868 * The caller must treat the string as a constant and not modify it
869 * in any way.
870 */
871JNIEXPORT const char * JNICALL
872JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cb, jint index);
873
874/*
875 * Returns the signature of a given method in UTF format.
876 * The result remains valid until JVM_ReleaseUTF is called.
877 *
878 * The caller must treat the string as a constant and not modify it
879 * in any way.
880 */
881JNIEXPORT const char * JNICALL
882JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cb, jint index);
883
884/*
885 * Returns the name of the field refered to at a given constant pool
886 * index.
887 *
888 * The result is in UTF format and remains valid until JVM_ReleaseUTF
889 * is called.
890 *
891 * The caller must treat the string as a constant and not modify it
892 * in any way.
893 */
894JNIEXPORT const char * JNICALL
895JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cb, jint index);
896
897/*
898 * Returns the name of the method refered to at a given constant pool
899 * index.
900 *
901 * The result is in UTF format and remains valid until JVM_ReleaseUTF
902 * is called.
903 *
904 * The caller must treat the string as a constant and not modify it
905 * in any way.
906 */
907JNIEXPORT const char * JNICALL
908JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cb, jint index);
909
910/*
911 * Returns the signature of the method refered to at a given constant pool
912 * index.
913 *
914 * The result is in UTF format and remains valid until JVM_ReleaseUTF
915 * is called.
916 *
917 * The caller must treat the string as a constant and not modify it
918 * in any way.
919 */
920JNIEXPORT const char * JNICALL
921JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cb, jint index);
922
923/*
924 * Returns the signature of the field refered to at a given constant pool
925 * index.
926 *
927 * The result is in UTF format and remains valid until JVM_ReleaseUTF
928 * is called.
929 *
930 * The caller must treat the string as a constant and not modify it
931 * in any way.
932 */
933JNIEXPORT const char * JNICALL
934JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cb, jint index);
935
936/*
937 * Returns the class name refered to at a given constant pool index.
938 *
939 * The result is in UTF format and remains valid until JVM_ReleaseUTF
940 * is called.
941 *
942 * The caller must treat the string as a constant and not modify it
943 * in any way.
944 */
945JNIEXPORT const char * JNICALL
946JVM_GetCPClassNameUTF(JNIEnv *env, jclass cb, jint index);
947
948/*
949 * Returns the class name refered to at a given constant pool index.
950 *
951 * The constant pool entry must refer to a CONSTANT_Fieldref.
952 *
953 * The result is in UTF format and remains valid until JVM_ReleaseUTF
954 * is called.
955 *
956 * The caller must treat the string as a constant and not modify it
957 * in any way.
958 */
959JNIEXPORT const char * JNICALL
960JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cb, jint index);
961
962/*
963 * Returns the class name refered to at a given constant pool index.
964 *
965 * The constant pool entry must refer to CONSTANT_Methodref or
966 * CONSTANT_InterfaceMethodref.
967 *
968 * The result is in UTF format and remains valid until JVM_ReleaseUTF
969 * is called.
970 *
971 * The caller must treat the string as a constant and not modify it
972 * in any way.
973 */
974JNIEXPORT const char * JNICALL
975JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cb, jint index);
976
977/*
978 * Returns the modifiers of a field in calledClass. The field is
979 * referred to in class cb at constant pool entry index.
980 *
981 * The caller must treat the string as a constant and not modify it
982 * in any way.
983 *
984 * Returns -1 if the field does not exist in calledClass.
985 */
986JNIEXPORT jint JNICALL
987JVM_GetCPFieldModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
988
989/*
990 * Returns the modifiers of a method in calledClass. The method is
991 * referred to in class cb at constant pool entry index.
992 *
993 * Returns -1 if the method does not exist in calledClass.
994 */
995JNIEXPORT jint JNICALL
996JVM_GetCPMethodModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass);
997
998/*
999 * Releases the UTF string obtained from the VM.
1000 */
1001JNIEXPORT void JNICALL
1002JVM_ReleaseUTF(const char *utf);
1003
1004/*
1005 * Compare if two classes are in the same package.
1006 */
1007JNIEXPORT jboolean JNICALL
1008JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2);
1009
1010/* Constants in class files */
1011
1012#define JVM_ACC_PUBLIC        0x0001  /* visible to everyone */
1013#define JVM_ACC_PRIVATE       0x0002  /* visible only to the defining class */
1014#define JVM_ACC_PROTECTED     0x0004  /* visible to subclasses */
1015#define JVM_ACC_STATIC        0x0008  /* instance variable is static */
1016#define JVM_ACC_FINAL         0x0010  /* no further subclassing, overriding */
1017#define JVM_ACC_SYNCHRONIZED  0x0020  /* wrap method call in monitor lock */
1018#define JVM_ACC_SUPER         0x0020  /* funky handling of invokespecial */
1019#define JVM_ACC_VOLATILE      0x0040  /* can not cache in registers */
1020#define JVM_ACC_BRIDGE        0x0040  /* bridge method generated by compiler */
1021#define JVM_ACC_TRANSIENT     0x0080  /* not persistent */
1022#define JVM_ACC_VARARGS       0x0080  /* method declared with variable number of args */
1023#define JVM_ACC_NATIVE        0x0100  /* implemented in C */
1024#define JVM_ACC_INTERFACE     0x0200  /* class is an interface */
1025#define JVM_ACC_ABSTRACT      0x0400  /* no definition provided */
1026#define JVM_ACC_STRICT        0x0800  /* strict floating point */
1027#define JVM_ACC_SYNTHETIC     0x1000  /* compiler-generated class, method or field */
1028#define JVM_ACC_ANNOTATION    0x2000  /* annotation type */
1029#define JVM_ACC_ENUM          0x4000  /* field is declared as element of enum */
1030
1031#define JVM_ACC_PUBLIC_BIT        0
1032#define JVM_ACC_PRIVATE_BIT       1
1033#define JVM_ACC_PROTECTED_BIT     2
1034#define JVM_ACC_STATIC_BIT        3
1035#define JVM_ACC_FINAL_BIT         4
1036#define JVM_ACC_SYNCHRONIZED_BIT  5
1037#define JVM_ACC_SUPER_BIT         5
1038#define JVM_ACC_VOLATILE_BIT      6
1039#define JVM_ACC_BRIDGE_BIT        6
1040#define JVM_ACC_TRANSIENT_BIT     7
1041#define JVM_ACC_VARARGS_BIT       7
1042#define JVM_ACC_NATIVE_BIT        8
1043#define JVM_ACC_INTERFACE_BIT     9
1044#define JVM_ACC_ABSTRACT_BIT      10
1045#define JVM_ACC_STRICT_BIT        11
1046#define JVM_ACC_SYNTHETIC_BIT     12
1047#define JVM_ACC_ANNOTATION_BIT    13
1048#define JVM_ACC_ENUM_BIT          14
1049
1050// NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/utilities/ConstantTag.java
1051enum {
1052    JVM_CONSTANT_Utf8 = 1,
1053    JVM_CONSTANT_Unicode,               /* unused */
1054    JVM_CONSTANT_Integer,
1055    JVM_CONSTANT_Float,
1056    JVM_CONSTANT_Long,
1057    JVM_CONSTANT_Double,
1058    JVM_CONSTANT_Class,
1059    JVM_CONSTANT_String,
1060    JVM_CONSTANT_Fieldref,
1061    JVM_CONSTANT_Methodref,
1062    JVM_CONSTANT_InterfaceMethodref,
1063    JVM_CONSTANT_NameAndType,
1064    JVM_CONSTANT_MethodHandle           = 15,  // JSR 292
1065    JVM_CONSTANT_MethodType             = 16,  // JSR 292
1066    JVM_CONSTANT_InvokeDynamicTrans     = 17,  // JSR 292, only occurs in old class files
1067    JVM_CONSTANT_InvokeDynamic          = 18   // JSR 292
1068};
1069
1070/* JVM_CONSTANT_MethodHandle subtypes */
1071enum {
1072    JVM_REF_getField                = 1,
1073    JVM_REF_getStatic               = 2,
1074    JVM_REF_putField                = 3,
1075    JVM_REF_putStatic               = 4,
1076    JVM_REF_invokeVirtual           = 5,
1077    JVM_REF_invokeStatic            = 6,
1078    JVM_REF_invokeSpecial           = 7,
1079    JVM_REF_newInvokeSpecial        = 8,
1080    JVM_REF_invokeInterface         = 9
1081};
1082
1083/* Used in the newarray instruction. */
1084
1085#define JVM_T_BOOLEAN 4
1086#define JVM_T_CHAR    5
1087#define JVM_T_FLOAT   6
1088#define JVM_T_DOUBLE  7
1089#define JVM_T_BYTE    8
1090#define JVM_T_SHORT   9
1091#define JVM_T_INT    10
1092#define JVM_T_LONG   11
1093
1094/* JVM method signatures */
1095
1096#define JVM_SIGNATURE_ARRAY             '['
1097#define JVM_SIGNATURE_BYTE              'B'
1098#define JVM_SIGNATURE_CHAR              'C'
1099#define JVM_SIGNATURE_CLASS             'L'
1100#define JVM_SIGNATURE_ENDCLASS          ';'
1101#define JVM_SIGNATURE_ENUM              'E'
1102#define JVM_SIGNATURE_FLOAT             'F'
1103#define JVM_SIGNATURE_DOUBLE            'D'
1104#define JVM_SIGNATURE_FUNC              '('
1105#define JVM_SIGNATURE_ENDFUNC           ')'
1106#define JVM_SIGNATURE_INT               'I'
1107#define JVM_SIGNATURE_LONG              'J'
1108#define JVM_SIGNATURE_SHORT             'S'
1109#define JVM_SIGNATURE_VOID              'V'
1110#define JVM_SIGNATURE_BOOLEAN           'Z'
1111
1112/*
1113 * A function defined by the byte-code verifier and called by the VM.
1114 * This is not a function implemented in the VM.
1115 *
1116 * Returns JNI_FALSE if verification fails. A detailed error message
1117 * will be places in msg_buf, whose length is specified by buf_len.
1118 */
1119typedef jboolean (*verifier_fn_t)(JNIEnv *env,
1120                                  jclass cb,
1121                                  char * msg_buf,
1122                                  jint buf_len);
1123
1124
1125/*
1126 * Support for a VM-independent class format checker.
1127 */
1128typedef struct {
1129    unsigned long code;    /* byte code */
1130    unsigned long excs;    /* exceptions */
1131    unsigned long etab;    /* catch table */
1132    unsigned long lnum;    /* line number */
1133    unsigned long lvar;    /* local vars */
1134} method_size_info;
1135
1136typedef struct {
1137    unsigned int constants;    /* constant pool */
1138    unsigned int fields;
1139    unsigned int methods;
1140    unsigned int interfaces;
1141    unsigned int fields2;      /* number of static 2-word fields */
1142    unsigned int innerclasses; /* # of records in InnerClasses attr */
1143
1144    method_size_info clinit;   /* memory used in clinit */
1145    method_size_info main;     /* used everywhere else */
1146} class_size_info;
1147
1148/*
1149 * Functions defined in libjava.so to perform string conversions.
1150 *
1151 */
1152
1153typedef jstring (*to_java_string_fn_t)(JNIEnv *env, char *str);
1154
1155typedef char *(*to_c_string_fn_t)(JNIEnv *env, jstring s, jboolean *b);
1156
1157/* This is the function defined in libjava.so that performs class
1158 * format checks. This functions fills in size information about
1159 * the class file and returns:
1160 *
1161 *   0: good
1162 *  -1: out of memory
1163 *  -2: bad format
1164 *  -3: unsupported version
1165 *  -4: bad class name
1166 */
1167
1168typedef jint (*check_format_fn_t)(char *class_name,
1169                                  unsigned char *data,
1170                                  unsigned int data_size,
1171                                  class_size_info *class_size,
1172                                  char *message_buffer,
1173                                  jint buffer_length,
1174                                  jboolean measure_only,
1175                                  jboolean check_relaxed);
1176
1177#define JVM_RECOGNIZED_CLASS_MODIFIERS (JVM_ACC_PUBLIC | \
1178                                        JVM_ACC_FINAL | \
1179                                        JVM_ACC_SUPER | \
1180                                        JVM_ACC_INTERFACE | \
1181                                        JVM_ACC_ABSTRACT | \
1182                                        JVM_ACC_ANNOTATION | \
1183                                        JVM_ACC_ENUM | \
1184                                        JVM_ACC_SYNTHETIC)
1185
1186#define JVM_RECOGNIZED_FIELD_MODIFIERS (JVM_ACC_PUBLIC | \
1187                                        JVM_ACC_PRIVATE | \
1188                                        JVM_ACC_PROTECTED | \
1189                                        JVM_ACC_STATIC | \
1190                                        JVM_ACC_FINAL | \
1191                                        JVM_ACC_VOLATILE | \
1192                                        JVM_ACC_TRANSIENT | \
1193                                        JVM_ACC_ENUM | \
1194                                        JVM_ACC_SYNTHETIC)
1195
1196#define JVM_RECOGNIZED_METHOD_MODIFIERS (JVM_ACC_PUBLIC | \
1197                                         JVM_ACC_PRIVATE | \
1198                                         JVM_ACC_PROTECTED | \
1199                                         JVM_ACC_STATIC | \
1200                                         JVM_ACC_FINAL | \
1201                                         JVM_ACC_SYNCHRONIZED | \
1202                                         JVM_ACC_BRIDGE | \
1203                                         JVM_ACC_VARARGS | \
1204                                         JVM_ACC_NATIVE | \
1205                                         JVM_ACC_ABSTRACT | \
1206                                         JVM_ACC_STRICT | \
1207                                         JVM_ACC_SYNTHETIC)
1208
1209/*
1210 * This is the function defined in libjava.so to perform path
1211 * canonicalization. VM call this function before opening jar files
1212 * to load system classes.
1213 *
1214 */
1215
1216typedef int (*canonicalize_fn_t)(JNIEnv *env, char *orig, char *out, int len);
1217
1218/*************************************************************************
1219 PART 3: I/O and Network Support
1220 ************************************************************************/
1221
1222/* Note that the JVM IO functions are expected to return JVM_IO_ERR
1223 * when there is any kind of error. The caller can then use the
1224 * platform specific support (e.g., errno) to get the detailed
1225 * error info.  The JVM_GetLastErrorString procedure may also be used
1226 * to obtain a descriptive error string.
1227 */
1228#define JVM_IO_ERR  (-1)
1229
1230/* For interruptible IO. Returning JVM_IO_INTR indicates that an IO
1231 * operation has been disrupted by Thread.interrupt. There are a
1232 * number of technical difficulties related to interruptible IO that
1233 * need to be solved. For example, most existing programs do not handle
1234 * InterruptedIOExceptions specially, they simply treat those as any
1235 * IOExceptions, which typically indicate fatal errors.
1236 *
1237 * There are also two modes of operation for interruptible IO. In the
1238 * resumption mode, an interrupted IO operation is guaranteed not to
1239 * have any side-effects, and can be restarted. In the termination mode,
1240 * an interrupted IO operation corrupts the underlying IO stream, so
1241 * that the only reasonable operation on an interrupted stream is to
1242 * close that stream. The resumption mode seems to be impossible to
1243 * implement on Win32 and Solaris. Implementing the termination mode is
1244 * easier, but it's not clear that's the right semantics.
1245 *
1246 * Interruptible IO is not supported on Win32.It can be enabled/disabled
1247 * using a compile-time flag on Solaris. Third-party JVM ports do not
1248 * need to implement interruptible IO.
1249 */
1250#define JVM_IO_INTR (-2)
1251
1252/* Write a string into the given buffer, in the platform's local encoding,
1253 * that describes the most recent system-level error to occur in this thread.
1254 * Return the length of the string or zero if no error occurred.
1255 */
1256JNIEXPORT jint JNICALL
1257JVM_GetLastErrorString(char *buf, int len);
1258
1259/*
1260 * Convert a pathname into native format.  This function does syntactic
1261 * cleanup, such as removing redundant separator characters.  It modifies
1262 * the given pathname string in place.
1263 */
1264JNIEXPORT char * JNICALL
1265JVM_NativePath(char *);
1266
1267/*
1268 * JVM I/O error codes
1269 */
1270#define JVM_EEXIST       -100
1271
1272/*
1273 * Open a file descriptor. This function returns a negative error code
1274 * on error, and a non-negative integer that is the file descriptor on
1275 * success.
1276 */
1277JNIEXPORT jint JNICALL
1278JVM_Open(const char *fname, jint flags, jint mode);
1279
1280/*
1281 * Close a file descriptor. This function returns -1 on error, and 0
1282 * on success.
1283 *
1284 * fd        the file descriptor to close.
1285 */
1286JNIEXPORT jint JNICALL
1287JVM_Close(jint fd);
1288
1289/*
1290 * Read data from a file decriptor into a char array.
1291 *
1292 * fd        the file descriptor to read from.
1293 * buf       the buffer where to put the read data.
1294 * nbytes    the number of bytes to read.
1295 *
1296 * This function returns -1 on error, and 0 on success.
1297 */
1298JNIEXPORT jint JNICALL
1299JVM_Read(jint fd, char *buf, jint nbytes);
1300
1301/*
1302 * Write data from a char array to a file decriptor.
1303 *
1304 * fd        the file descriptor to read from.
1305 * buf       the buffer from which to fetch the data.
1306 * nbytes    the number of bytes to write.
1307 *
1308 * This function returns -1 on error, and 0 on success.
1309 */
1310JNIEXPORT jint JNICALL
1311JVM_Write(jint fd, char *buf, jint nbytes);
1312
1313/*
1314 * Returns the number of bytes available for reading from a given file
1315 * descriptor
1316 */
1317JNIEXPORT jint JNICALL
1318JVM_Available(jint fd, jlong *pbytes);
1319
1320/*
1321 * Move the file descriptor pointer from whence by offset.
1322 *
1323 * fd        the file descriptor to move.
1324 * offset    the number of bytes to move it by.
1325 * whence    the start from where to move it.
1326 *
1327 * This function returns the resulting pointer location.
1328 */
1329JNIEXPORT jlong JNICALL
1330JVM_Lseek(jint fd, jlong offset, jint whence);
1331
1332/*
1333 * Set the length of the file associated with the given descriptor to the given
1334 * length.  If the new length is longer than the current length then the file
1335 * is extended; the contents of the extended portion are not defined.  The
1336 * value of the file pointer is undefined after this procedure returns.
1337 */
1338JNIEXPORT jint JNICALL
1339JVM_SetLength(jint fd, jlong length);
1340
1341/*
1342 * Synchronize the file descriptor's in memory state with that of the
1343 * physical device.  Return of -1 is an error, 0 is OK.
1344 */
1345JNIEXPORT jint JNICALL
1346JVM_Sync(jint fd);
1347
1348/*
1349 * Networking library support
1350 */
1351
1352JNIEXPORT jint JNICALL
1353JVM_InitializeSocketLibrary(void);
1354
1355struct sockaddr;
1356
1357JNIEXPORT jint JNICALL
1358JVM_Socket(jint domain, jint type, jint protocol);
1359
1360JNIEXPORT jint JNICALL
1361JVM_SocketClose(jint fd);
1362
1363JNIEXPORT jint JNICALL
1364JVM_SocketShutdown(jint fd, jint howto);
1365
1366JNIEXPORT jint JNICALL
1367JVM_Recv(jint fd, char *buf, jint nBytes, jint flags);
1368
1369JNIEXPORT jint JNICALL
1370JVM_Send(jint fd, char *buf, jint nBytes, jint flags);
1371
1372JNIEXPORT jint JNICALL
1373JVM_Timeout(int fd, long timeout);
1374
1375JNIEXPORT jint JNICALL
1376JVM_Listen(jint fd, jint count);
1377
1378JNIEXPORT jint JNICALL
1379JVM_Connect(jint fd, struct sockaddr *him, jint len);
1380
1381JNIEXPORT jint JNICALL
1382JVM_Bind(jint fd, struct sockaddr *him, jint len);
1383
1384JNIEXPORT jint JNICALL
1385JVM_Accept(jint fd, struct sockaddr *him, jint *len);
1386
1387JNIEXPORT jint JNICALL
1388JVM_RecvFrom(jint fd, char *buf, int nBytes,
1389                  int flags, struct sockaddr *from, int *fromlen);
1390
1391JNIEXPORT jint JNICALL
1392JVM_SendTo(jint fd, char *buf, int len,
1393                int flags, struct sockaddr *to, int tolen);
1394
1395JNIEXPORT jint JNICALL
1396JVM_SocketAvailable(jint fd, jint *result);
1397
1398
1399JNIEXPORT jint JNICALL
1400JVM_GetSockName(jint fd, struct sockaddr *him, int *len);
1401
1402JNIEXPORT jint JNICALL
1403JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen);
1404
1405JNIEXPORT jint JNICALL
1406JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen);
1407
1408/*
1409 * These routines are only reentrant on Windows
1410 */
1411
1412#ifdef _WINDOWS
1413
1414JNIEXPORT struct protoent * JNICALL
1415JVM_GetProtoByName(char* name);
1416
1417JNIEXPORT struct hostent* JNICALL
1418JVM_GetHostByAddr(const char* name, int len, int type);
1419
1420JNIEXPORT struct hostent* JNICALL
1421JVM_GetHostByName(char* name);
1422
1423#endif /* _WINDOWS */
1424
1425JNIEXPORT int JNICALL
1426JVM_GetHostName(char* name, int namelen);
1427
1428/*
1429 * The standard printing functions supported by the Java VM. (Should they
1430 * be renamed to JVM_* in the future?
1431 */
1432
1433/*
1434 * BE CAREFUL! The following functions do not implement the
1435 * full feature set of standard C printf formats.
1436 */
1437int
1438jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
1439
1440int
1441jio_snprintf(char *str, size_t count, const char *fmt, ...);
1442
1443int
1444jio_fprintf(FILE *, const char *fmt, ...);
1445
1446int
1447jio_vfprintf(FILE *, const char *fmt, va_list args);
1448
1449
1450JNIEXPORT void * JNICALL
1451JVM_RawMonitorCreate(void);
1452
1453JNIEXPORT void JNICALL
1454JVM_RawMonitorDestroy(void *mon);
1455
1456JNIEXPORT jint JNICALL
1457JVM_RawMonitorEnter(void *mon);
1458
1459JNIEXPORT void JNICALL
1460JVM_RawMonitorExit(void *mon);
1461
1462
1463#ifdef SUPPORT_OLD_REFLECTION
1464
1465/*
1466 * Support for old native code-based (pre-JDK 1.4) reflection implementation.
1467 * Disabled by default in the product build.
1468 *
1469 * See reflection.hpp for information on SUPPORT_OLD_REFLECTION
1470 */
1471
1472/*
1473 * reflecting fields and methods.
1474 * which: 0 --- MEMBER_PUBLIC
1475 *        1 --- MEMBER_DECLARED
1476 * NOTE: absent in product build by default
1477 */
1478
1479JNIEXPORT jobjectArray JNICALL
1480JVM_GetClassFields(JNIEnv *env, jclass cls, jint which);
1481
1482JNIEXPORT jobjectArray JNICALL
1483JVM_GetClassMethods(JNIEnv *env, jclass cls, jint which);
1484
1485JNIEXPORT jobjectArray JNICALL
1486JVM_GetClassConstructors(JNIEnv *env, jclass cls, jint which);
1487
1488JNIEXPORT jobject JNICALL
1489JVM_GetClassField(JNIEnv *env, jclass cls, jstring name, jint which);
1490
1491JNIEXPORT jobject JNICALL
1492JVM_GetClassMethod(JNIEnv *env, jclass cls, jstring name, jobjectArray types,
1493                   jint which);
1494JNIEXPORT jobject JNICALL
1495JVM_GetClassConstructor(JNIEnv *env, jclass cls, jobjectArray types,
1496                        jint which);
1497
1498/*
1499 * Implements Class.newInstance
1500 */
1501JNIEXPORT jobject JNICALL
1502JVM_NewInstance(JNIEnv *env, jclass cls);
1503
1504/*
1505 * java.lang.reflect.Field
1506 */
1507JNIEXPORT jobject JNICALL
1508JVM_GetField(JNIEnv *env, jobject field, jobject obj);
1509
1510JNIEXPORT jvalue JNICALL
1511JVM_GetPrimitiveField(JNIEnv *env, jobject field, jobject obj,
1512                      unsigned char wCode);
1513
1514JNIEXPORT void JNICALL
1515JVM_SetField(JNIEnv *env, jobject field, jobject obj, jobject val);
1516
1517JNIEXPORT void JNICALL
1518JVM_SetPrimitiveField(JNIEnv *env, jobject field, jobject obj, jvalue v,
1519                      unsigned char vCode);
1520
1521/*
1522 * java.lang.reflect.Method
1523 */
1524JNIEXPORT jobject JNICALL
1525JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0);
1526
1527/*
1528 * java.lang.reflect.Constructor
1529 */
1530JNIEXPORT jobject JNICALL
1531JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0);
1532
1533#endif /* SUPPORT_OLD_REFLECTION */
1534
1535/*
1536 * java.lang.management support
1537 */
1538JNIEXPORT void* JNICALL
1539JVM_GetManagement(jint version);
1540
1541/*
1542 * com.sun.tools.attach.VirtualMachine support
1543 *
1544 * Initialize the agent properties with the properties maintained in the VM.
1545 */
1546JNIEXPORT jobject JNICALL
1547JVM_InitAgentProperties(JNIEnv *env, jobject agent_props);
1548
1549/* Generics reflection support.
1550 *
1551 * Returns information about the given class's EnclosingMethod
1552 * attribute, if present, or null if the class had no enclosing
1553 * method.
1554 *
1555 * If non-null, the returned array contains three elements. Element 0
1556 * is the java.lang.Class of which the enclosing method is a member,
1557 * and elements 1 and 2 are the java.lang.Strings for the enclosing
1558 * method's name and descriptor, respectively.
1559 */
1560JNIEXPORT jobjectArray JNICALL
1561JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass);
1562
1563/*
1564 * Java thread state support
1565 */
1566enum {
1567    JAVA_THREAD_STATE_NEW           = 0,
1568    JAVA_THREAD_STATE_RUNNABLE      = 1,
1569    JAVA_THREAD_STATE_BLOCKED       = 2,
1570    JAVA_THREAD_STATE_WAITING       = 3,
1571    JAVA_THREAD_STATE_TIMED_WAITING = 4,
1572    JAVA_THREAD_STATE_TERMINATED    = 5,
1573    JAVA_THREAD_STATE_COUNT         = 6
1574};
1575
1576/*
1577 * Returns an array of the threadStatus values representing the
1578 * given Java thread state.  Returns NULL if the VM version is
1579 * incompatible with the JDK or doesn't support the given
1580 * Java thread state.
1581 */
1582JNIEXPORT jintArray JNICALL
1583JVM_GetThreadStateValues(JNIEnv* env, jint javaThreadState);
1584
1585/*
1586 * Returns an array of the substate names representing the
1587 * given Java thread state.  Returns NULL if the VM version is
1588 * incompatible with the JDK or the VM doesn't support
1589 * the given Java thread state.
1590 * values must be the jintArray returned from JVM_GetThreadStateValues
1591 * and javaThreadState.
1592 */
1593JNIEXPORT jobjectArray JNICALL
1594JVM_GetThreadStateNames(JNIEnv* env, jint javaThreadState, jintArray values);
1595
1596/* =========================================================================
1597 * The following defines a private JVM interface that the JDK can query
1598 * for the JVM version and capabilities.  sun.misc.Version defines
1599 * the methods for getting the VM version and its capabilities.
1600 *
1601 * When a new bit is added, the following should be updated to provide
1602 * access to the new capability:
1603 *    HS:   JVM_GetVersionInfo and Abstract_VM_Version class
1604 *    SDK:  Version class
1605 *
1606 * Similary, a private JDK interface JDK_GetVersionInfo0 is defined for
1607 * JVM to query for the JDK version and capabilities.
1608 *
1609 * When a new bit is added, the following should be updated to provide
1610 * access to the new capability:
1611 *    HS:   JDK_Version class
1612 *    SDK:  JDK_GetVersionInfo0
1613 *
1614 * ==========================================================================
1615 */
1616typedef struct {
1617    /* HotSpot Express VM version string:
1618     * <major>.<minor>-bxx[-<identifier>][-<debug_flavor>]
1619     */
1620    unsigned int jvm_version; /* Consists of major.minor.0.build */
1621    unsigned int update_version : 8;         /* 0 in HotSpot Express VM */
1622    unsigned int special_update_version : 8; /* 0 in HotSpot Express VM */
1623    unsigned int reserved1 : 16;
1624    unsigned int reserved2;
1625
1626    /* The following bits represents JVM supports that JDK has dependency on.
1627     * JDK can use these bits to determine which JVM version
1628     * and support it has to maintain runtime compatibility.
1629     *
1630     * When a new bit is added in a minor or update release, make sure
1631     * the new bit is also added in the main/baseline.
1632     */
1633    unsigned int is_attachable : 1;
1634    unsigned int is_kernel_jvm : 1;
1635    unsigned int : 30;
1636    unsigned int : 32;
1637    unsigned int : 32;
1638} jvm_version_info;
1639
1640#define JVM_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24)
1641#define JVM_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16)
1642// Micro version is 0 in HotSpot Express VM (set in jvm.cpp).
1643#define JVM_VERSION_MICRO(version) ((version & 0x0000FF00) >> 8)
1644/* Build number is available in all HotSpot Express VM builds.
1645 * It is defined in make/hotspot_version file.
1646 */
1647#define JVM_VERSION_BUILD(version) ((version & 0x000000FF))
1648
1649JNIEXPORT void JNICALL
1650JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size);
1651
1652typedef struct {
1653    // Naming convention of RE build version string: n.n.n[_uu[c]][-<identifier>]-bxx
1654    unsigned int jdk_version;   /* Consists of major, minor, micro (n.n.n) */
1655                                /* and build number (xx) */
1656    unsigned int update_version : 8;         /* Update release version (uu) */
1657    unsigned int special_update_version : 8; /* Special update release version (c)*/
1658    unsigned int reserved1 : 16;
1659    unsigned int reserved2;
1660
1661    /* The following bits represents new JDK supports that VM has dependency on.
1662     * VM implementation can use these bits to determine which JDK version
1663     * and support it has to maintain runtime compatibility.
1664     *
1665     * When a new bit is added in a minor or update release, make sure
1666     * the new bit is also added in the main/baseline.
1667     */
1668    unsigned int thread_park_blocker : 1;
1669    unsigned int : 31;
1670    unsigned int : 32;
1671    unsigned int : 32;
1672} jdk_version_info;
1673
1674#define JDK_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24)
1675#define JDK_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16)
1676#define JDK_VERSION_MICRO(version) ((version & 0x0000FF00) >> 8)
1677
1678/* Build number is available only for RE build (i.e. JDK_BUILD_NUMBER is set to bNN)
1679 * It will be zero for internal builds.
1680 */
1681#define JDK_VERSION_BUILD(version) ((version & 0x000000FF))
1682
1683/*
1684 * This is the function JDK_GetVersionInfo0 defined in libjava.so
1685 * that is dynamically looked up by JVM.
1686 */
1687typedef void (*jdk_version_info_fn_t)(jdk_version_info* info, size_t info_size);
1688
1689/*
1690 * This structure is used by the launcher to get the default thread
1691 * stack size from the VM using JNI_GetDefaultJavaVMInitArgs() with a
1692 * version of 1.1.  As it is not supported otherwise, it has been removed
1693 * from jni.h
1694 */
1695typedef struct JDK1_1InitArgs {
1696    jint version;
1697
1698    char **properties;
1699    jint checkSource;
1700    jint nativeStackSize;
1701    jint javaStackSize;
1702    jint minHeapSize;
1703    jint maxHeapSize;
1704    jint verifyMode;
1705    char *classpath;
1706
1707    jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args);
1708    void (JNICALL *exit)(jint code);
1709    void (JNICALL *abort)(void);
1710
1711    jint enableClassGC;
1712    jint enableVerboseGC;
1713    jint disableAsyncGC;
1714    jint verbose;
1715    jboolean debugging;
1716    jint debugPort;
1717} JDK1_1InitArgs;
1718
1719#ifdef __cplusplus
1720} /* extern "C" */
1721#endif /* __cplusplus */
1722
1723#endif /* !_JAVASOFT_JVM_H_ */
1724
1725#endif // SHARE_VM_PRIMS_JVM_H
1726