re PR java/15133 (gcjh generates wrong method signatures)
authorRanjit Mathew <rmathew@hotmail.com>
Fri, 30 Apr 2004 18:19:37 +0000 (18:19 +0000)
committerRanjit Mathew <rmathew@gcc.gnu.org>
Fri, 30 Apr 2004 18:19:37 +0000 (18:19 +0000)
* 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.

Co-Authored-By: Tom Tromey <tromey@redhat.com>
From-SVN: r81358

libjava/ChangeLog
libjava/testsuite/libjava.jni/PR15133.c [new file with mode: 0644]
libjava/testsuite/libjava.jni/PR15133.java [new file with mode: 0644]
libjava/testsuite/libjava.jni/PR15133.out [new file with mode: 0644]
libjava/testsuite/libjava.jni/jni.exp

index d62ca38520b226b3d4ef32332efc9f5b863e9ea5..e2968ca346f6de7cb71aab35f650101c4412a6f3 100644 (file)
@@ -1,3 +1,13 @@
+2004-04-30  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.
+
 2004-04-30  Roger Sayle  <roger@eyesopen.com>
 
        * testsuite/libjava.lang/MathBuiltin.java: Add tests for acos, asin,
diff --git a/libjava/testsuite/libjava.jni/PR15133.c b/libjava/testsuite/libjava.jni/PR15133.c
new file mode 100644 (file)
index 0000000..be5a48e
--- /dev/null
@@ -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);
+}
diff --git a/libjava/testsuite/libjava.jni/PR15133.java b/libjava/testsuite/libjava.jni/PR15133.java
new file mode 100644 (file)
index 0000000..9043576
--- /dev/null
@@ -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);
+  }
+}
diff --git a/libjava/testsuite/libjava.jni/PR15133.out b/libjava/testsuite/libjava.jni/PR15133.out
new file mode 100644 (file)
index 0000000..32bb421
--- /dev/null
@@ -0,0 +1 @@
+1729
index 7dad519d415380d43116439bef7159b4b84e28af..a4bf4b80ee1abfbbed14f398724f8caffff5a2de 100644 (file)
@@ -21,12 +21,21 @@ proc gcj_jni_compile_c_to_so {file {options {}}} {
       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 {options {}}} {
           [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
 }