Check dynamic inline exceptions (generated after actual code).
authortwisti <none@none>
Sun, 7 Mar 2004 17:14:46 +0000 (17:14 +0000)
committertwisti <none@none>
Sun, 7 Mar 2004 17:14:46 +0000 (17:14 +0000)
tests/extest.java
tests/extest.output

index e871de0e16982a4ce899aa0c2a652742ce9447f2..00dd7906bb0c7f178fc6c615dba56cc1299c38d2 100644 (file)
@@ -1,7 +1,7 @@
 public class extest {
     public static void main(String[] argv) {
        try {
-            System.out.print("THROWS: ");
+            System.out.print("throw Exception: ");
            sub();
             System.out.println("failed.");
        } catch (Exception e) {
@@ -9,15 +9,15 @@ public class extest {
        }
 
        try {
-            System.out.print("NATIVE: ");
+            System.out.print("native Exception: ");
             System.arraycopy(null, 1, null, 1, 1);
             System.out.println("failed.");
        } catch (Exception e) {
-           System.out.println("passed");
+           System.out.println("passed.");
        }
 
         try {
-            System.out.print("NULL: ");
+            System.out.print("NullPointerException: ");
             int[] ia = null;
             int i = ia.length;
             System.out.println("failed.");
@@ -26,16 +26,41 @@ public class extest {
        }
 
         try {
-            System.out.print("ARITHMETIC: ");
-            int i = 1;
-            int j = 0;
-            int k = i / j;
+            System.out.print("ArithmeticException: ");
+            int i = 1, j = 0, k = i / j;
             System.out.println("failed.");
         } catch (ArithmeticException e) {
            System.out.println("passed.");
        }
 
-        System.out.println("NULL (without catch): ");
+        try {
+            System.out.print("ArrayIndexOutOfBoundsException: ");
+            int[] ia = new int[1];
+            ia[1] = 1;
+            System.out.println("failed.");
+        } catch (ArrayIndexOutOfBoundsException e) {
+           System.out.println("passed.");
+       }
+
+        try {
+            System.out.print("NegativeArraySizeException: ");
+            int[] ia = new int[-1];
+            System.out.println("failed.");
+        } catch (NegativeArraySizeException e) {
+           System.out.println("passed.");
+       }
+        
+        try {
+            System.out.print("ClassCastException: ");
+            Object o = new Object();
+            Integer i = null;
+            i = (Integer) o;
+            System.out.println("failed.");
+        } catch (ClassCastException e) {
+           System.out.println("passed.");
+       }
+        
+        System.out.println("NullPointerException (without catch): ");
         String s = null;
         int i = s.length();
         System.out.println("failed.");
index aa4291b0c8ebab7b16fb9238db2baf3f9769d787..c25355e3d3576387ef2d218fe45736cccc644be3 100644 (file)
@@ -1,6 +1,9 @@
-THROWS: passed.
-NATIVE: passed
-NULL: passed.
-ARITHMETIC: passed.
-NULL (without catch): 
-Exception in thread "main" java/lang/NullPointerException
+throw Exception: passed.
+native Exception: passed.
+NullPointerException: passed.
+ArithmeticException: passed.
+ArrayIndexOutOfBoundsException: passed.
+NegativeArraySizeException: passed.
+ClassCastException: passed.
+NullPointerException (without catch): 
+Exception in thread "main" java.lang.NullPointerException