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]

Patch: PR java/15133 - gcjh generates wrong method signatures


Hi,

  This is my proposed patch for PR java/15133.

If a non-native and native method have the same name,
gcjh was disambiguating the native method by using
its signature - this is unlike the JDK, which uses
the disambiguation only when *another* native method
of the same name is present to create the confusion.

The following patch uses a new flag "is_native" in
struct method_name to keep track of whether a method
is native or not and changes
overloaded_jni_method_exists_p() to check only against
native methods.

Patch was tested on i686-pc-linux-gnu (c,c++,java)
and caused no regressions by itself.

Ok for mainline?

Ranjit.

Index: ChangeLog
from  Ranjit Mathew  <rmathew@hotmail.com>

	Fixes PR java/15133
	* gjavah.c (struct method_name): Add member is_native.
	(overloaded_jni_method_exists_p): Match candidate method only if
	it is native.
	(print_method_info): Initialise is_native flag from the method's
	access flags.

Index: gjavah.c
===================================================================
--- gjavah.c	2004-04-27 15:29:57.000000000 +0530
+++ gjavah.c	2004-04-27 15:47:20.000000000 +0530
@@ -119,6 +119,7 @@ struct method_name
   int length;
   unsigned char *signature;
   int sig_length;
+  int is_native;
   struct method_name *next;
 };

@@ -634,7 +635,7 @@ name_is_method_p (const unsigned char *n
   return 0;
 }

-/* If there is already a method named NAME, whose signature is not
+/* If there is already a native method named NAME, whose signature is not
    SIGNATURE, then return true.  Otherwise return false.  */
 static int
 overloaded_jni_method_exists_p (const unsigned char *name, int length,
@@ -644,7 +645,8 @@ overloaded_jni_method_exists_p (const un

   for (p = method_name_list; p != NULL; p = p->next)
     {
-      if (p->length == length
+      if (p->is_native
+          && p->length == length
 	  && ! memcmp (p->name, name, length)
 	  && (p->sig_length != sig_length
 	      || memcmp (p->signature, signature, sig_length)))
@@ -851,6 +853,7 @@ print_method_info (FILE *stream, JCF* jc
       nn->next = method_name_list;
       nn->sig_length = JPOOL_UTF_LENGTH (jcf, sig_index);
       nn->signature = xmalloc (nn->sig_length);
+      nn->is_native = METHOD_IS_NATIVE (flags);
       memcpy (nn->signature, JPOOL_UTF_DATA (jcf, sig_index),
 	      nn->sig_length);
       method_name_list = nn;


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