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]

Re: Recent JNI regression


Tom Tromey wrote:
"Marco" == Marco Trudel <mtrudel@gmx.ch> writes:

Marco> Please consider the attached example.


I turned this into a JNI regression test.
I'm checking it in.

Great! thanks...


Marco


Tom

Index: ChangeLog
from Tom Tromey <tromey@redhat.com>

* testsuite/libjava.jni/init.c: New file. * testsuite/libjava.jni/init.java: New file. * testsuite/libjava.jni/init.out: New file. * testsuite/libjava.jni/init.jar: New file. * testsuite/libjava.jni/init.h: New file. * testsuite/libjava.jni/init$NativeClass.h: New file.

Index: testsuite/libjava.jni/init.c
===================================================================
--- testsuite/libjava.jni/init.c	(revision 0)
+++ testsuite/libjava.jni/init.c	(revision 0)
@@ -0,0 +1,8 @@
+#include <jni.h>
+#include <init$NativeClass.h>
+
+JNIEXPORT void JNICALL
+Java_init_00024NativeClass_printHello(JNIEnv *env, jclass cl)
+{
+	printf("hello\n");
+}
Index: testsuite/libjava.jni/init.h
===================================================================
--- testsuite/libjava.jni/init.h	(revision 0)
+++ testsuite/libjava.jni/init.h	(revision 0)
@@ -0,0 +1,18 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#include <jni.h>
+
+#ifndef __init__
+#define __init__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __init__ */
Index: testsuite/libjava.jni/init$NativeClass.h
===================================================================
--- testsuite/libjava.jni/init$NativeClass.h	(revision 0)
+++ testsuite/libjava.jni/init$NativeClass.h	(revision 0)
@@ -0,0 +1,19 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#include <jni.h>
+
+#ifndef __init_00024NativeClass__
+#define __init_00024NativeClass__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_init_00024NativeClass_printHello (JNIEnv *env, jclass);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __init_00024NativeClass__ */
Index: testsuite/libjava.jni/init.java
===================================================================
--- testsuite/libjava.jni/init.java	(revision 0)
+++ testsuite/libjava.jni/init.java	(revision 0)
@@ -0,0 +1,26 @@
+// Regression test for JNI and static initializers.
+
+public class init
+{
+  public static class NativeClass
+  {
+    static
+    {
+      System.out.println("static initializer 2");
+      System.loadLibrary("init"); // if it's here, this app doesn't work
+    }
+
+    public static native void printHello();
+  }
+
+  static
+  {
+    System.out.println("static initializer 1");
+  }
+
+  public static void main(String[] args)
+  {
+    //System.loadLibrary("test"); // if it's here, this app works
+    NativeClass.printHello();
+  }
+}
Index: testsuite/libjava.jni/init.out
===================================================================
--- testsuite/libjava.jni/init.out	(revision 0)
+++ testsuite/libjava.jni/init.out	(revision 0)
@@ -0,0 +1,3 @@
+static initializer 1
+static initializer 2
+hello
Index: testsuite/libjava.jni/init.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: testsuite/libjava.jni/init.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream



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