Patch: JNI field test

Tom Tromey tromey@redhat.com
Thu Mar 22 21:54:00 GMT 2001


I'm checking this in, but only on the trunk.  Since we don't run JNI
tests it isn't important that it be on the branch.

2001-03-22  Tom Tromey  <tromey@redhat.com>

	* libjava.jni/field.out: New file.
	* libjava.jni/field.c: New file.
	* libjava.jni/field.java: New file.

Tom

Index: field.c
===================================================================
RCS file: field.c
diff -N field.c
--- /dev/null	Tue May  5 13:32:27 1998
+++ field.c	Thu Mar 22 21:51:11 2001
@@ -0,0 +1,24 @@
+#include <jni.h>
+#include <field.h>
+
+jobjectArray
+Java_field_fetch (JNIEnv *env, jobject this)
+{
+  jclass cls;
+  jfieldID fid;
+  jobjectArray obj;
+
+  cls = (*env)->GetObjectClass (env, this);
+  if (! cls)
+    return 0;
+
+  fid = (*env)->GetFieldID (env, cls, "F", "[Ljava/lang/Object;");
+  if (! fid)
+    return 0;
+
+  obj = (*env)->GetObjectField (env, this, fid);
+
+  return obj;
+}
+
+
Index: field.java
===================================================================
RCS file: field.java
diff -N field.java
--- /dev/null	Tue May  5 13:32:27 1998
+++ field.java	Thu Mar 22 21:51:11 2001
@@ -0,0 +1,25 @@
+// Test for array field lookup.
+
+public class field
+{
+  // A field for us to look up.
+  public Object[] F = new Object[7];
+
+  public native Object[] fetch ();
+
+  public void doit ()
+  {
+    System.out.println (F == fetch ());
+  }
+
+  public static void main (String[] args)
+  {
+    field q = new field ();
+    q.doit ();
+  }
+
+  static
+  {
+    System.loadLibrary ("field");
+  }
+}
Index: field.out
===================================================================
RCS file: field.out
diff -N field.out
--- /dev/null	Tue May  5 13:32:27 1998
+++ field.out	Thu Mar 22 21:51:11 2001
@@ -0,0 +1 @@
+true



More information about the Java-patches mailing list