I can reduce my real problem to the attached class and native metbod.
We are simply creating a weak reference to the class then releasing it
once we have finished with it. Deleting the weak reference aborts the
program!
Hello, world from java first
Got weak reference
kaffe-bin: jni-refs.c:290: KaffeJNI_DeleteWeakGlobalRef: Assertion
`((main_collector)->ops->getObjectIndex)((Collector*)(main_collector), (
ref)) == KGC_ALLOC_VMWEAKREF' failed.
Program received signal SIGABRT, Aborted.
kaffe -version
java full version "kaffe-1.4.2"
kaffe VM "1.1.7"
Engine: Just-in-time v3 Version: 1.1.7 Java Version: 1.4
Heap defaults: minimum size: 5 MB, maximum size: unlimited
Stack default size: 256 KB
Compiled under
gcc --version
gcc (GCC) 4.0.2 20050901 (prerelease) (SUSE Linux)
NB we have fixed bug 60 locally.
--
Tim Bevan,
Principal Software Engineer, Laser-Scan.
+44 (0)1223 420 414
http://www.laser-scan.com
public class HelloWorldNative{
private native void print();
public static void main(String[] args) {
System.out.println("Hello, world from java first");
new HelloWorldNative().print();
System.out.println("Hello, world from java again");
}
static {
System.loadLibrary("HelloWorldNative");
}
}
/*gcc -shared HelloWorldNative.c -o libHelloWorldNative.so $JNI_INCLUDES*/
#include <jni.h>
#include <stdio.h>
#include "HelloWorldNative.h"
JNIEXPORT void JNICALL
Java_HelloWorldNative_print(JNIEnv *env, jobject obj)
{
jclass cls;
jweak hint;
/* get the class */
cls = (*env)->GetObjectClass(env, obj);
/* get a WEAK reference to the class */
hint = (*env)->NewWeakGlobalRef(env,cls);
printf("Got weak reference\n");
(*env)->DeleteWeakGlobalRef(env,hint);
printf("dumped weak reference\n");
}
_______________________________________________
kaffe mailing list
[email protected]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe