This is the mail archive of the java@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]

Re: Bug in JNI RegisterNatives?


Juerg,

Thanks for the reminder. Ideally we should find a way to refer to klass->name directly rather than reading it as a String and converting it back to Utf8. Yes, doing it in this one instance doesn't hurt much, but it would simplify the patch a lot, and fixing it might come in useful elsewhere. Would the patch below help?

Also, was there a reason to change _Jv_AllocBytes() calls to _Jv_Malloc()?

For large changes we need a GCC copyright assignment on file with the FSF. See: http://gcc.gnu.org/contribute.html - I think we can accept this under the "small changes" rule, however. But, if you plan to contribute more changes in the future, it might be a good idea to start the paperwork process now.

Bryce


Juerg Lehni wrote:
Tom,

Please let me know what I should do to get this patch finalized and commited. I would like to make sure it's getting there soon.

Jürg

2006-06-16  Bryce McKinlay  <mckinlay@redhat.com>

        * java/lang/Class.h (_Jv_GetClassNameUtf8): New declaration.
        * java/lang/natClass.cc (_Jv_GetClassNameUtf8): Define.

Index: Class.h
===================================================================
--- Class.h	(revision 114642)
+++ Class.h	(working copy)
@@ -231,6 +231,7 @@
 jmethodID _Jv_FromReflectedConstructor (java::lang::reflect::Constructor *);
 jint JvNumMethods (jclass);
 jmethodID JvGetFirstMethod (jclass);
+_Jv_Utf8Const* _Jv_GetClassNameUtf8 (jclass);
 
 #ifdef INTERPRETER
 // Finds a desired interpreter method in the given class or NULL if not found
@@ -472,6 +473,7 @@
   friend jmethodID (::_Jv_FromReflectedConstructor) (java::lang::reflect::Constructor *);
   friend jint (::JvNumMethods) (jclass);
   friend jmethodID (::JvGetFirstMethod) (jclass);
+  friend _Jv_Utf8Const * ::_Jv_GetClassNameUtf8 (jclass);
 #ifdef INTERPRETER
   friend _Jv_InterpMethod* (::_Jv_FindInterpreterMethod) (jclass klass,
 							  jmethodID desired_method);
Index: natClass.cc
===================================================================
--- natClass.cc	(revision 114642)
+++ natClass.cc	(working copy)
@@ -1264,3 +1264,11 @@
   return NULL;
 }
 #endif
+
+// Return Utf8 name of a class. This function is here for code that can't access 
+// klass->name directly.
+_Jv_Utf8Const*
+_Jv_GetClassNameUtf8 (jclass klass)
+{
+  return klass->name;
+}

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