Added JavaVM class>>_AASTORE:_:_: insn implementation.
The above method is calles by the VM if simple check for
class compatinility fails (as for interfaces) and eventually
throws ArrayStoreException.
--- a/JavaVM.st Mon Apr 29 21:08:38 2013 +0100
+++ b/JavaVM.st Mon Apr 29 21:46:05 2013 +0100
@@ -4824,6 +4824,21 @@
!JavaVM class methodsFor:'vm support'!
+_AASTORE: arr _: val _: index
+ "Called from the VM (___aastore()) for unhandled cases"
+
+ (val notNil and:[arr isJavaArray])"false" ifTrue:[
+ (self canCast: val class to: arr class javaComponentClass) ifFalse: [
+ self throwArrayStoreException: 'Incompatible types'.
+ ^ nil "Not reached"
+ ].
+ ].
+ arr basicAt: index + 1 put: val
+
+ "Created: / 29-04-2013 / 21:22:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+
+!
+
_ANEWARRAY:cls _:size
"Returns a new array of elements of type class."
--- a/tests/libjava/src/stx/libjava/tests/lang/ArrayTests.java Mon Apr 29 21:08:38 2013 +0100
+++ b/tests/libjava/src/stx/libjava/tests/lang/ArrayTests.java Mon Apr 29 21:46:05 2013 +0100
@@ -7,16 +7,19 @@
public class ArrayTests {
@Test
- public void test_01() {
+ public void test_01() {
String[] sa = new String[3];
Object[] oa = (Object[])sa;
+ boolean gotASE = false;
try {
- oa[0] = new Integer(1);
- assertFalse("Should not store Integer into String[]", false);
+ oa[0] = new Integer(1);
} catch (ArrayStoreException ase) {
- assertTrue(true);
+ gotASE = true;
+ } catch (Throwable t) {
+ t.printStackTrace();
+
}
-
+ assertTrue(gotASE);
}
}