When exception is thrown out of main then we should print that
exception (printing support is preliminary yet). The process should be
terminated with non-zero exit status to indicate the failure.

Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
 include/vm/stack-trace.h |    1 +
 vm/jato.c                |   10 ++++++++++
 vm/stack-trace.c         |    6 ++++++
 3 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/include/vm/stack-trace.h b/include/vm/stack-trace.h
index b8e4894..8759ced 100644
--- a/include/vm/stack-trace.h
+++ b/include/vm/stack-trace.h
@@ -46,5 +46,6 @@ struct vm_object * __vm_native 
vm_throwable_get_stack_trace(struct vm_object *,
 void set_throwable_vmstate(struct vm_object *throwable, struct vm_object 
*vmstate);
 
 bool called_from_jit_trampoline(struct native_stack_frame *frame);
+void vm_print_exception(struct vm_object *exception);
 
 #endif /* JATO_VM_STACK_TRACE_H */
diff --git a/vm/jato.c b/vm/jato.c
index 9816759..cc80fb7 100644
--- a/vm/jato.c
+++ b/vm/jato.c
@@ -302,6 +302,16 @@ main(int argc, char *argv[])
                = vm_method_trampoline_ptr(vmm);
        main_method_trampoline();
 
+       if (exception_occurred()) {
+               struct vm_object *exception;
+
+               exception = exception_occurred();
+               clear_exception();
+
+               vm_print_exception(exception);
+               goto out;
+       }
+
        return EXIT_SUCCESS;
 
 out:
diff --git a/vm/stack-trace.c b/vm/stack-trace.c
index 795243c..b36245b 100644
--- a/vm/stack-trace.c
+++ b/vm/stack-trace.c
@@ -407,3 +407,9 @@ void set_throwable_vmstate(struct vm_object *throwable, 
struct vm_object *vmstat
 {
        INST_DATA(throwable)[vmstate_offset] = (uintptr_t)vmstate;
 }
+
+void vm_print_exception(struct vm_object *exception)
+{
+       printf("%s: %s\n", __func__, exception->class->name);
+       NOT_IMPLEMENTED;
+}
-- 
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