Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
 regression/jvm/ExceptionsTest.java |  147 ++++++++++++++++++++++++++++++++++--
 1 files changed, 139 insertions(+), 8 deletions(-)

diff --git a/regression/jvm/ExceptionsTest.java 
b/regression/jvm/ExceptionsTest.java
index 0ec9d05..41dc8ad 100644
--- a/regression/jvm/ExceptionsTest.java
+++ b/regression/jvm/ExceptionsTest.java
@@ -29,13 +29,26 @@ package jvm;
  * @author Tomasz Grabiec
  */
 public class ExceptionsTest extends TestCase {
+    public static int static_field;
+    public int field;
+
+    private void privateMethod() {
+    }
+
+    public void publicMethod() {
+    }
+
+    public static void takeInt(int val) {
+    }
+
     public static void testTryBlockDoesNotThrowAnything() {
-       boolean caught;
-       try {
+        boolean caught;
+        try {
             caught = false;
-       } catch (Exception e) {
+        } catch (Exception e) {
             caught = true;
-       }
+        }
+
         assertFalse(caught);
     }
 
@@ -121,12 +134,119 @@ public class ExceptionsTest extends TestCase {
         } catch (Exception e) {}
     }
 
-    public static void testInvokevirtualOnNullReference() {
+    public static void testInvokespecial() {
+        boolean catched = false;
+        ExceptionsTest test = null;
+
+        try {
+            test.privateMethod();
+        } catch (NullPointerException e) {
+            catched = true;
+        }
+
+        assertTrue(catched);
+    }
+
+    public static void testInvokevirtual() {
+        boolean catched = false;
+        ExceptionsTest test = null;
+
+        try {
+            test.publicMethod();
+        } catch (NullPointerException e) {
+            catched = true;
+        }
+
+        assertTrue(catched);
+    }
+
+    public static void testArrayLoad() {
+        boolean catched = false;
+        Object[] array = null;
+
+        try {
+            array[0].getClass();
+        } catch (NullPointerException e) {
+            catched = true;
+        }
+
+        assertTrue(catched);
+    }
+
+    public static void testArrayStore() {
+        boolean catched = false;
+        Object[] array = null;
+
+        try {
+            array[0] = null;
+        } catch (NullPointerException e) {
+            catched = true;
+        }
+
+        assertTrue(catched);
+    }
+
+    public static void testArraylength() {
+        boolean catched = false;
+        Object[] array = null;
+
+        try {
+            takeInt(array.length);
+        } catch (NullPointerException e) {
+            catched = true;
+        }
+
+        assertTrue(catched);
+    }
+
+    public static void testAthrow() {
+        boolean catched = false;
+        Exception exception = null;
+
+        try {
+            throw exception;
+        } catch (NullPointerException e) {
+            catched = true;
+        } catch (Exception e) {
+        }
+
+        assertTrue(catched);
+    }
+
+    public static void testGetfield() {
+        boolean catched = false;
+        ExceptionsTest test = null;
+
+        try {
+            takeInt(test.field);
+        } catch (NullPointerException e) {
+            catched = true;
+        }
+
+        assertTrue(catched);
+    }
+
+    public static void testPutfield() {
         boolean catched = false;
+        ExceptionsTest test = null;
 
         try {
-            Object o = null;
-            o.getClass();
+            test.field = 1;
+        } catch (NullPointerException e) {
+            catched = true;
+        }
+
+        assertTrue(catched);
+    }
+
+    public static void testMonitorenter() {
+        boolean catched = false;
+        Object mon = null;
+
+        try {
+            synchronized(mon) {
+                takeInt(1);
+            }
         } catch (NullPointerException e) {
             catched = true;
         }
@@ -141,7 +261,18 @@ public class ExceptionsTest extends TestCase {
         testMultipleCatchBlocks();
         testNestedTryCatch();
         testEmptyCatchBlock();
-        testInvokevirtualOnNullReference();
+
+        /* Test run-time exceptions */
+        testInvokespecial();
+        testInvokevirtual();
+        testArrayLoad();
+        testArrayStore();
+        testArraylength();
+        testAthrow();
+        testGetfield();
+        testPutfield();
+        testMonitorenter();
+        /* no test for Monitorexit */
 
         exit();
     }
-- 
1.6.0.6


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to