Fix opcode tests for check_cast and filled_new_array_range.

Updated test to verify froyo vm behaviur of throwing exceptions at first
access.

Bug 3147582

Change-Id: Ic0ffc1b7e058ed8c5f8643b8ac39ce95f96ec124
diff --git a/tools/vm-tests/src/dot/junit/opcodes/check_cast/TestStubs.java b/tools/vm-tests/src/dot/junit/opcodes/check_cast/TestStubs.java
index 53af56d..67f8f04 100644
--- a/tools/vm-tests/src/dot/junit/opcodes/check_cast/TestStubs.java
+++ b/tools/vm-tests/src/dot/junit/opcodes/check_cast/TestStubs.java
@@ -16,12 +16,5 @@
 
 package dot.junit.opcodes.check_cast;
 
-public class TestStubs {
-    @SuppressWarnings("unused")
-    private class TestStub {
-        // used by testVFE5
-        public void foo() {
-            
-        }
-    } 
+class TestStubs {
 }
diff --git a/tools/vm-tests/src/dot/junit/opcodes/check_cast/Test_check_cast.java b/tools/vm-tests/src/dot/junit/opcodes/check_cast/Test_check_cast.java
index ea9e38c..78a0479 100644
--- a/tools/vm-tests/src/dot/junit/opcodes/check_cast/Test_check_cast.java
+++ b/tools/vm-tests/src/dot/junit/opcodes/check_cast/Test_check_cast.java
@@ -20,6 +20,8 @@
 import dot.junit.DxUtil;
 import dot.junit.opcodes.check_cast.d.T_check_cast_1;
 import dot.junit.opcodes.check_cast.d.T_check_cast_2;
+import dot.junit.opcodes.check_cast.d.T_check_cast_3;
+import dot.junit.opcodes.check_cast.d.T_check_cast_7;
 
 
 public class Test_check_cast extends DxTestCase {
@@ -118,34 +120,34 @@
         }
     }
 
-   
     /**
      * @constraint n/a
-     * @title Attempt to access inaccessible class. Java throws IllegalAccessError 
-     * on first access but Dalvik throws VerifyError on class loading.
-     */    
+     * @title Attempt to access inaccessible class, expect throws IllegalAccessError
+     */
     public void testVFE5() {
         //@uses dot.junit.opcodes.check_cast.TestStubs
         //@uses dot.junit.opcodes.check_cast.d.T_check_cast_3
+        T_check_cast_3 t = new T_check_cast_3();
         try {
-            Class.forName("dot.junit.opcodes.check_cast.d.T_check_cast_3");
-            fail("expected a verification exception");
-        } catch (Throwable t) {
-            DxUtil.checkVerifyException(t);
+            t.run();
+            fail("expected IllegalAccessError");
+        } catch (IllegalAccessError iae) {
+            // expected
         }
     }
 
     /**
      * @constraint n/a
-     * @title Attempt to access undefined class. Java throws NoClassDefFoundError on 
-     * first access but Dalvik throws VerifyError on class loading.
-     */    
+     * @title Attempt to access undefined class, expect throws NoClassDefFoundError on
+     * first access
+     */
     public void testVFE6() {
+        T_check_cast_7 t = new T_check_cast_7();
         try {
-            Class.forName("dot.junit.opcodes.check_cast.d.T_check_cast_7");
-            fail("expected a verification exception");
-        } catch (Throwable t) {
-            DxUtil.checkVerifyException(t);
+            t.run();
+            fail("expected NoClassDefFoundError");
+        } catch (NoClassDefFoundError iae) {
+            // expected
         }
     }
     
diff --git a/tools/vm-tests/src/dot/junit/opcodes/check_cast/d/T_check_cast_3.d b/tools/vm-tests/src/dot/junit/opcodes/check_cast/d/T_check_cast_3.d
index 5b5dea0..d269a31 100644
--- a/tools/vm-tests/src/dot/junit/opcodes/check_cast/d/T_check_cast_3.d
+++ b/tools/vm-tests/src/dot/junit/opcodes/check_cast/d/T_check_cast_3.d
@@ -26,7 +26,7 @@
 
 .method public run()V
 .limit regs 6
-       check-cast v5, dot/junit/opcodes/check_cast/Test_check_cast$TestStub
+       check-cast v5, dot/junit/opcodes/check_cast/TestStubs
        return-void
 .end method
 
diff --git a/tools/vm-tests/src/dot/junit/opcodes/filled_new_array_range/TestStubs.java b/tools/vm-tests/src/dot/junit/opcodes/filled_new_array_range/TestStubs.java
index d38808e..47b87e4 100644
--- a/tools/vm-tests/src/dot/junit/opcodes/filled_new_array_range/TestStubs.java
+++ b/tools/vm-tests/src/dot/junit/opcodes/filled_new_array_range/TestStubs.java
@@ -16,9 +16,6 @@
 
 package dot.junit.opcodes.filled_new_array_range;
 
