This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch: PR java/15133 - gcjh generates wrong method signatures
- From: Ranjit Mathew <rmathew at gmail dot com>
- To: tromey at redhat dot com
- Cc: java-patches at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Fri, 30 Apr 2004 13:20:30 +0530
- Subject: Re: Patch: PR java/15133 - gcjh generates wrong method signatures
- References: <c6lhc7$600$1@sea.gmane.org> <87d65sjd0i.fsf@fleche.redhat.com>
Tom Tromey wrote:
>>>>>>"Ranjit" == Ranjit Mathew <rmathew@gmail.com> writes:
>
>
> Ranjit> The following patch uses a new flag "is_native" in
> Ranjit> struct method_name to keep track of whether a method
> Ranjit> is native or not and changes
> Ranjit> overloaded_jni_method_exists_p() to check only against
> Ranjit> native methods.
>
> Ranjit> Ok for mainline?
>
> Yes, please commit. Could you add a test case for this to
> libjava/testsuite/libjava.jni?
Hi Tom,
Thanks for approving this patch. When I tried to implement a
testcase for this, I realised that a wrong prototype does not
quite result in an error so the testcase didn't have any effect
in uncovering the bug in question.
Therefore (as suggested by you privately), I am changing the
script to use an additional "-Wmissing-prototypes" for compiling
C sources.
While I was at it, I noticed that we print the wrong file
name for C++ sources (e.g. "cxxtest.c" instead of "cxxtest.cc").
The following also contains a fix for that.
With this patch, I can finally see a FAIL -> PASS transition
after I apply my original patch for PR 15133.
Ok?
Ranjit.
Index: ChangeLog
from Ranjit Mathew <rmathew@hotmail.com>
Tom Tromey <tromey@redhat.com>
* testsuite/libjava.jni/jni.exp (gcj_jni_compile_c_to_so): Use
additional option "-Wmissing-prototypes" for compiling C sources.
Print actual filename for pass/fail rather than $name.c.
* testsuite/libjava.jni/PR15133.java: New testcase file.
* testsuite/libjava.jni/PR15133.c: Likewise.
* testsuite/libjava.jni/PR15133.out: Likewise.
Index: testsuite/libjava.jni/jni.exp
===================================================================
--- testsuite/libjava.jni/jni.exp 2004-04-30 11:23:47.000000000 +0530
+++ testsuite/libjava.jni/jni.exp 2004-04-30 12:30:33.000000000 +0530
@@ -21,12 +21,21 @@ proc gcj_jni_compile_c_to_so {file {opti
set so_extension "so"
set so_flag "-shared"
}
- set name [file rootname [file tail $file]]
+ set filename [file tail $file]
+ set name [file rootname $filename]
set soname lib${name}.${so_extension}
lappend options "additional_flags=${so_flag} -fPIC"
# Find the generated header.
lappend options "additional_flags=-I. -I.."
+
+ # Ensure that the generated header has correct prototypes.
+ set cfile [file rootname $file].c
+ if { [file exists $cfile]} {
+ # This option is only valid for C sources.
+ lappend options "additional_flags=-Wmissing-prototypes"
+ }
+
# Find jni.h.
lappend options "additional_flags=-I$srcdir/../include"
@@ -34,11 +43,11 @@ proc gcj_jni_compile_c_to_so {file {opti
[target_compile $file $soname executable $options]]
if {$x != ""} {
verbose "target_compile failed: $x" 2
- fail "$name.c compilation"
+ fail "$filename compilation"
return 0
}
- pass "$name.c compilation"
+ pass "$filename compilation"
return 1
}
Index: testsuite/libjava.jni/PR15133.out
===================================================================
--- testsuite/libjava.jni/PR15133.out 2004-04-30 12:08:54.000000000 +0530
+++ testsuite/libjava.jni/PR15133.out 2004-04-30 12:08:44.000000000 +0530
@@ -0,0 +1 @@
+1729
Index: testsuite/libjava.jni/PR15133.java
===================================================================
--- testsuite/libjava.jni/PR15133.java 2004-04-30 12:08:58.000000000 +0530
+++ testsuite/libjava.jni/PR15133.java 2004-04-30 12:08:35.000000000 +0530
@@ -0,0 +1,14 @@
+/* Test case for PR java/15133 */
+public class PR15133
+{
+ public void printIt (String dummy) { }
+
+ public native void printIt (int num);
+
+ public static void main (String[] args)
+ {
+ System.loadLibrary ("PR15133");
+
+ new PR15133( ).printIt( 1729);
+ }
+}
Index: testsuite/libjava.jni/PR15133.c
===================================================================
--- testsuite/libjava.jni/PR15133.c 2004-04-30 12:09:01.000000000 +0530
+++ testsuite/libjava.jni/PR15133.c 2004-04-30 12:08:32.000000000 +0530
@@ -0,0 +1,9 @@
+#include <stdio.h>
+#include <jni.h>
+#include "PR15133.h"
+
+JNIEXPORT void JNICALL
+Java_PR15133_printIt (JNIEnv *env, jobject x, jint y)
+{
+ printf ("%d\n", y);
+}