summaryrefslogtreecommitdiffstats
path: root/libjava/testsuite
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2006-10-18 23:17:04 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2006-10-18 23:17:04 +0000
commitb68dfd9590812041be7f41c9e44877a936bf0b6f (patch)
tree090a052b333feb86cf809ba60ebdc7a86794ff1e /libjava/testsuite
parentdf45db482c1b39f2c39dce63ffabab82e8a68c5c (diff)
downloadppe42-gcc-b68dfd9590812041be7f41c9e44877a936bf0b6f.tar.gz
ppe42-gcc-b68dfd9590812041be7f41c9e44877a936bf0b6f.zip
* testsuite/libjava.jni/register2.java: New file.
* testsuite/libjava.jni/register2.out: New file. * testsuite/libjava.jni/register2.c: New file. * java/lang/natClass.cc (_Jv_GetClassNameUtf8): New function. * java/lang/Class.h (_Jv_GetClassNameUtf8): Declare. * jni.cc (struct NativeMethodCacheEntry): New struct. (nathash): Changed type. (hash): Updated. (nathash_find_slot): Likewise. (nathash_find): Likewise. (natrehash): Likewise. (nathash_add): Likewise. (_Jv_JNI_RegisterNatives): Likewise. (_Jv_LookupJNIMethod): Likewise. Idea from Juerg Lehni <juerg@scratchdisk.com> git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117867 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/testsuite')
-rw-r--r--libjava/testsuite/libjava.jni/register2.c48
-rw-r--r--libjava/testsuite/libjava.jni/register2.java27
-rw-r--r--libjava/testsuite/libjava.jni/register2.out2
3 files changed, 77 insertions, 0 deletions
diff --git a/libjava/testsuite/libjava.jni/register2.c b/libjava/testsuite/libjava.jni/register2.c
new file mode 100644
index 00000000000..1ed10a88a23
--- /dev/null
+++ b/libjava/testsuite/libjava.jni/register2.c
@@ -0,0 +1,48 @@
+#include <stdlib.h>
+#include <assert.h>
+#include <register2.h>
+
+static int
+twentythree (JNIEnv *env, jclass k)
+{
+ return 23;
+}
+
+static int
+oneninetyseven (JNIEnv *env, jclass k)
+{
+ return 197;
+}
+
+JNIEXPORT jint JNICALL
+JNI_OnLoad (JavaVM *vm, void *nothing)
+{
+ JNIEnv *env;
+ JNINativeMethod meth;
+ jclass k;
+ jint r;
+
+ r = (*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_2);
+ assert (r == JNI_OK);
+ k = (*env)->FindClass (env, "register2$I1");
+ assert (k != NULL);
+
+ meth.name = "doit";
+ meth.signature = "()I";
+ meth.fnPtr = twentythree;
+
+ r = (*env)->RegisterNatives (env, k, &meth, 1);
+ assert (r == JNI_OK);
+
+ k = (*env)->FindClass (env, "register2$I2");
+ assert (k != NULL);
+
+ meth.name = "doit";
+ meth.signature = "()I";
+ meth.fnPtr = oneninetyseven;
+
+ r = (*env)->RegisterNatives (env, k, &meth, 1);
+ assert (r == JNI_OK);
+
+ return JNI_VERSION_1_2;
+}
diff --git a/libjava/testsuite/libjava.jni/register2.java b/libjava/testsuite/libjava.jni/register2.java
new file mode 100644
index 00000000000..2d6c56a3b02
--- /dev/null
+++ b/libjava/testsuite/libjava.jni/register2.java
@@ -0,0 +1,27 @@
+// Another test of RegisterNatives.
+// We neglected to track the class name in our internal hash table.
+// This is a regression test for the fix.
+
+public class register2
+{
+ static
+ {
+ System.loadLibrary ("register2");
+ }
+
+ static class I1
+ {
+ public static native int doit ();
+ }
+
+ static class I2
+ {
+ public static native int doit ();
+ }
+
+ public static void main (String[] args)
+ {
+ System.out.println (new I1().doit());
+ System.out.println (new I2().doit());
+ }
+}
diff --git a/libjava/testsuite/libjava.jni/register2.out b/libjava/testsuite/libjava.jni/register2.out
new file mode 100644
index 00000000000..5b90358a22b
--- /dev/null
+++ b/libjava/testsuite/libjava.jni/register2.out
@@ -0,0 +1,2 @@
+23
+197
OpenPOWER on IntegriCloud