[kaffe] CVS kaffe (guilhem): Added some new tests for JNI weak ref.
Kaffe CVS
cvs-commits at kaffe.org
Wed Jul 13 13:20:57 PDT 2005
PatchSet 6727
Date: 2005/07/13 20:16:12
Author: guilhem
Branch: HEAD
Tag: (none)
Log:
Added some new tests for JNI weak ref.
* test/jni/JNIWeakTest.java: New tests.
* test/jni/jniweaklib.c: Added support functions for the new tests.
Members:
ChangeLog:1.4251->1.4252
test/jni/JNIWeakTest.java:1.1->1.2
test/jni/jniweaklib.c:1.1->1.2
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4251 kaffe/ChangeLog:1.4252
--- kaffe/ChangeLog:1.4251 Wed Jul 13 13:31:07 2005
+++ kaffe/ChangeLog Wed Jul 13 20:16:12 2005
@@ -1,5 +1,11 @@
2004-07-13 Guilhem Lavaux <guilhem at kaffe.org>
+ * test/jni/JNIWeakTest.java: New tests.
+
+ * test/jni/jniweaklib.c: Added support functions for the new tests.
+
+2004-07-13 Guilhem Lavaux <guilhem at kaffe.org>
+
* TODO: Added some TODO entries.
* kaffe/kaffe/main.c
Index: kaffe/test/jni/JNIWeakTest.java
diff -u kaffe/test/jni/JNIWeakTest.java:1.1 kaffe/test/jni/JNIWeakTest.java:1.2
--- kaffe/test/jni/JNIWeakTest.java:1.1 Tue Jul 12 23:50:52 2005
+++ kaffe/test/jni/JNIWeakTest.java Wed Jul 13 20:16:16 2005
@@ -1,3 +1,13 @@
+/*
+ * JNIWeakTest.java -- Test the handling of JNI weak reference.
+ *
+ * Copyright (C) 2005
+ * The Kaffe.org's developers. See ChangeLog for details.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file.
+ */
+
public class JNIWeakTest
{
static {
@@ -7,6 +17,23 @@
native Object testWeak();
+ static void testArgWeak(Object a, Object b)
+ {
+ if (a == b)
+ System.out.println("Args OK !");
+ else
+ System.out.println("Args FAIL !");
+ }
+
+ void testInvoke()
+ {
+ System.out.println("Invoke OK !");
+ }
+
+ static native void passWeakArg(Object a);
+
+ static native void invokeWeak(Object a);
+
static public void main(String args[])
{
JNIWeakTest o = new JNIWeakTest();
@@ -15,9 +42,13 @@
o2 = o.testWeak();
if (o2 == o)
- System.out.println("OK !");
+ System.out.println("Return OK !");
else
- System.out.println("FAIL !");
+ System.out.println("Return FAIL !");
+
+ passWeakArg(new Object());
+
+ invokeWeak(o);
}
}
Index: kaffe/test/jni/jniweaklib.c
diff -u kaffe/test/jni/jniweaklib.c:1.1 kaffe/test/jni/jniweaklib.c:1.2
--- kaffe/test/jni/jniweaklib.c:1.1 Tue Jul 12 23:50:52 2005
+++ kaffe/test/jni/jniweaklib.c Wed Jul 13 20:16:16 2005
@@ -1,3 +1,13 @@
+/*
+ * jniweaklib.c -- Test the handling of JNI weak reference.
+ *
+ * Copyright (C) 2005
+ * The Kaffe.org's developers. See ChangeLog for details.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file.
+ */
+
#include <jni.h>
JNIEXPORT jobject JNICALL
@@ -5,3 +15,26 @@
{
return (*env)->NewWeakGlobalRef(env, obj);
}
+
+JNIEXPORT void JNICALL
+Java_JNIWeakTest_passWeakArg(JNIEnv *env, jclass clazz,
+ jobject o)
+{
+ jmethodID weak_fun = (*env)->GetStaticMethodID(env, clazz, "testArgWeak",
+ "(Ljava/lang/Object;Ljava/lang/Object;)V");
+ jweak wo = (*env)->NewWeakGlobalRef(env, o);
+
+ (*env)->CallStaticVoidMethod(env, clazz, weak_fun, wo, o);
+
+}
+
+JNIEXPORT void JNICALL
+Java_JNIWeakTest_invokeWeak(JNIEnv *env, jclass clazz,
+ jobject o)
+{
+ jmethodID weak_fun = (*env)->GetMethodID(env, clazz, "testInvoke",
+ "()V");
+ jweak wo = (*env)->NewWeakGlobalRef(env, o);
+
+ (*env)->CallVoidMethod(env, wo, weak_fun);
+}
More information about the kaffe
mailing list