File: 0005-debugging-facility-for-Java-exceptions.patch

package info (click to toggle)
camljava 0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, stretch, wheezy
  • size: 260 kB
  • ctags: 259
  • sloc: ansic: 813; ml: 333; java: 302; makefile: 86
file content (71 lines) | stat: -rw-r--r-- 1,842 bytes parent folder | download
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
From: Gregoire Henry <Gregoire.Henry@pps.jussieu.fr>
Date: Sat, 28 Nov 2009 10:15:23 +0100
Subject: [PATCH] debugging facility for Java exceptions

debugging is togglable at runtime, without needing to recompile CamlJava
---
 lib/jni.mli    |    2 ++
 lib/jni.mlp    |    2 ++
 lib/jnistubs.c |   15 +++++++++++----
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/lib/jni.mli b/lib/jni.mli
index 2a593f0..ad829b3 100644
--- a/lib/jni.mli
+++ b/lib/jni.mli
@@ -14,6 +14,8 @@
 
 (* Low-level Java interface (JNI level) *)
 
+external set_debug: bool -> unit = "camljava_set_debug"
+
 (* Object operations *)
 
 type obj
diff --git a/lib/jni.mlp b/lib/jni.mlp
index 9005e65..d1febac 100644
--- a/lib/jni.mlp
+++ b/lib/jni.mlp
@@ -14,6 +14,8 @@
 
 (* Low-level Java interface (JNI level) *)
 
+external set_debug: bool -> unit = "camljava_set_debug"
+
 external init: string -> unit = "camljava_Init"
 external shutdown: unit -> unit = "camljava_Shutdown"
 
diff --git a/lib/jnistubs.c b/lib/jnistubs.c
index e1659f8..27ff365 100644
--- a/lib/jnistubs.c
+++ b/lib/jnistubs.c
@@ -74,6 +74,13 @@ value camljava_IsNull(value vobj)
 
 /*********** Reflecting Java exceptions as Caml exceptions *************/
 
+static int debug = 0;
+
+value camljava_set_debug(value v) {
+  debug = Bool_val(v);
+  return Val_unit;
+}
+
 static void check_java_exception(void)
 {
   jthrowable exn;
@@ -82,10 +89,10 @@ static void check_java_exception(void)
 
   exn = (*jenv)->ExceptionOccurred(jenv);
   if (exn != NULL) {
-#if 0
-    /* For debugging */
-    (*jenv)->ExceptionDescribe(jenv);
-#endif
+    if(debug) {
+      /* For debugging */
+      (*jenv)->ExceptionDescribe(jenv);
+    }
     (*jenv)->ExceptionClear(jenv);
     /* TODO: check Caml exception embedded into Java exception */
     if (camljava_raise_exception == NULL) {
--