Commit 880f8c16 by Tom Tromey Committed by Tom Tromey

Makefile.in: Rebuilt.

	* Makefile.in: Rebuilt.
	* Makefile.am (java/lang/Thread.h): Mark
	_Jv_AttachCurrentThreadAsDaemon as friend.
	* gcj/javaprims.h (_Jv_AttachCurrentThreadAsDaemon): Declare.
	* gcj/cni.h (JvAttachCurrentThreadAsDaemon): New function.
	* java/lang/natThread.cc (_Jv_AttachCurrentThreadAsDaemon): New
	function.
	* java/lang/natRuntime.cc (_load): Recognize JNI_VERSION_1_4.
	* jni.cc (_Jv_JNI_GetVersion): Return JNI_VERSION_1_4.
	(_Jv_JNI_InvokeFunctions): Added
	_Jv_JNI_AttachCurrentThreadAsDaemon.
	(_Jv_JNI_GetEnv): Handle JNI_VERSION_1_4.
	(JNI_GetDefaultJavaVMInitArgs): Likewise.
	(JNI_CreateJavaVM): Likewise.
	(_Jv_JNI_AttachCurrentThread): Likewise.
	(_Jv_JNI_AttachCurrentThread): Added `is_daemon' argument.
	(_Jv_JNI_AttachCurrentThreadAsDaemon): New method.
	(_Jv_JNIFunctions): Initialize new fields.
	(_Jv_JNI_NewDirectByteBuffer): New function.
	(_Jv_JNI_GetDirectBufferAddress): Likewise.
	(_Jv_JNI_GetDirectBufferCapacity): Likewise.
	* include/jni.h (JNI_VERSION_1_4): New macro.
	(JNIInvokeInterface::AttachCurrentThreadAsDaemon): New field.
	(_Jv_JavaVM::AttachCurrentThreadAsDaemon): New method.
	(JNINativeInterface::NewDirectByteBuffer): New field.
	(JNINativeInterface::GetDirectBufferAddress): New field.
	(JNINativeInterface::GetDirectBufferCapacity): New field.
	(_Jv_JNIEnv::NewDirectByteBuffer): New method.
	(_Jv_JNIEnv::GetDirectBufferAddress): New method.
	(_Jv_JNIEnv::GetDirectBufferCapacity): New method.

From-SVN: r52144
parent 174bf2b1
2002-04-10 Tom Tromey <tromey@redhat.com>
* Makefile.in: Rebuilt.
* Makefile.am (java/lang/Thread.h): Mark
_Jv_AttachCurrentThreadAsDaemon as friend.
* gcj/javaprims.h (_Jv_AttachCurrentThreadAsDaemon): Declare.
* gcj/cni.h (JvAttachCurrentThreadAsDaemon): New function.
* java/lang/natThread.cc (_Jv_AttachCurrentThreadAsDaemon): New
function.
* java/lang/natRuntime.cc (_load): Recognize JNI_VERSION_1_4.
* jni.cc (_Jv_JNI_GetVersion): Return JNI_VERSION_1_4.
(_Jv_JNI_InvokeFunctions): Added
_Jv_JNI_AttachCurrentThreadAsDaemon.
(_Jv_JNI_GetEnv): Handle JNI_VERSION_1_4.
(JNI_GetDefaultJavaVMInitArgs): Likewise.
(JNI_CreateJavaVM): Likewise.
(_Jv_JNI_AttachCurrentThread): Likewise.
(_Jv_JNI_AttachCurrentThread): Added `is_daemon' argument.
(_Jv_JNI_AttachCurrentThreadAsDaemon): New method.
(_Jv_JNIFunctions): Initialize new fields.
(_Jv_JNI_NewDirectByteBuffer): New function.
(_Jv_JNI_GetDirectBufferAddress): Likewise.
(_Jv_JNI_GetDirectBufferCapacity): Likewise.
* include/jni.h (JNI_VERSION_1_4): New macro.
(JNIInvokeInterface::AttachCurrentThreadAsDaemon): New field.
(_Jv_JavaVM::AttachCurrentThreadAsDaemon): New method.
(JNINativeInterface::NewDirectByteBuffer): New field.
(JNINativeInterface::GetDirectBufferAddress): New field.
(JNINativeInterface::GetDirectBufferCapacity): New field.
(_Jv_JNIEnv::NewDirectByteBuffer): New method.
(_Jv_JNIEnv::GetDirectBufferAddress): New method.
(_Jv_JNIEnv::GetDirectBufferCapacity): New method.
2002-04-09 Tom Tromey <tromey@redhat.com> 2002-04-09 Tom Tromey <tromey@redhat.com>
* win32.cc (_Jv_platform_initProperties): Use GetTempPath. * win32.cc (_Jv_platform_initProperties): Use GetTempPath.
......
...@@ -288,6 +288,7 @@ java/lang/Thread.h: java/lang/Thread.class ...@@ -288,6 +288,7 @@ java/lang/Thread.h: java/lang/Thread.class
-friend 'void _Jv_ThreadRun (java::lang::Thread* thread);' \ -friend 'void _Jv_ThreadRun (java::lang::Thread* thread);' \
-friend 'jint _Jv_AttachCurrentThread(java::lang::Thread* thread);' \ -friend 'jint _Jv_AttachCurrentThread(java::lang::Thread* thread);' \
-friend 'java::lang::Thread* _Jv_AttachCurrentThread(jstring name, java::lang::ThreadGroup* group);' \ -friend 'java::lang::Thread* _Jv_AttachCurrentThread(jstring name, java::lang::ThreadGroup* group);' \
-friend 'java::lang::Thread* _Jv_AttachCurrentThreadAsDaemon(jstring name, java::lang::ThreadGroup* group);' \
-friend 'jint _Jv_DetachCurrentThread ();' \ -friend 'jint _Jv_DetachCurrentThread ();' \
$(basename $<) $(basename $<)
......
...@@ -3304,6 +3304,7 @@ java/lang/Thread.h: java/lang/Thread.class ...@@ -3304,6 +3304,7 @@ java/lang/Thread.h: java/lang/Thread.class
-friend 'void _Jv_ThreadRun (java::lang::Thread* thread);' \ -friend 'void _Jv_ThreadRun (java::lang::Thread* thread);' \
-friend 'jint _Jv_AttachCurrentThread(java::lang::Thread* thread);' \ -friend 'jint _Jv_AttachCurrentThread(java::lang::Thread* thread);' \
-friend 'java::lang::Thread* _Jv_AttachCurrentThread(jstring name, java::lang::ThreadGroup* group);' \ -friend 'java::lang::Thread* _Jv_AttachCurrentThread(jstring name, java::lang::ThreadGroup* group);' \
-friend 'java::lang::Thread* _Jv_AttachCurrentThreadAsDaemon(jstring name, java::lang::ThreadGroup* group);' \
-friend 'jint _Jv_DetachCurrentThread ();' \ -friend 'jint _Jv_DetachCurrentThread ();' \
$(basename $<) $(basename $<)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// This file describes the Cygnus Native Interface, CNI. // This file describes the Cygnus Native Interface, CNI.
// It provides a nicer interface to many of the things in gcj/javaprims.h. // It provides a nicer interface to many of the things in gcj/javaprims.h.
/* Copyright (C) 1998, 1999 Free Software Foundation /* Copyright (C) 1998, 1999, 2002 Free Software Foundation
This file is part of libgcj. This file is part of libgcj.
...@@ -131,6 +131,12 @@ JvAttachCurrentThread (jstring name, java::lang::ThreadGroup* group) ...@@ -131,6 +131,12 @@ JvAttachCurrentThread (jstring name, java::lang::ThreadGroup* group)
return _Jv_AttachCurrentThread (name, group); return _Jv_AttachCurrentThread (name, group);
} }
extern inline java::lang::Thread*
JvAttachCurrentThreadAsDaemon (jstring name, java::lang::ThreadGroup* group)
{
return _Jv_AttachCurrentThreadAsDaemon (name, group);
}
extern inline jint extern inline jint
JvDetachCurrentThread (void) JvDetachCurrentThread (void)
{ {
......
...@@ -418,6 +418,8 @@ jint ...@@ -418,6 +418,8 @@ jint
_Jv_AttachCurrentThread(java::lang::Thread* thread); _Jv_AttachCurrentThread(java::lang::Thread* thread);
extern "C" java::lang::Thread* extern "C" java::lang::Thread*
_Jv_AttachCurrentThread(jstring name, java::lang::ThreadGroup* group); _Jv_AttachCurrentThread(jstring name, java::lang::ThreadGroup* group);
extern "C" java::lang::Thread*
_Jv_AttachCurrentThreadAsDaemon(jstring name, java::lang::ThreadGroup* group);
extern "C" jint _Jv_DetachCurrentThread (void); extern "C" jint _Jv_DetachCurrentThread (void);
extern "C" void _Jv_Throw (jthrowable) __attribute__ ((__noreturn__)); extern "C" void _Jv_Throw (jthrowable) __attribute__ ((__noreturn__));
......
...@@ -161,6 +161,7 @@ typedef void *jmethodID; ...@@ -161,6 +161,7 @@ typedef void *jmethodID;
/* Version numbers. */ /* Version numbers. */
#define JNI_VERSION_1_1 0x00010001 #define JNI_VERSION_1_1 0x00010001
#define JNI_VERSION_1_2 0x00010002 #define JNI_VERSION_1_2 0x00010002
#define JNI_VERSION_1_4 0x00010004
/* Used when releasing array elements. */ /* Used when releasing array elements. */
#define JNI_COMMIT 1 #define JNI_COMMIT 1
...@@ -641,6 +642,10 @@ struct JNINativeInterface ...@@ -641,6 +642,10 @@ struct JNINativeInterface
void (*DeleteWeakGlobalRef) (JNIEnv *, jweak); void (*DeleteWeakGlobalRef) (JNIEnv *, jweak);
jboolean (*ExceptionCheck) (JNIEnv *); jboolean (*ExceptionCheck) (JNIEnv *);
jobject (*NewDirectByteBuffer) (JNIEnv *, void *, jlong);
void * (*GetDirectBufferAddress) (JNIEnv *, jobject);
jlong (*GetDirectBufferCapacity) (JNIEnv *, jobject);
}; };
#ifdef __cplusplus #ifdef __cplusplus
...@@ -1522,6 +1527,15 @@ public: ...@@ -1522,6 +1527,15 @@ public:
jboolean ExceptionCheck () jboolean ExceptionCheck ()
{ return p->ExceptionCheck (this); } { return p->ExceptionCheck (this); }
jobject NewDirectByteBuffer (void *addr, jlong capacity)
{ return p->NewDirectByteBuffer (this, addr, capacity); }
void *GetDirectBufferAddress (jobject buf)
{ return p->GetDirectBufferAddress (this, buf); }
jlong GetDirectBufferCapacity (jobject buf)
{ return p->GetDirectBufferCapacity (this, buf); }
}; };
#endif /* __cplusplus */ #endif /* __cplusplus */
...@@ -1539,6 +1553,7 @@ struct JNIInvokeInterface ...@@ -1539,6 +1553,7 @@ struct JNIInvokeInterface
jint (*AttachCurrentThread) (JavaVM *, void **, void *); jint (*AttachCurrentThread) (JavaVM *, void **, void *);
jint (*DetachCurrentThread) (JavaVM *); jint (*DetachCurrentThread) (JavaVM *);
jint (*GetEnv) (JavaVM *, void **, jint); jint (*GetEnv) (JavaVM *, void **, jint);
jint (*AttachCurrentThreadAsDaemon) (JavaVM *, void **, void *);
}; };
#ifdef __cplusplus #ifdef __cplusplus
...@@ -1563,6 +1578,9 @@ public: ...@@ -1563,6 +1578,9 @@ public:
jint GetEnv (void **penv, jint version) jint GetEnv (void **penv, jint version)
{ return functions->GetEnv (this, penv, version); } { return functions->GetEnv (this, penv, version); }
jint AttachCurrentThreadAsDaemon (void **penv, void *args)
{ return functions->AttachCurrentThreadAsDaemon (this, penv, args); }
}; };
#endif /* __cplusplus */ #endif /* __cplusplus */
......
// natRuntime.cc - Implementation of native side of Runtime class. // natRuntime.cc - Implementation of native side of Runtime class.
/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation /* Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation
This file is part of libgcj. This file is part of libgcj.
...@@ -167,7 +167,8 @@ java::lang::Runtime::_load (jstring path, jboolean do_search) ...@@ -167,7 +167,8 @@ java::lang::Runtime::_load (jstring path, jboolean do_search)
return; return;
} }
jint vers = ((jint (*) (JavaVM *, void *)) onload) (vm, NULL); jint vers = ((jint (*) (JavaVM *, void *)) onload) (vm, NULL);
if (vers != JNI_VERSION_1_1 && vers != JNI_VERSION_1_2) if (vers != JNI_VERSION_1_1 && vers != JNI_VERSION_1_2
&& vers != JNI_VERSION_1_4)
{ {
// FIXME: unload the library. // FIXME: unload the library.
throw new UnsatisfiedLinkError (JvNewStringLatin1 ("unrecognized version from JNI_OnLoad")); throw new UnsatisfiedLinkError (JvNewStringLatin1 ("unrecognized version from JNI_OnLoad"));
......
// natThread.cc - Native part of Thread class. // natThread.cc - Native part of Thread class.
/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation /* Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation
This file is part of libgcj. This file is part of libgcj.
...@@ -410,6 +410,21 @@ _Jv_AttachCurrentThread(jstring name, java::lang::ThreadGroup* group) ...@@ -410,6 +410,21 @@ _Jv_AttachCurrentThread(jstring name, java::lang::ThreadGroup* group)
return thread; return thread;
} }
java::lang::Thread*
_Jv_AttachCurrentThreadAsDaemon(jstring name, java::lang::ThreadGroup* group)
{
java::lang::Thread *thread = _Jv_ThreadCurrent ();
if (thread != NULL)
return thread;
if (name == NULL)
name = java::lang::Thread::gen_name ();
thread = new java::lang::Thread (NULL, group, NULL, name);
thread->setDaemon (true);
_Jv_AttachCurrentThread (thread);
_Jv_NotifyThreadStart (thread);
return thread;
}
jint jint
_Jv_DetachCurrentThread (void) _Jv_DetachCurrentThread (void)
{ {
......
...@@ -424,7 +424,7 @@ wrap_value (JNIEnv *env, T *value) ...@@ -424,7 +424,7 @@ wrap_value (JNIEnv *env, T *value)
static jint static jint
_Jv_JNI_GetVersion (JNIEnv *) _Jv_JNI_GetVersion (JNIEnv *)
{ {
return JNI_VERSION_1_2; return JNI_VERSION_1_4;
} }
static jclass static jclass
...@@ -1672,6 +1672,31 @@ _Jv_JNI_DeleteWeakGlobalRef (JNIEnv *, jweak obj) ...@@ -1672,6 +1672,31 @@ _Jv_JNI_DeleteWeakGlobalRef (JNIEnv *, jweak obj)
// Direct byte buffers.
static jobject
_Jv_JNI_NewDirectByteBuffer (JNIEnv *, void *, jlong)
{
// For now we don't support this.
return NULL;
}
static void *
_Jv_JNI_GetDirectBufferAddress (JNIEnv *, jobject)
{
// For now we don't support this.
return NULL;
}
static jlong
_Jv_JNI_GetDirectBufferCapacity (JNIEnv *, jobject)
{
// For now we don't support this.
return -1;
}
// Hash table of native methods. // Hash table of native methods.
static JNINativeMethod *nathash; static JNINativeMethod *nathash;
// Number of slots used. // Number of slots used.
...@@ -2096,7 +2121,8 @@ _Jv_JNIMethod::call (ffi_cif *, void *ret, ffi_raw *args, void *__this) ...@@ -2096,7 +2121,8 @@ _Jv_JNIMethod::call (ffi_cif *, void *ret, ffi_raw *args, void *__this)
// An internal helper function. // An internal helper function.
static jint static jint
_Jv_JNI_AttachCurrentThread (JavaVM *, jstring name, void **penv, void *args) _Jv_JNI_AttachCurrentThread (JavaVM *, jstring name, void **penv,
void *args, jboolean is_daemon)
{ {
JavaVMAttachArgs *attach = reinterpret_cast<JavaVMAttachArgs *> (args); JavaVMAttachArgs *attach = reinterpret_cast<JavaVMAttachArgs *> (args);
java::lang::ThreadGroup *group = NULL; java::lang::ThreadGroup *group = NULL;
...@@ -2104,7 +2130,8 @@ _Jv_JNI_AttachCurrentThread (JavaVM *, jstring name, void **penv, void *args) ...@@ -2104,7 +2130,8 @@ _Jv_JNI_AttachCurrentThread (JavaVM *, jstring name, void **penv, void *args)
if (attach) if (attach)
{ {
// FIXME: do we really want to support 1.1? // FIXME: do we really want to support 1.1?
if (attach->version != JNI_VERSION_1_2 if (attach->version != JNI_VERSION_1_4
&& attach->version != JNI_VERSION_1_2
&& attach->version != JNI_VERSION_1_1) && attach->version != JNI_VERSION_1_1)
return JNI_EVERSION; return JNI_EVERSION;
...@@ -2147,7 +2174,10 @@ _Jv_JNI_AttachCurrentThread (JavaVM *, jstring name, void **penv, void *args) ...@@ -2147,7 +2174,10 @@ _Jv_JNI_AttachCurrentThread (JavaVM *, jstring name, void **penv, void *args)
{ {
try try
{ {
_Jv_AttachCurrentThread (name, group); if (is_daemon)
_Jv_AttachCurrentThreadAsDaemon (name, group);
else
_Jv_AttachCurrentThread (name, group);
} }
catch (jthrowable t) catch (jthrowable t)
{ {
...@@ -2163,7 +2193,13 @@ _Jv_JNI_AttachCurrentThread (JavaVM *, jstring name, void **penv, void *args) ...@@ -2163,7 +2193,13 @@ _Jv_JNI_AttachCurrentThread (JavaVM *, jstring name, void **penv, void *args)
static jint static jint
_Jv_JNI_AttachCurrentThread (JavaVM *vm, void **penv, void *args) _Jv_JNI_AttachCurrentThread (JavaVM *vm, void **penv, void *args)
{ {
return _Jv_JNI_AttachCurrentThread (vm, NULL, penv, args); return _Jv_JNI_AttachCurrentThread (vm, NULL, penv, args, false);
}
static jint
_Jv_JNI_AttachCurrentThreadAsDaemon (JavaVM *vm, void **penv, void *args)
{
return _Jv_JNI_AttachCurrentThread (vm, NULL, penv, args, true);
} }
static jint static jint
...@@ -2185,10 +2221,9 @@ _Jv_JNI_DestroyJavaVM (JavaVM *vm) ...@@ -2185,10 +2221,9 @@ _Jv_JNI_DestroyJavaVM (JavaVM *vm)
return JNI_ERR; return JNI_ERR;
} }
jint r = _Jv_JNI_AttachCurrentThread (vm, jint r = _Jv_JNI_AttachCurrentThread (vm, main_name,
main_name,
reinterpret_cast<void **> (&env), reinterpret_cast<void **> (&env),
NULL); NULL, false);
if (r < 0) if (r < 0)
return r; return r;
} }
...@@ -2227,7 +2262,8 @@ _Jv_JNI_GetEnv (JavaVM *, void **penv, jint version) ...@@ -2227,7 +2262,8 @@ _Jv_JNI_GetEnv (JavaVM *, void **penv, jint version)
#endif #endif
// FIXME: do we really want to support 1.1? // FIXME: do we really want to support 1.1?
if (version != JNI_VERSION_1_2 && version != JNI_VERSION_1_1) if (version != JNI_VERSION_1_4 && version != JNI_VERSION_1_2
&& version != JNI_VERSION_1_1)
{ {
*penv = NULL; *penv = NULL;
return JNI_EVERSION; return JNI_EVERSION;
...@@ -2241,12 +2277,12 @@ jint ...@@ -2241,12 +2277,12 @@ jint
JNI_GetDefaultJavaVMInitArgs (void *args) JNI_GetDefaultJavaVMInitArgs (void *args)
{ {
jint version = * (jint *) args; jint version = * (jint *) args;
// Here we only support 1.2. // Here we only support 1.2 and 1.4.
if (version != JNI_VERSION_1_2) if (version != JNI_VERSION_1_2 && version != JNI_VERSION_1_4)
return JNI_EVERSION; return JNI_EVERSION;
JavaVMInitArgs *ia = reinterpret_cast<JavaVMInitArgs *> (args); JavaVMInitArgs *ia = reinterpret_cast<JavaVMInitArgs *> (args);
ia->version = JNI_VERSION_1_2; ia->version = JNI_VERSION_1_4;
ia->nOptions = 0; ia->nOptions = 0;
ia->options = NULL; ia->options = NULL;
ia->ignoreUnrecognized = true; ia->ignoreUnrecognized = true;
...@@ -2271,8 +2307,8 @@ JNI_CreateJavaVM (JavaVM **vm, void **penv, void *args) ...@@ -2271,8 +2307,8 @@ JNI_CreateJavaVM (JavaVM **vm, void **penv, void *args)
if (args != NULL) if (args != NULL)
{ {
jint version = * (jint *) args; jint version = * (jint *) args;
// We only support 1.2. // We only support 1.2 and 1.4.
if (version != JNI_VERSION_1_2) if (version != JNI_VERSION_1_2 && version != JNI_VERSION_1_4)
return JNI_EVERSION; return JNI_EVERSION;
JavaVMInitArgs *ia = reinterpret_cast<JavaVMInitArgs *> (args); JavaVMInitArgs *ia = reinterpret_cast<JavaVMInitArgs *> (args);
for (int i = 0; i < ia->nOptions; ++i) for (int i = 0; i < ia->nOptions; ++i)
...@@ -2614,7 +2650,11 @@ struct JNINativeInterface _Jv_JNIFunctions = ...@@ -2614,7 +2650,11 @@ struct JNINativeInterface _Jv_JNIFunctions =
_Jv_JNI_NewWeakGlobalRef, // NewWeakGlobalRef _Jv_JNI_NewWeakGlobalRef, // NewWeakGlobalRef
_Jv_JNI_DeleteWeakGlobalRef, // DeleteWeakGlobalRef _Jv_JNI_DeleteWeakGlobalRef, // DeleteWeakGlobalRef
_Jv_JNI_ExceptionCheck _Jv_JNI_ExceptionCheck, // ExceptionCheck
_Jv_JNI_NewDirectByteBuffer, // NewDirectByteBuffer
_Jv_JNI_GetDirectBufferAddress, // GetDirectBufferAddress
_Jv_JNI_GetDirectBufferCapacity // GetDirectBufferCapacity
}; };
struct JNIInvokeInterface _Jv_JNI_InvokeFunctions = struct JNIInvokeInterface _Jv_JNI_InvokeFunctions =
...@@ -2626,5 +2666,6 @@ struct JNIInvokeInterface _Jv_JNI_InvokeFunctions = ...@@ -2626,5 +2666,6 @@ struct JNIInvokeInterface _Jv_JNI_InvokeFunctions =
_Jv_JNI_DestroyJavaVM, _Jv_JNI_DestroyJavaVM,
_Jv_JNI_AttachCurrentThread, _Jv_JNI_AttachCurrentThread,
_Jv_JNI_DetachCurrentThread, _Jv_JNI_DetachCurrentThread,
_Jv_JNI_GetEnv _Jv_JNI_GetEnv,
_Jv_JNI_AttachCurrentThreadAsDaemon
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment