public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Patch: FYI: JNI fixlet
@ 2006-01-19  0:46 Tom Tromey
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2006-01-19  0:46 UTC (permalink / raw)
  To: Java Patch List

I'm checking this in on the trunk and the 4.1 branch.

This is a JNI fix I've been sitting on for a long time.
This lets fuse-j work.  Basically if you try to attach an
already-attached thread, you should still get back the environment
pointer.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* jni.cc (_Jv_JNI_AttachCurrentThread): Return environment if it
	already exists.

Index: jni.cc
===================================================================
--- jni.cc	(revision 109835)
+++ jni.cc	(working copy)
@@ -1,6 +1,6 @@
 // jni.cc - JNI implementation, including the jump table.
 
-/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation
 
    This file is part of libgcj.
@@ -2352,10 +2352,14 @@
     }
 
   // Attaching an already-attached thread is a no-op.
-  if (_Jv_GetCurrentJNIEnv () != NULL)
-    return 0;
+  JNIEnv *env = _Jv_GetCurrentJNIEnv ();
+  if (env != NULL)
+    {
+      *penv = reinterpret_cast<void *> (env);
+      return 0;
+    }
 
-  JNIEnv *env = (JNIEnv *) _Jv_MallocUnchecked (sizeof (JNIEnv));
+  env = (JNIEnv *) _Jv_MallocUnchecked (sizeof (JNIEnv));
   if (env == NULL)
     return JNI_ERR;
   env->p = &_Jv_JNIFunctions;

^ permalink raw reply	[flat|nested] 3+ messages in thread
* Patch: FYI: JNI fixlet
@ 2003-11-18 17:54 Tom Tromey
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2003-11-18 17:54 UTC (permalink / raw)
  To: GCC libjava patches

I'm checking this in.

My reading of the JNI spec is that GetStringUTFChars should handle the
case where the string argument is NULL.  In any case, it doesn't hurt
to code this defensively.  I'm fixing this as appended.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* jni.cc (_Jv_JNI_GetStringUTFChars): Fail gracefully if string
	is null.

Index: jni.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni.cc,v
retrieving revision 1.79
diff -u -r1.79 jni.cc
--- jni.cc 14 Nov 2003 01:48:28 -0000 1.79
+++ jni.cc 18 Nov 2003 17:51:37 -0000
@@ -1298,10 +1298,12 @@
 (JNICALL _Jv_JNI_GetStringUTFChars) (JNIEnv *env, jstring string, 
                                      jboolean *isCopy)
 {
-  string = unwrap (string);
-  jsize len = JvGetStringUTFLength (string);
   try
     {
+      string = unwrap (string);
+      if (string == NULL)
+	return NULL;
+      jsize len = JvGetStringUTFLength (string);
       char *r = (char *) _Jv_Malloc (len + 1);
       JvGetStringUTFRegion (string, 0, string->length(), r);
       r[len] = '\0';

^ permalink raw reply	[flat|nested] 3+ messages in thread
* Patch: FYI: JNI fixlet
@ 2002-03-05 20:33 Tom Tromey
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2002-03-05 20:33 UTC (permalink / raw)
  To: Java Patch List

I'm checking this in on the trunk and branch.
This fixes a minor spec divergence.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* jni.cc (_Jv_LookupJNIMethod): Throw UnsatisfiedLinkError, not
	AbstractMethodError.

Index: jni.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni.cc,v
retrieving revision 1.60
diff -u -r1.60 jni.cc
--- jni.cc 2002/02/13 17:34:52 1.60
+++ jni.cc 2002/03/05 22:33:53
@@ -26,7 +26,7 @@
 #include <java/lang/Throwable.h>
 #include <java/lang/ArrayIndexOutOfBoundsException.h>
 #include <java/lang/StringIndexOutOfBoundsException.h>
-#include <java/lang/AbstractMethodError.h>
+#include <java/lang/UnsatisfiedLinkError.h>
 #include <java/lang/InstantiationException.h>
 #include <java/lang/NoSuchFieldError.h>
 #include <java/lang/NoSuchMethodError.h>
@@ -2014,7 +2014,7 @@
       if (function == NULL)
 	{
 	  jstring str = JvNewStringUTF (name->data);
-	  throw new java::lang::AbstractMethodError (str);
+	  throw new java::lang::UnsatisfiedLinkError (str);
 	}
     }
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-01-19  0:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-19  0:46 Patch: FYI: JNI fixlet Tom Tromey
  -- strict thread matches above, loose matches on Subject: below --
2003-11-18 17:54 Tom Tromey
2002-03-05 20:33 Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).