Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
 arch/x86/insn-selector_32.brg |    2 --
 vm/class.c                    |   26 +++++++++++++++++++++-----
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/arch/x86/insn-selector_32.brg b/arch/x86/insn-selector_32.brg
index f900515..8a73256 100644
--- a/arch/x86/insn-selector_32.brg
+++ b/arch/x86/insn-selector_32.brg
@@ -1182,9 +1182,7 @@ stmt:     STMT_ARRAY_CHECK(array_check)
        select_insn(s, tree, reg_insn(INSN_PUSH_REG, index));
        select_insn(s, tree, reg_insn(INSN_PUSH_REG, ref));
        select_insn(s, tree, rel_insn(INSN_CALL_REL, (unsigned long) 
check_array));
-
        method_args_cleanup(s, tree, 2);
-       select_exception_test(s, tree);
 }
 
 stmt:  STMT_IF(reg)
diff --git a/vm/class.c b/vm/class.c
index 90b9184..15fab23 100644
--- a/vm/class.c
+++ b/vm/class.c
@@ -76,13 +76,29 @@ unsigned long is_object_instance_of(struct object *obj, 
struct object *type)
 
 void check_array(struct object *obj, unsigned int index)
 {
-       struct classblock *cb = CLASS_CB(obj->class);
+       unsigned int array_len;
+       struct classblock *cb;
+       char index_str[32];
 
-       if (!IS_ARRAY(cb))
-               abort();
+       cb = CLASS_CB(obj->class);
 
-       if (index >= ARRAY_LEN(obj))
-               abort();
+       if (!IS_ARRAY(cb)) {
+               signal_new_exception("java/lang/RuntimeException",
+                                    "object is not an array");
+               goto throw;
+       }
+
+       array_len = ARRAY_LEN(obj);
+
+       if (index < array_len)
+               return;
+
+       sprintf(index_str, "%d > %d", index, array_len - 1);
+       signal_new_exception("java/lang/ArrayIndexOutOfBoundsException",
+                            index_str);
+
+ throw:
+       throw_from_native(sizeof(struct object *) + sizeof(unsigned int));
 }
 
 void check_cast(struct object *obj, struct object *type)
-- 
1.6.0.6


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to