-public class TestStubs {
-    @SuppressWarnings("unused")
-    private class TestStub{
-        // used by T_filled_new_array_range_11
-    }
+// used by T_filled_new_array_range_11
+class TestStubs {
 }
diff --git a/tools/vm-tests/src/dot/junit/opcodes/filled_new_array_range/Test_filled_new_array_range.java b/tools/vm-tests/src/dot/junit/opcodes/filled_new_array_range/Test_filled_new_array_range.java
index b69d5b4..84b1379 100644
--- a/tools/vm-tests/src/dot/junit/opcodes/filled_new_array_range/Test_filled_new_array_range.java
+++ b/tools/vm-tests/src/dot/junit/opcodes/filled_new_array_range/Test_filled_new_array_range.java
@@ -19,8 +19,9 @@
 import dot.junit.DxTestCase;
 import dot.junit.DxUtil;
 import dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_1;
+import dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_10;
+import dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_11;
 import dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_2;
-import dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_9;
 
 public class Test_filled_new_array_range extends DxTestCase {
     /**
@@ -140,31 +141,32 @@
     }
     
     /**
-     * @constraint n/a 
+     * @constraint n/a
      * @title attempt to instantiate array of non-existent class
      */
     public void testVFE8() {
+        T_filled_new_array_range_10 t = new T_filled_new_array_range_10();
         try {
-        	Class.forName("dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_10");
-        	fail("expected a verification exception");
-        } catch(Throwable t) {
-        	DxUtil.checkVerifyException(t);	
+            t.run();
+            fail("expected NoClassDefFoundError exception");
+        } catch (NoClassDefFoundError e) {
+            // expected
         }
     }
-    
+
     /**
-     * @constraint n/a 
+     * @constraint n/a
      * @title attempt to instantiate array of inaccessible class
      */
     public void testVFE9() {
-    	//@uses dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_11
+        //@uses dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_11
         //@uses dot.junit.opcodes.filled_new_array_range.TestStubs
+        T_filled_new_array_range_11 t = new T_filled_new_array_range_11();
         try {
-        	Class.forName("dot.junit.opcodes.filled_new_array_range.d.T_filled_new_array_range_11");
-        	fail("expected a verification exception");
-        } catch(Throwable t) {
-        	DxUtil.checkVerifyException(t);	
+            t.run();
+            fail("expected IllegalAccessError exception");
+        } catch (IllegalAccessError e) {
+            // expected
         }
     }
-    
 }
diff --git a/tools/vm-tests/src/dot/junit/opcodes/filled_new_array_range/d/T_filled_new_array_range_10.java b/tools/vm-tests/src/dot/junit/opcodes/filled_new_array_range/d/T_filled_new_array_range_10.java
new file mode 100644
index 0000000..57075bd
--- /dev/null
+++ b/tools/vm-tests/src/dot/junit/opcodes/filled_new_array_range/d/T_filled_new_array_range_10.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package dot.junit.opcodes.filled_new_array_range.d;
+
+public class T_filled_new_array_range_10 {
+    public Object[] run() {
+        return null;
+    }
+}
diff --git a/tools/vm-tests/src/dot/junit/opcodes/filled_new_array_range/d/T_filled_new_array_range_11.d b/tools/vm-tests/src/dot/junit/opcodes/filled_new_array_range/d/T_filled_new_array_range_11.d
index a628f07..e3a21e9 100644
--- a/tools/vm-tests/src/dot/junit/opcodes/filled_new_array_range/d/T_filled_new_array_range_11.d
+++ b/tools/vm-tests/src/dot/junit/opcodes/filled_new_array_range/d/T_filled_new_array_range_11.d
@@ -27,7 +27,7 @@
 .method public run()[Ljava/lang/Object;
 .limit regs 10
     const v9, 0
-    filled-new-array/range {v9}, [Ldot/junit/opcodes/filled_new_array_range/TestStubs$TestStub;
+    filled-new-array/range {v9}, [Ldot/junit/opcodes/filled_new_array_range/TestStubs;
     move-result-object v0
     return-object v0
 .end method
diff --git a/tools/vm-tests/src/dot/junit/opcodes/filled_new_array_range/d/T_filled_new_array_range_11.java b/tools/vm-tests/src/dot/junit/opcodes/filled_new_array_range/d/T_filled_new_array_range_11.java
new file mode 100644
index 0000000..f4ca611
--- /dev/null
+++ b/tools/vm-tests/src/dot/junit/opcodes/filled_new_array_range/d/T_filled_new_array_range_11.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package dot.junit.opcodes.filled_new_array_range.d;
+
+public class T_filled_new_array_range_11 {
+    public Object[] run() {
+        return null;
+    }
+}
diff --git a/tools/vm-tests/src/util/build/BuildDalvikSuite.java b/tools/vm-tests/src/util/build/BuildDalvikSuite.java
index af130b6..ff89022 100644
--- a/tools/vm-tests/src/util/build/BuildDalvikSuite.java
+++ b/tools/vm-tests/src/util/build/BuildDalvikSuite.java
@@ -532,7 +532,7 @@
 
         File sourceFolder = new File(JAVASRC_FOLDER);
         String fileName = dependentTestClassName.replace('.', '/').trim();
-
+        
         if (new File(sourceFolder, fileName + ".dfh").exists()) {
 
             BuildStep.BuildFile inputFile = new BuildStep.BuildFile(