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
This commit is contained in:
Tom Tromey 2002-04-10 20:36:04 +00:00 committed by Tom Tromey
parent 174bf2b1b2
commit 880f8c16ad
9 changed files with 138 additions and 20 deletions

View File

@ -1,3 +1,36 @@
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>
* win32.cc (_Jv_platform_initProperties): Use GetTempPath.

View File

@ -288,6 +288,7 @@ java/lang/Thread.h: java/lang/Thread.class
-friend 'void _Jv_ThreadRun (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_AttachCurrentThreadAsDaemon(jstring name, java::lang::ThreadGroup* group);' \
-friend 'jint _Jv_DetachCurrentThread ();' \
$(basename $<)

View File

@ -3304,6 +3304,7 @@ java/lang/Thread.h: java/lang/Thread.class
-friend 'void _Jv_ThreadRun (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_AttachCurrentThreadAsDaemon(jstring name, java::lang::ThreadGroup* group);' \
-friend 'jint _Jv_DetachCurrentThread ();' \
$(basename $<)

View File

@ -2,7 +2,7 @@
// This file describes the Cygnus Native Interface, CNI.
// 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.
@ -131,6 +131,12 @@ JvAttachCurrentThread (jstring name, java::lang::ThreadGroup* 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
JvDetachCurrentThread (void)
{

View File

@ -418,6 +418,8 @@ jint
_Jv_AttachCurrentThread(java::lang::Thread* thread);
extern "C" java::lang::Thread*
_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" void _Jv_Throw (jthrowable) __attribute__ ((__noreturn__));

View File

@ -161,6 +161,7 @@ typedef void *jmethodID;
/* Version numbers. */
#define JNI_VERSION_1_1 0x00010001
#define JNI_VERSION_1_2 0x00010002
#define JNI_VERSION_1_4 0x00010004
/* Used when releasing array elements. */
#define JNI_COMMIT 1
@ -641,6 +642,10 @@ struct JNINativeInterface
void (*DeleteWeakGlobalRef) (JNIEnv *, jweak);
jboolean (*ExceptionCheck) (JNIEnv *);
jobject (*NewDirectByteBuffer) (JNIEnv *, void *, jlong);
void * (*GetDirectBufferAddress) (JNIEnv *, jobject);
jlong (*GetDirectBufferCapacity) (JNIEnv *, jobject);
};
#ifdef __cplusplus
@ -1522,6 +1527,15 @@ public:
jboolean ExceptionCheck ()
{ 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 */
@ -1539,6 +1553,7 @@ struct JNIInvokeInterface
jint (*AttachCurrentThread) (JavaVM *, void **, void *);
jint (*DetachCurrentThread) (JavaVM *);
jint (*GetEnv) (JavaVM *, void **, jint);
jint (*AttachCurrentThreadAsDaemon) (JavaVM *, void **, void *);
};
#ifdef __cplusplus
@ -1563,6 +1578,9 @@ public:
jint GetEnv (void **penv, jint version)
{ return functions->GetEnv (this, penv, version); }
jint AttachCurrentThreadAsDaemon (void **penv, void *args)
{ return functions->AttachCurrentThreadAsDaemon (this, penv, args); }
};
#endif /* __cplusplus */

View File

@ -1,6 +1,6 @@
// 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.
@ -167,7 +167,8 @@ java::lang::Runtime::_load (jstring path, jboolean do_search)
return;
}
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.
throw new UnsatisfiedLinkError (JvNewStringLatin1 ("unrecognized version from JNI_OnLoad"));

View File

@ -1,6 +1,6 @@
// 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.
@ -410,6 +410,21 @@ _Jv_AttachCurrentThread(jstring name, java::lang::ThreadGroup* group)
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
_Jv_DetachCurrentThread (void)
{

View File

@ -424,7 +424,7 @@ wrap_value (JNIEnv *env, T *value)
static jint
_Jv_JNI_GetVersion (JNIEnv *)
{
return JNI_VERSION_1_2;
return JNI_VERSION_1_4;
}
static jclass
@ -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.
static JNINativeMethod *nathash;
// Number of slots used.
@ -2096,7 +2121,8 @@ _Jv_JNIMethod::call (ffi_cif *, void *ret, ffi_raw *args, void *__this)
// An internal helper function.
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);
java::lang::ThreadGroup *group = NULL;
@ -2104,7 +2130,8 @@ _Jv_JNI_AttachCurrentThread (JavaVM *, jstring name, void **penv, void *args)
if (attach)
{
// 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)
return JNI_EVERSION;
@ -2147,7 +2174,10 @@ _Jv_JNI_AttachCurrentThread (JavaVM *, jstring name, void **penv, void *args)
{
try
{
_Jv_AttachCurrentThread (name, group);
if (is_daemon)
_Jv_AttachCurrentThreadAsDaemon (name, group);
else
_Jv_AttachCurrentThread (name, group);
}
catch (jthrowable t)
{
@ -2163,7 +2193,13 @@ _Jv_JNI_AttachCurrentThread (JavaVM *, jstring name, void **penv, void *args)
static jint
_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
@ -2185,10 +2221,9 @@ _Jv_JNI_DestroyJavaVM (JavaVM *vm)
return JNI_ERR;
}
jint r = _Jv_JNI_AttachCurrentThread (vm,
main_name,
jint r = _Jv_JNI_AttachCurrentThread (vm, main_name,
reinterpret_cast<void **> (&env),
NULL);
NULL, false);
if (r < 0)
return r;
}
@ -2227,7 +2262,8 @@ _Jv_JNI_GetEnv (JavaVM *, void **penv, jint version)
#endif
// 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;
return JNI_EVERSION;
@ -2241,12 +2277,12 @@ jint
JNI_GetDefaultJavaVMInitArgs (void *args)
{
jint version = * (jint *) args;
// Here we only support 1.2.
if (version != JNI_VERSION_1_2)
// Here we only support 1.2 and 1.4.
if (version != JNI_VERSION_1_2 && version != JNI_VERSION_1_4)
return JNI_EVERSION;
JavaVMInitArgs *ia = reinterpret_cast<JavaVMInitArgs *> (args);
ia->version = JNI_VERSION_1_2;
ia->version = JNI_VERSION_1_4;
ia->nOptions = 0;
ia->options = NULL;
ia->ignoreUnrecognized = true;
@ -2271,8 +2307,8 @@ JNI_CreateJavaVM (JavaVM **vm, void **penv, void *args)
if (args != NULL)
{
jint version = * (jint *) args;
// We only support 1.2.
if (version != JNI_VERSION_1_2)
// We only support 1.2 and 1.4.
if (version != JNI_VERSION_1_2 && version != JNI_VERSION_1_4)
return JNI_EVERSION;
JavaVMInitArgs *ia = reinterpret_cast<JavaVMInitArgs *> (args);
for (int i = 0; i < ia->nOptions; ++i)
@ -2614,7 +2650,11 @@ struct JNINativeInterface _Jv_JNIFunctions =
_Jv_JNI_NewWeakGlobalRef, // NewWeakGlobalRef
_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 =
@ -2626,5 +2666,6 @@ struct JNIInvokeInterface _Jv_JNI_InvokeFunctions =
_Jv_JNI_DestroyJavaVM,
_Jv_JNI_AttachCurrentThread,
_Jv_JNI_DetachCurrentThread,
_Jv_JNI_GetEnv
_Jv_JNI_GetEnv,
_Jv_JNI_AttachCurrentThreadAsDaemon
};