1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
From: Gregoire Henry <Gregoire.Henry@pps.jussieu.fr>
Date: Thu, 26 Nov 2009 14:15:43 +0100
Subject: [PATCH] GC global reference fix for JDK 1.6
Starting from JDK 1.6, local references might be cleaned up by the Garbage
Collector at the end of native methods. Since classes representing OCaml types
are long lived for CamlJava, they can't be local references otherwise they will
be collected.
This fix turns references to OCaml type classes into global references.
---
lib/jnistubs.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/lib/jnistubs.c b/lib/jnistubs.c
index 368c03e..5d6b92e 100644
--- a/lib/jnistubs.c
+++ b/lib/jnistubs.c
@@ -735,6 +735,7 @@ static int init_caml_classes(JNIEnv * env)
{
#define INIT_CAML_CLASS(cls,fld,cname,fsig) \
cls = (*env)->FindClass(env, cname); \
+ cls = (*env)->NewGlobalRef(env, cls); \
if (cls == NULL) return -1; \
fld = (*env)->GetFieldID(env, cls, "contents", fsig); \
if (fld == NULL) return -1;
--
|