When vm_print_exception() is called from JNI then exception
that is printed is signalled. Therefore we have to clear exceptions
before printing to be able to detect when exception is thrown
from printing code.

Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
 vm/stack-trace.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/vm/stack-trace.c b/vm/stack-trace.c
index 45f625b..30c0595 100644
--- a/vm/stack-trace.c
+++ b/vm/stack-trace.c
@@ -710,12 +710,16 @@ static void vm_print_exception_description(struct 
vm_object *exception)
 
 void vm_print_exception(struct vm_object *exception)
 {
+       struct vm_object *old_exception;
        struct string *str;
 
        str = alloc_str();
        if (!str)
                goto error;
 
+       old_exception = exception_occurred();
+       clear_exception();
+
        /* TODO: print correct thread name */
        str_append(str, "Exception in thread \"main\" ");
 
@@ -726,6 +730,9 @@ void vm_print_exception(struct vm_object *exception)
        fprintf(stderr, "%s", str->value);
        free_str(str);
 
+       if (old_exception)
+               signal_exception(old_exception);
+
        return;
 error:
        warn("unable to print exception");
-- 
1.6.0.6


------------------------------------------------------------------------------
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to