Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
 jit/emulate.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/jit/emulate.c b/jit/emulate.c
index 28e98d8..bfae22e 100644
--- a/jit/emulate.c
+++ b/jit/emulate.c
@@ -24,7 +24,9 @@
  * Please refer to the file LICENSE for details.
  */
 
+#include <jit/exception.h>
 #include <jit/emulate.h>
+#include <vm/class.h>
 
 int emulate_lcmp(long long value1, long long value2)
 {
@@ -39,10 +41,26 @@ int emulate_lcmp(long long value1, long long value2)
 
 long long emulate_ldiv(long long value1, long long value2)
 {
+       if (value2 == 0) {
+               struct object *exception = new_exception(
+                   "java/lang/ArithmeticException", "division by zero");
+
+               signal_exception(exception);
+               return 0;
+       }
+
        return value1 / value2;
 }
 
 long long emulate_lrem(long long value1, long long value2)
 {
+       if (value2 == 0) {
+               struct object *exception = new_exception(
+                   "java/lang/ArithmeticException", "division by zero");
+
+               signal_exception(exception);
+               return 0;
+       }
+
        return value1 % value2;
 }
-- 
1.6.0.6


------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to