This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

JNI NoSuchMethodError message patch


Hi,

While hunting down a bug in the gtk-peer implementation with Thomas we
were confused by a NoSuchMethodError with no additional information
thrown from JNI code. The following patch adds the method name and
signature to the exception when it is thrown. This would have saved us
quite some time debugging.

2004-06-01  Mark Wielaard  <mark@klomp.org>

        * jni.cc (_Jv_JNI_GetAnyMethodID): Add name and signature to
        NoSuchMethodError.

OK, to commit?

Cheers,

Mark
--- jni.cc.orig	2004-06-01 21:18:21.000000000 +0200
+++ jni.cc	2004-06-01 21:17:42.000000000 +0200
@@ -1,6 +1,7 @@
 // jni.cc - JNI implementation, including the jump table.
 
-/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
+   Free Software Foundation
 
    This file is part of libgcj.
 
@@ -27,6 +28,7 @@
 #include <java/lang/Throwable.h>
 #include <java/lang/ArrayIndexOutOfBoundsException.h>
 #include <java/lang/StringIndexOutOfBoundsException.h>
+#include <java/lang/StringBuffer.h>
 #include <java/lang/UnsatisfiedLinkError.h>
 #include <java/lang/InstantiationException.h>
 #include <java/lang/NoSuchFieldError.h>
@@ -705,7 +707,10 @@
 	  clazz = clazz->getSuperclass ();
 	}
 
-      env->ex = new java::lang::NoSuchMethodError ();
+      java::lang::StringBuffer *name_sig =
+        new java::lang::StringBuffer (JvNewStringUTF (name));
+      name_sig->append ((jchar) ' ')->append (JvNewStringUTF (s));
+      env->ex = new java::lang::NoSuchMethodError (name_sig->toString ());
     }
   catch (jthrowable t)
     {

Attachment: signature.asc
Description: This is a digitally signed message part


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]