am c44ffdf9: Merge "Fix opcode tests for new_array and new_instance" into froyo
* commit 'c44ffdf940e05122d1cf006f57247932e447f48a':
Fix opcode tests for new_array and new_instance
diff --git a/tools/vm-tests/src/dot/junit/opcodes/new_array/TestStubs.java b/tools/vm-tests/src/dot/junit/opcodes/new_array/TestStubs.java
new file mode 100644
index 0000000..587b4d1
--- /dev/null
+++ b/tools/vm-tests/src/dot/junit/opcodes/new_array/TestStubs.java
@@ -0,0 +1,21 @@
+/*
+ * 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.new_array;
+
+// package access to trigger IllegalAccessError in testVFE8
+class TestStubs {
+}
diff --git a/tools/vm-tests/src/dot/junit/opcodes/new_array/Test_new_array.java b/tools/vm-tests/src/dot/junit/opcodes/new_array/Test_new_array.java
index d474ec1..44aedaa 100644
--- a/tools/vm-tests/src/dot/junit/opcodes/new_array/Test_new_array.java
+++ b/tools/vm-tests/src/dot/junit/opcodes/new_array/Test_new_array.java
@@ -19,16 +19,13 @@
import dot.junit.DxTestCase;
import dot.junit.DxUtil;
import dot.junit.opcodes.new_array.d.T_new_array_1;
+import dot.junit.opcodes.new_array.d.T_new_array_10;
+import dot.junit.opcodes.new_array.d.T_new_array_11;
import dot.junit.opcodes.new_array.d.T_new_array_2;
import dot.junit.opcodes.new_array.d.T_new_array_3;
public class Test_new_array extends DxTestCase {
-
- @SuppressWarnings("unused")
- private class TestStub{
- // used by testVFE8
- }
-
+
/**
* @title Array of ints
*/
@@ -59,7 +56,7 @@
assertFalse(r[i]);
}
}
-
+
/**
* @title Array of Objects
*/
@@ -74,7 +71,7 @@
assertNull(r[i]);
}
}
-
+
/**
* @title Array size = 0
*/
@@ -83,7 +80,7 @@
int[] r = t.run(0);
assertNotNull(r);
assertEquals(0, r.length);
- }
+ }
/**
* @title expected NegativeArraySizeException
@@ -97,10 +94,10 @@
// expected
}
}
-
+
/**
- * @constraint B1
+ * @constraint B1
* @title number of registers
*/
public void testVFE1() {
@@ -113,8 +110,8 @@
}
/**
- *
- * @constraint B1
+ *
+ * @constraint B1
* @title size argument - long
*/
public void testVFE2() {
@@ -125,9 +122,9 @@
DxUtil.checkVerifyException(t);
}
}
-
+
/**
- *
+ *
* @constraint B1
* @title size argument - reference
*/
@@ -141,8 +138,8 @@
}
/**
- *
- * @constraint A19
+ *
+ * @constraint A19
* @title constant pool index
*/
public void testVFE4() {
@@ -155,8 +152,8 @@
}
/**
- *
- * @constraint A22
+ *
+ * @constraint A22
* @title attempt to create object
*/
public void testVFE5() {
@@ -167,10 +164,10 @@
DxUtil.checkVerifyException(t);
}
}
-
+
/**
- *
- * @constraint A20
+ *
+ * @constraint A20
* @title array of more than 255 dimensions
*/
public void testVFE6() {
@@ -181,33 +178,30 @@
DxUtil.checkVerifyException(t);
}
}
-
+
/**
* @constraint n/a
- * @title Attempt to instantiate array of non-existent class. Java
- * throws NoClassDefFoundError on first access but Dalvik throws VerifyError on class loading.
+ * @title Attempt to instantiate array of non-existent class.
*/
public void testVFE7() {
try {
- Class.forName("dot.junit.opcodes.new_array.d.T_new_array_11");
- fail("expected a verification exception");
- } catch (Throwable t) {
- DxUtil.checkVerifyException(t);
+ new T_new_array_11().run();
+ fail("expected NoClassDefFoundError");
+ } catch (NoClassDefFoundError t) {
}
}
-
+
/**
* @constraint n/a
- * @title Attempt to instantiate array of inaccessible class. Java
- * throws IllegalAccessError on first access but Dalvik throws VerifyError on class loading.
+ * @title Attempt to instantiate array of inaccessible class.
*/
public void testVFE8() {
+ //@uses dot.junit.opcodes.new_array.TestStubs
try {
- Class.forName("dot.junit.opcodes.new_array.d.T_new_array_10");
- fail("expected a verification exception");
- } catch (Throwable t) {
- DxUtil.checkVerifyException(t);
+ new T_new_array_10().run();
+ fail("expected IllegalAccessError");
+ } catch (IllegalAccessError t) {
}
}
-
+
}
diff --git a/tools/vm-tests/src/dot/junit/opcodes/new_array/d/T_new_array_10.d b/tools/vm-tests/src/dot/junit/opcodes/new_array/d/T_new_array_10.d
index bcd570b..4c99085 100644
--- a/tools/vm-tests/src/dot/junit/opcodes/new_array/d/T_new_array_10.d
+++ b/tools/vm-tests/src/dot/junit/opcodes/new_array/d/T_new_array_10.d
@@ -28,7 +28,7 @@
.limit regs 5
const v0, 3
- new-array v0, v0, [Ldot/junit/opcodes/new_array/Test_new_array$TestStub;
+ new-array v0, v0, [Ldot/junit/opcodes/new_array/TestStubs;
return-object v0
.end method
diff --git a/tools/vm-tests/src/dot/junit/opcodes/new_array/d/T_new_array_10.java b/tools/vm-tests/src/dot/junit/opcodes/new_array/d/T_new_array_10.java
new file mode 100644
index 0000000..81b7a7e
--- /dev/null
+++ b/tools/vm-tests/src/dot/junit/opcodes/new_array/d/T_new_array_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.new_array.d;
+
+public class T_new_array_10 {
+ public Object[] run() {
+ return null;
+ }
+}
diff --git a/tools/vm-tests/src/dot/junit/opcodes/new_array/d/T_new_array_11.java b/tools/vm-tests/src/dot/junit/opcodes/new_array/d/T_new_array_11.java
new file mode 100644
index 0000000..e37e1ec
--- /dev/null
+++ b/tools/vm-tests/src/dot/junit/opcodes/new_array/d/T_new_array_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.new_array.d;
+
+public class T_new_array_11 {
+ public Object[] run() {
+ return null;
+ }
+}
diff --git a/tools/vm-tests/src/dot/junit/opcodes/new_instance/TestStubs.java b/tools/vm-tests/src/dot/junit/opcodes/new_instance/TestStubs.java
index 9cba0ea..ca22946 100644
--- a/tools/vm-tests/src/dot/junit/opcodes/new_instance/TestStubs.java
+++ b/tools/vm-tests/src/dot/junit/opcodes/new_instance/TestStubs.java
@@ -16,9 +16,6 @@
package dot.junit.opcodes.new_instance;
-public class TestStubs {
- @SuppressWarnings("unused")
- private class TestStub {
- // used by testVFE5
- }
-}
\ No newline at end of file
+// package access to trigger IllegalAccessError in testVFE5
+class TestStubs {
+}
diff --git a/tools/vm-tests/src/dot/junit/opcodes/new_instance/Test_new_instance.java b/tools/vm-tests/src/dot/junit/opcodes/new_instance/Test_new_instance.java
index 6a9fcbe..d994f65 100644
--- a/tools/vm-tests/src/dot/junit/opcodes/new_instance/Test_new_instance.java
+++ b/tools/vm-tests/src/dot/junit/opcodes/new_instance/Test_new_instance.java
@@ -20,6 +20,8 @@
import dot.junit.DxUtil;
import dot.junit.opcodes.new_instance.d.T_new_instance_1;
import dot.junit.opcodes.new_instance.d.T_new_instance_3;
+import dot.junit.opcodes.new_instance.d.T_new_instance_4;
+import dot.junit.opcodes.new_instance.d.T_new_instance_5;
import dot.junit.opcodes.new_instance.d.T_new_instance_8;
import dot.junit.opcodes.new_instance.d.T_new_instance_9;
@@ -37,7 +39,7 @@
}
/**
- * @title class initialization throws exception
+ * @title class initialization throws exception
*/
public void testE1() {
try {
@@ -49,7 +51,7 @@
}
/**
- * @constraint A21
+ * @constraint A21
* @title attempt to instantiate interface
*/
public void testE4() {
@@ -65,7 +67,7 @@
}
/**
- * @constraint A21
+ * @constraint A21
* @title attempt to instantiate abstract
* class
*/
@@ -82,7 +84,7 @@
}
/**
- * @constraint A18
+ * @constraint A18
* @title constant pool index
*/
public void testVFE1() {
@@ -95,8 +97,8 @@
}
/**
- *
- * @constraint A21
+ *
+ * @constraint A21
* @title attempt to create array using new
*/
public void testVFE2() {
@@ -121,9 +123,9 @@
DxUtil.checkVerifyException(t);
}
}
-
+
/**
- * @constraint A23
+ * @constraint A23
* @title number of registers
*/
public void testVFE4() {
@@ -134,41 +136,37 @@
DxUtil.checkVerifyException(t);
}
}
-
+
/**
* @constraint n/a
- * @title Attempt to instantiate array of inaccessible class. Java
- * throws IllegalAccessError on first access but Dalvik throws VerifyError on class loading.
+ * @title Attempt to instantiate array of inaccessible class.
*/
public void testVFE5() {
//@uses dot.junit.opcodes.new_instance.TestStubs
//@uses dot.junit.opcodes.new_instance.d.T_new_instance_4
try {
- Class.forName("dot.junit.opcodes.new_instance.d.T_new_instance_4");
- fail("expected a verification exception");
- } catch (Throwable t) {
- DxUtil.checkVerifyException(t);
+ new T_new_instance_4().run();
+ fail("expected IllegalAccessError");
+ } catch (IllegalAccessError t) {
}
}
/**
* @constraint n/a
- * @title Attempt to instantiate array of non-existent class. Java
- * throws NoClassDefFoundError on first access but Dalvik throws VerifyError on class loading.
+ * @title Attempt to instantiate array of non-existent class.
*/
public void testVFE6() {
try {
- Class.forName("dot.junit.opcodes.new_instance.d.T_new_instance_5");
- fail("expected a verification exception");
- } catch (Throwable t) {
- DxUtil.checkVerifyException(t);
+ new T_new_instance_5().run();
+ fail("expected NoClassDefFoundError");
+ } catch (NoClassDefFoundError t) {
}
}
/**
* @constraint B7
- * @title A register which holds the result of a new-instance instruction must not be used
- * if the same new-instance instruction is again executed before the instance is initialized
+ * @title A register which holds the result of a new-instance instruction must not be used
+ * if the same new-instance instruction is again executed before the instance is initialized
*/
public void testVFE7() {
try {
@@ -178,11 +176,11 @@
DxUtil.checkVerifyException(t);
}
}
-
+
/**
* @constraint B7
- * @title A register which holds the result of a new-instance instruction must not be used
- * if the same new-instance instruction is again executed before the instance is initialized
+ * @title A register which holds the result of a new-instance instruction must not be used
+ * if the same new-instance instruction is again executed before the instance is initialized
*/
public void testVFE8() {
try {
diff --git a/tools/vm-tests/src/dot/junit/opcodes/new_instance/d/T_new_instance_4.d b/tools/vm-tests/src/dot/junit/opcodes/new_instance/d/T_new_instance_4.d
index 508e63c..a92c597 100644
--- a/tools/vm-tests/src/dot/junit/opcodes/new_instance/d/T_new_instance_4.d
+++ b/tools/vm-tests/src/dot/junit/opcodes/new_instance/d/T_new_instance_4.d
@@ -27,8 +27,8 @@
.method public run()Ljava/lang/Object;
.limit regs 5
- new-instance v1, dot/junit/opcodes/new_instance/TestStubs$TestStub
-; invoke-direct {v1}, dot/junit/opcodes/new_instance/TestStubs$TestStub/<init>()V
+ new-instance v1, dot/junit/opcodes/new_instance/TestStubs
+; invoke-direct {v1}, dot/junit/opcodes/new_instance/TestStubs/<init>()V
; intentionally return v4 ("this")
return-object v4
.end method