< prev index next > test/jdk/java/util/Arrays/Fill.java
Print this page
/*
* @test
* @bug 4229892
* @summary Arrays.fill(Object[], ...) should throw ArrayStoreException
* @author Martin Buchholz
+ * @library /test/lib
*/
import java.io.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
+ import jdk.test.lib.valueclass.AsValueClass;
+
public class Fill {
+
+ @AsValueClass
+ static record MyValue(int value) {};
+
private static void realMain(String[] args) throws Throwable {
try {
Arrays.fill(new Integer[3], "foo");
fail("Expected ArrayStoreException");
}
catch (Throwable t) { unexpected(t); }
try {
Arrays.fill(new Integer[3], 0, 4, "foo");
fail("Expected ArrayIndexOutOfBoundsException");
+ }
+ catch (ArrayIndexOutOfBoundsException e) { pass(); }
+ catch (Throwable t) { unexpected(t); }
+
+ try {
+ Arrays.fill(new MyValue[3], "foo");
+ fail("Expected ArrayStoreException");
+ }
+ catch (ArrayStoreException e) { pass(); }
+ catch (Throwable t) { unexpected(t); }
+
+ try {
+ Arrays.fill(new MyValue[3], 0, 4, "foo");
+ fail("Expected ArrayIndexOutOfBoundsException");
}
catch (ArrayIndexOutOfBoundsException e) { pass(); }
catch (Throwable t) { unexpected(t); }
}
< prev index next >