natNativeThread.cc: New file.
* gnu/gcj/jni/natNativeThread.cc: New file. * gnu/gcj/jni/NativeThread.java: New file. * java/lang/Thread.java (data): Now a RawData. * include/jvm.h (_Jv_GetCurrentJNIEnv, _Jv_SetCurrentJNIEnv): Declare. * Makefile.in: Rebuilt. * Makefile.am (java/lang/Thread.h): New target. (ordinary_java_source_files): Added NativeThread.java. (nat_source_files): Added natNativeThread.cc. * java/lang/natThread.cc: Include <jni.h> (struct natThread): Added `jni_env' field. (_Jv_GetCurrentJNIEnv): New function. (_Jv_SetCurrentJNIEnv): Likewise. (initialize_native): Initialize jni_env. Include RawData.h. * jni.cc (ThreadGroupClass): New define. (_Jv_JNI_InvokeFunctions): New structure. (JNI_GetCreatedJavaVMs): New function. (the_vm): New global. (JNI_GetDefaultJavaVMInitArgs): New function. Include NativeThread.h. (NativeThreadClass): New define. (_Jv_JNI_EnsureLocalCapacity): Return JNI_ERR, not -1. (_Jv_JNI_DestroyJavaVM): New function. (_Jv_JNI_AttachCurrentThread): New function. (_Jv_JNI_DetachCurrentThread): New function. (_Jv_JNI_GetEnv): New function. (JNI_CreateJavaVM): New function. (_Jv_JNI_GetJavaVM): New function. (_Jv_JNIFunctions): Added entry for GetJavaVM. * include/jni.h (JavaVMAttachArgs): New structure. (JNI_EDETACHED): New define. (JNI_EVERSION): Likewise. (JavaVM): Define properly. (struct JNIInvokeInterface): New structure. (class _Jv_JavaVM): New class. (JNI_OnLoad, JNI_OnUnload): Declare. (JNI_GetDefaultJavaVMInitArgs, JNI_CreateJavaVM, JNI_GetCreatedJavaVMs): Declare. (JavaVMInitArgs): New typedef. (JavaVMOption): Likewise. (JNI_ERR): New define. (JNI_OK): Likewise. From-SVN: r31901
This commit is contained in:
parent
ef86eabb6c
commit
aaf0766e9f
10 changed files with 560 additions and 30 deletions
|
@ -23,6 +23,7 @@ details. */
|
|||
#include <gcj/javaprims.h>
|
||||
|
||||
typedef struct _Jv_JNIEnv JNIEnv;
|
||||
typedef struct _Jv_JavaVM JavaVM;
|
||||
|
||||
#define JNI_TRUE true
|
||||
#define JNI_FALSE false
|
||||
|
@ -59,6 +60,7 @@ typedef void *jfieldID;
|
|||
typedef void *jmethodID;
|
||||
|
||||
typedef const struct JNINativeInterface *JNIEnv;
|
||||
typedef const struct JNIInvokeInterface *JavaVM;
|
||||
|
||||
#define JNI_TRUE 1
|
||||
#define JNI_TRUE 0
|
||||
|
@ -76,6 +78,32 @@ typedef jobject jweak;
|
|||
#define JNI_COMMIT 1
|
||||
#define JNI_ABORT 2
|
||||
|
||||
/* Error codes */
|
||||
#define JNI_OK 0
|
||||
#define JNI_ERR -1
|
||||
#define JNI_EDETACHED -2
|
||||
#define JNI_EVERSION -3
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* These functions might be defined in libraries which we load; the
|
||||
JNI implementation calls them at the appropriate times. */
|
||||
extern jint JNI_OnLoad (JavaVM *, void *);
|
||||
extern void JNI_OnUnload (JavaVM *, void *);
|
||||
|
||||
/* These functions are called by user code to start using the
|
||||
invocation API. */
|
||||
extern jint JNI_GetDefaultJavaVMInitArgs (void *);
|
||||
extern jint JNI_CreateJavaVM (JavaVM **, void **, void *);
|
||||
extern jint JNI_GetCreatedJavaVMs(JavaVM **, jsize, jsize *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef union jvalue
|
||||
{
|
||||
jboolean z;
|
||||
|
@ -99,9 +127,6 @@ typedef struct
|
|||
void *fnPtr; /* Sigh. */
|
||||
} JNINativeMethod;
|
||||
|
||||
/* FIXME: this is just a placeholder. */
|
||||
typedef int JavaVM;
|
||||
|
||||
struct JNINativeInterface
|
||||
{
|
||||
_Jv_func reserved0;
|
||||
|
@ -1402,4 +1427,74 @@ public:
|
|||
};
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* Invocation API.
|
||||
*/
|
||||
|
||||
struct JNIInvokeInterface
|
||||
{
|
||||
_Jv_func reserved0;
|
||||
_Jv_func reserved1;
|
||||
_Jv_func reserved2;
|
||||
|
||||
jint (*DestroyJavaVM) (JavaVM *);
|
||||
jint (*AttachCurrentThread) (JavaVM *, void **, void *);
|
||||
jint (*DetachCurrentThread) (JavaVM *);
|
||||
jint (*GetEnv) (JavaVM *, void **, jint);
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
class _Jv_JavaVM
|
||||
{
|
||||
public:
|
||||
const struct JNIInvokeInterface *functions;
|
||||
|
||||
private:
|
||||
/* FIXME: other fields. */
|
||||
|
||||
public:
|
||||
jint DestroyJavaVM ()
|
||||
{ return functions->DestroyJavaVM (this); }
|
||||
|
||||
jint AttachCurrentThread (void **penv, void *args)
|
||||
{ return functions->AttachCurrentThread (this, penv, args); }
|
||||
|
||||
jint DetachCurrentThread ()
|
||||
{ return functions->DetachCurrentThread (this); }
|
||||
|
||||
jint GetEnv (void **penv, jint version)
|
||||
{ return functions->GetEnv (this, penv, version); }
|
||||
};
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct JavaVMAttachArgs
|
||||
{
|
||||
jint version; /* Must be JNI_VERSION_1_2. */
|
||||
char *name; /* The name of the thread (or NULL). */
|
||||
jobject group; /* Global ref of a ThreadGroup object
|
||||
(or NULL). */
|
||||
} JavaVMAttachArgs;
|
||||
|
||||
typedef struct JavaVMOption
|
||||
{
|
||||
char *optionString;
|
||||
void *extraInfo;
|
||||
} JavaVMOption;
|
||||
|
||||
typedef struct JavaVMInitArgs
|
||||
{
|
||||
/* Must be JNI_VERSION_1_2. */
|
||||
jint version;
|
||||
|
||||
/* Number of options. */
|
||||
jint nOptions;
|
||||
|
||||
/* Options to the VM. */
|
||||
JavaVMOption *options;
|
||||
|
||||
/* Whether we should ignore unrecognized options. */
|
||||
jboolean ignoreUnrecognized;
|
||||
} JavaVMInitArgs;
|
||||
|
||||
#endif /* __GCJ_JNI_H__ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue