Makefile.in: Rebuilt.
authorTom Tromey <tromey@redhat.com>
Wed, 10 Apr 2002 20:36:04 +0000 (20:36 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Wed, 10 Apr 2002 20:36:04 +0000 (20:36 +0000)
* 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

libjava/ChangeLog
libjava/Makefile.am
libjava/Makefile.in
libjava/gcj/cni.h
libjava/gcj/javaprims.h
libjava/include/jni.h
libjava/java/lang/natRuntime.cc
libjava/java/lang/natThread.cc
libjava/jni.cc

index 8d8bf19f5dc88d821dbf64fcb1575b85fe44f721..f7830847e8fb49aad2e1cd9198ce1971420632db 100644 (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.
index aefb731002fba8a5e4d42c2b4c62f00272559d4c..2a392430c6876aecaa2ace9d2a7f2577f8f32b6e 100644 (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 $<)
 
index 834ed17a31c2248f9b14ed7b71a8aa3e5a13fb66..818ad5aaf1532f254278527806257dfd04f5fb28 100644 (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 $<)
 
index b1254a2e191d4f8fb54fee7a1b66c5b3d8b5de0c..08b55c3c7f282be7c94e66ef67f731683bd6ff80 100644 (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)
 {
index c4d86fb126e5591ddd501d4e0544ede9e386002d..4337f56d566695620f4430fe795a5971b4f183b8 100644 (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__));
index 6eb04407ad48f7b5ff5cf2e78d9cbc72f3b7828e..b5ce334b895742ee7c0efdf49f30258060bec77e 100644 (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 */
 
index 18bc3cb9bf9eb205dd209d49e64ee3093756c633..a566bf4d99943d92142bd6637e9eeea0114ed2ea 100644 (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"));
index 4c0d978767d0817bdcd367002d0f19dbd06206ab..7fe8fb0db4620a4ce89ba35203d02b114dd15ee6 100644 (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)
 {
index 1abd2d2497ac70c72c7891eb353f68d672bd80b3..bb504209cf55bb162414924698bb8f1c0cf06fef 100644 (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)
 
 \f
 
+// 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;
+}
+
+\f
+
 // 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
 };