--- old/src/hotspot/cpu/aarch64/c1_CodeStubs_aarch64.cpp 2018-04-24 15:41:21.333295000 +0200 +++ new/src/hotspot/cpu/aarch64/c1_CodeStubs_aarch64.cpp 2018-04-24 15:41:20.817251000 +0200 @@ -52,7 +52,13 @@ } RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array) - : _throw_index_out_of_bounds_exception(array == NULL), _index(index), _array(array) { + : _throw_index_out_of_bounds_exception(false), _index(index), _array(array) { + assert(info != NULL, "must have info"); + _info = new CodeEmitInfo(info); +} + +RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index) + : _throw_index_out_of_bounds_exception(true), _index(index), _array(NULL) { assert(info != NULL, "must have info"); _info = new CodeEmitInfo(info); } --- old/src/hotspot/cpu/arm/c1_CodeStubs_arm.cpp 2018-04-24 15:41:22.635399000 +0200 +++ new/src/hotspot/cpu/arm/c1_CodeStubs_arm.cpp 2018-04-24 15:41:22.147364000 +0200 @@ -53,11 +53,18 @@ // TODO: ARM - is it possible to inline these stubs into the main code stream? + RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array) - : _throw_index_out_of_bounds_exception(array == NULL), _index(index), _array(array) { - _info = info == NULL ? NULL : new CodeEmitInfo(info); + : _throw_index_out_of_bounds_exception(false), _index(index), _array(array) { + assert(info != NULL, "must have info"); + _info = new CodeEmitInfo(info); } +RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index) + : _throw_index_out_of_bounds_exception(true), _index(index), _array(NULL) { + assert(info != NULL, "must have info"); + _info = new CodeEmitInfo(info); +} void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); --- old/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp 2018-04-24 15:41:25.171605000 +0200 +++ new/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp 2018-04-24 15:41:24.687566000 +0200 @@ -41,7 +41,13 @@ RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array) - : _throw_index_out_of_bounds_exception(array == NULL), _index(index), _array(array) { + : _throw_index_out_of_bounds_exception(false), _index(index), _array(array) { + assert(info != NULL, "must have info"); + _info = new CodeEmitInfo(info); +} + +RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index) + : _throw_index_out_of_bounds_exception(true), _index(index), _array(NULL) { assert(info != NULL, "must have info"); _info = new CodeEmitInfo(info); } --- old/src/hotspot/cpu/s390/c1_CodeStubs_s390.cpp 2018-04-24 15:41:26.414714000 +0200 +++ new/src/hotspot/cpu/s390/c1_CodeStubs_s390.cpp 2018-04-24 15:41:25.926666000 +0200 @@ -42,8 +42,14 @@ #undef CHECK_BAILOUT #define CHECK_BAILOUT() { if (ce->compilation()->bailed_out()) return; } -RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array) : - _throw_index_out_of_bounds_exception(array == NULL), _index(index), _array(array) { +RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array) + : _throw_index_out_of_bounds_exception(false), _index(index), _array(array) { + assert(info != NULL, "must have info"); + _info = new CodeEmitInfo(info); +} + +RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index) + : _throw_index_out_of_bounds_exception(true), _index(index), _array(NULL) { assert(info != NULL, "must have info"); _info = new CodeEmitInfo(info); } --- old/src/hotspot/cpu/sparc/c1_CodeStubs_sparc.cpp 2018-04-24 15:41:27.696813000 +0200 +++ new/src/hotspot/cpu/sparc/c1_CodeStubs_sparc.cpp 2018-04-24 15:41:27.203778000 +0200 @@ -39,11 +39,16 @@ #define __ ce->masm()-> RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array) - : _throw_index_out_of_bounds_exception(array == NULL), _index(index), _array(array) { + : _throw_index_out_of_bounds_exception(false), _index(index), _array(array) { assert(info != NULL, "must have info"); _info = new CodeEmitInfo(info); } +RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index) + : _throw_index_out_of_bounds_exception(true), _index(index), _array(NULL) { + assert(info != NULL, "must have info"); + _info = new CodeEmitInfo(info); +} void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); --- old/src/hotspot/cpu/x86/c1_CodeStubs_x86.cpp 2018-04-24 15:41:28.992923000 +0200 +++ new/src/hotspot/cpu/x86/c1_CodeStubs_x86.cpp 2018-04-24 15:41:28.492882000 +0200 @@ -92,12 +92,16 @@ } RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array) - : _throw_index_out_of_bounds_exception(array == NULL), _index(index), _array(array) -{ + : _throw_index_out_of_bounds_exception(false), _index(index), _array(array) { assert(info != NULL, "must have info"); _info = new CodeEmitInfo(info); } +RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index) + : _throw_index_out_of_bounds_exception(true), _index(index), _array(NULL) { + assert(info != NULL, "must have info"); + _info = new CodeEmitInfo(info); +} void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); --- old/src/hotspot/share/c1/c1_CodeStubs.hpp 2018-04-24 15:41:30.296025000 +0200 +++ new/src/hotspot/share/c1/c1_CodeStubs.hpp 2018-04-24 15:41:29.811986000 +0200 @@ -151,7 +151,10 @@ bool _throw_index_out_of_bounds_exception; public: + // For ArrayIndexOutOfBoundsException. RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array); + // For IndexOutOfBoundsException. + RangeCheckStub(CodeEmitInfo* info, LIR_Opr index); virtual void emit_code(LIR_Assembler* e); virtual CodeEmitInfo* info() const { return _info; } virtual bool is_exception_throw_stub() const { return true; } --- old/src/hotspot/share/c1/c1_LIRGenerator.cpp 2018-04-24 15:41:31.618139000 +0200 +++ new/src/hotspot/share/c1/c1_LIRGenerator.cpp 2018-04-24 15:41:31.107094000 +0200 @@ -504,7 +504,7 @@ void LIRGenerator::nio_range_check(LIR_Opr buffer, LIR_Opr index, LIR_Opr result, CodeEmitInfo* info) { - CodeStub* stub = new RangeCheckStub(info, index, NULL); + CodeStub* stub = new RangeCheckStub(info, index); if (index->is_constant()) { cmp_mem_int(lir_cond_belowEqual, buffer, java_nio_Buffer::limit_offset(), index->as_jint(), info); __ branch(lir_cond_belowEqual, T_INT, stub); // forward branch @@ -1889,7 +1889,7 @@ LIR_Opr result = rlock_result(x); if (GenerateRangeChecks) { CodeEmitInfo* info = state_for(x); - CodeStub* stub = new RangeCheckStub(info, index.result(), NULL); + CodeStub* stub = new RangeCheckStub(info, index.result()); if (index.result()->is_constant()) { cmp_mem_int(lir_cond_belowEqual, buf.result(), java_nio_Buffer::limit_offset(), index.result()->as_jint(), info); __ branch(lir_cond_belowEqual, T_INT, stub); --- old/src/hotspot/share/oops/objArrayKlass.cpp 2018-04-24 15:41:32.987248000 +0200 +++ new/src/hotspot/share/oops/objArrayKlass.cpp 2018-04-24 15:41:32.486207000 +0200 @@ -255,25 +255,28 @@ ResourceMark rm; stringStream ss; if (src_pos < 0) { - ss.print("while trying to copy from index %i of an object array with length %i", src_pos, s->length()); + ss.print("arraycopy source index %i out of bounds for object array[%i].", + src_pos, s->length()); } else if (dst_pos < 0) { - ss.print("while trying to copy to index %i of an object array with length %i", dst_pos, d->length()); + ss.print("arraycopy destination index %i out of bounds for object array[%i].", + dst_pos, d->length()); } else { - ss.print("while trying to copy a negative range %i from an object array with length %i to an object array with length %i", - length, s->length(), d->length()); + ss.print("arraycopy length %i is negative.", length); } THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string()); } // Check if the ranges are valid - if ( (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) - || (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length()) ) { + if ((((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) || + (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length())) { // Pass specific exception reason. ResourceMark rm; stringStream ss; if (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) { - ss.print("while trying to copy from index %u of an object array with length %i", (unsigned int) length + (unsigned int) src_pos, s->length()); + ss.print("arraycopy: last source index %u out of bounds for object array[%i].", + (unsigned int) length + (unsigned int) src_pos, s->length()); } else { - ss.print("while trying to copy to index %u of an object array with length %i", (unsigned int) length + (unsigned int) dst_pos, d->length()); + ss.print("arraycopy: last destination index %u out of bounds for object array[%i].", + (unsigned int) length + (unsigned int) dst_pos, d->length()); } THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string()); } --- old/src/hotspot/share/oops/typeArrayKlass.cpp 2018-04-24 15:41:34.285354000 +0200 +++ new/src/hotspot/share/oops/typeArrayKlass.cpp 2018-04-24 15:41:33.796317000 +0200 @@ -142,30 +142,28 @@ ResourceMark rm; stringStream ss; if (src_pos < 0) { - ss.print("while trying to copy from index %i of a %s array with length %i", + ss.print("arraycopy source index %i out of bounds for %s[%i].", src_pos, type2name_tab[ArrayKlass::cast(s->klass())->element_type()], s->length()); } else if (dst_pos < 0) { - ss.print("while trying to copy to index %i of a %s array with length %i", + ss.print("arraycopy destination index %i out of bounds for %s[%i].", dst_pos, type2name_tab[ArrayKlass::cast(d->klass())->element_type()], d->length()); } else { - ss.print("while trying to copy a negative range %i from a %s array with length %i to a %s array with length %i", - length, type2name_tab[ArrayKlass::cast(s->klass())->element_type()], s->length(), - type2name_tab[ArrayKlass::cast(d->klass())->element_type()], d->length()); + ss.print("arraycopy length %i is negative.", length); } THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string()); } // Check if the ranges are valid - if ( (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) - || (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length()) ) { + if ((((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) || + (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length())) { // Pass specific exception reason. ResourceMark rm; stringStream ss; if (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) { - ss.print("while trying to copy from index %u of a %s array with length %i", + ss.print("arraycopy: last source index %u out of bounds for %s[%i].", (unsigned int) length + (unsigned int) src_pos, type2name_tab[ArrayKlass::cast(s->klass())->element_type()], s->length()); } else { - ss.print("while trying to copy to index %u of a %s array with length %i", + ss.print("arraycopy: last destination index %u out of bounds for %s[%i].", (unsigned int) length + (unsigned int) dst_pos, type2name_tab[ArrayKlass::cast(d->klass())->element_type()], d->length()); } --- old/test/hotspot/jtreg/runtime/exceptionMsgs/ArrayIndexOutOfBoundsException/ArrayIndexOutOfBoundsExceptionTest.java 2018-04-24 15:41:35.654468000 +0200 +++ new/test/hotspot/jtreg/runtime/exceptionMsgs/ArrayIndexOutOfBoundsException/ArrayIndexOutOfBoundsExceptionTest.java 2018-04-24 15:41:35.133425000 +0200 @@ -24,14 +24,12 @@ /** * @test - * @summary Test extended ArrayIndexOutOfBoundsException message for - * class files generated without debug information. The message lists - * information about the array and the indexes involved. + * @summary Test extended ArrayIndexOutOfBoundsException message. The + * message lists information about the array and the indexes involved. * @compile ArrayIndexOutOfBoundsExceptionTest.java * @run testng ArrayIndexOutOfBoundsExceptionTest * @run testng/othervm -Xcomp -XX:-TieredCompilation ArrayIndexOutOfBoundsExceptionTest * @run testng/othervm -Xcomp -XX:TieredStopAtLevel=1 ArrayIndexOutOfBoundsExceptionTest - * @author Ann-Kathrin Wasle */ import java.io.ByteArrayInputStream; @@ -49,44 +47,19 @@ import static org.testng.Assert.fail; /** - * Tests the detailed messages for the ArrayIndexOutOfBoundsException. + * Tests the detailed messages of the ArrayIndexOutOfBoundsException. */ public class ArrayIndexOutOfBoundsExceptionTest { // Some fields used in the test. static int[] staticArray = new int[0]; static long[][] staticLongArray = new long[0][0]; - DoubleArrayGen dag; ArrayList names = new ArrayList<>(); ArrayList curr; public static void main(String[] args) { ArrayIndexOutOfBoundsExceptionTest t = new ArrayIndexOutOfBoundsExceptionTest(); try { - t.testCreationViaNew(); - t.testCreationViaReflection(); - t.testCreationViaSerialization(); - t.testLoadedFromLocalVariable1(); - t.testLoadedFromLocalVariable2(); - t.testLoadedFromLocalVariable3(); - t.testLoadedFromLocalVariable4(); - t.testLoadedFromLocalVariable5(); - t.testLoadedFromLocalVariable6(); - t.testLoadedFromLocalVariable7(); - t.testLoadedFromLocalVariable8(); - t.testLoadedFromLocalVariable9(); - t.testLoadedFromLocalVariable10(); - t.testLoadedFromLocalVariable11(); - t.testLoadedFromMethod1(); - t.testLoadedFromMethod2(); - t.testLoadedFromMethod3(); - t.testLoadedFromMethod4(); - t.testLoadedFromStaticField1(); - t.testLoadedFromStaticField2(); - t.testLoadedFromStaticField3(); - t.testLoadedFromStaticField4(); - t.testWorkWithCompiler(); - t.testMissingLocalVariableTable(); t.testAIOOBMessages(); } catch (Exception e) {} } @@ -94,386 +67,6 @@ /** * */ - @Test - public void testCreationViaNew() { - assertNull(new ArrayIndexOutOfBoundsException().getMessage()); - } - - /** - * @throws Exception - */ - @Test - public void testCreationViaReflection() throws Exception { - Exception ex = ArrayIndexOutOfBoundsException.class.newInstance(); - assertNull(ex.getMessage()); - } - - /** - * @throws Exception - */ - @Test - public void testCreationViaSerialization() throws Exception { - Object o = new ArrayIndexOutOfBoundsException(); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(bos); - oos.writeObject(o); - ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); - ObjectInputStream ois = new ObjectInputStream(bis); - Exception ex = (Exception) ois.readObject(); - assertNull(ex.getMessage()); - } - - /** - * - */ - @Test - public void testLoadedFromLocalVariable1() { - Object[] a = new Object[5]; - - try { - a[10].hashCode(); - fail(); - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - assertNotNull(e.getMessage()); - } - } - - /** - * - */ - @Test - public void testLoadedFromLocalVariable2() { - Object[] a = new Object[7]; - - try { - a[-7] = null; - fail(); - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - assertNotNull(e.getMessage()); - } - } - - /** - * - */ - @Test - public void testLoadedFromLocalVariable3() { - byte[] a = new byte[0]; - - try { - assertTrue(a[99] == 5); - fail(); - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - assertNotNull(e.getMessage()); - } - } - - /** - * - */ - @Test - public void testLoadedFromLocalVariable4() { - char[] a = new char[0]; - - try { - a[0] = 0; - fail(); - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - assertNotNull(e.getMessage()); - } - } - - /** - * - */ - @Test - public void testLoadedFromLocalVariable5() { - double[] a = new double[0]; - - try { - assertTrue(a[0] == 0); - fail(); - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - assertNotNull(e.getMessage()); - } - } - - /** - * - */ - @Test - public void testLoadedFromLocalVariable6() { - float[] a = new float[0]; - - try { - a[0] = 0; - fail(); - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - assertNotNull(e.getMessage()); - } - } - - /** - * - */ - @Test - public void testLoadedFromLocalVariable7() { - int[] a = new int[0]; - - try { - assertTrue(a[0] == 0); - fail(); - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - assertNotNull(e.getMessage()); - } - } - - /** - * - */ - @Test - public void testLoadedFromLocalVariable8() { - long[] a = new long[0]; - - try { - a[0] = 0; - fail(); - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - assertNotNull(e.getMessage()); - } - } - - /** - * - */ - @Test - public void testLoadedFromLocalVariable9() { - short[] a = new short[5]; - - try { - assertTrue(a[10] == 0); - fail(); - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - assertNotNull(e.getMessage()); - } - } - - /** - * - */ - @Test - public void testLoadedFromLocalVariable10() { - int[][][] a = new int[1][0][0]; - - try { - assertTrue(a[0][1][2] == 0); - fail(); - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - assertNotNull(e.getMessage()); - } - } - - /** - * - */ - @Test - public void testLoadedFromLocalVariable11() { - int[][][] a = new int[1][0][0]; - - try { - a[0][1][2] = 0; - fail(); - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - assertNotNull(e.getMessage()); - } - } - - /** - * - */ - @Test - public void testLoadedFromMethod1() { - - try { - assertTrue((ArrayGenerator.arrayReturner(false))[0] == null); - fail(); - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - assertNotNull(e.getMessage()); - } - } - - /** - * - */ - @Test - public void testLoadedFromMethod2() { - try { - assertTrue( - ((new ArrayGenerator().returnMyArray(1, 1, (short) 1)))[0] == null); - fail(); - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - assertNotNull(e.getMessage()); - } - } - - /** - * - */ - @Test - public void testLoadedFromMethod3() { - try { - assertTrue((returnArray(null, null, 1f))[0] == null); - fail(); - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - assertNotNull(e.getMessage()); - } - } - - /** - * - */ - @Test - public void testLoadedFromMethod4() { - ImplTestLoadedFromMethod4(new DoubleArrayGenImpl()); - } - - /** - * @param gen - */ - public void ImplTestLoadedFromMethod4(DoubleArrayGen gen) { - try { - (gen.getArray())[0] = 1.0; - fail(); - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - assertNotNull(e.getMessage()); - } - } - - /** - * - */ - @Test - public void testLoadedFromStaticField1() { - try { - assertTrue(staticArray[0] == 1); - fail(); - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - assertNotNull(e.getMessage()); - } - } - - /** - * - */ - @Test - public void testLoadedFromStaticField2() { - try { - staticArray[0] = 2; - fail(); - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - assertNotNull(e.getMessage()); - } - } - - /** - * - */ - @Test - public void testLoadedFromStaticField3() { - try { - assertTrue(staticLongArray[0][0] == 1L); - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - assertNotNull(e.getMessage()); - } - } - - /** - * - */ - @Test - public void testLoadedFromStaticField4() { - try { - staticLongArray[0][0] = 2L; - fail(); - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - assertNotNull(e.getMessage()); - } - } - - /** - * - */ - @Test - public void testWorkWithCompiler() { - int[] a = {0, 1, 2}; - int i1 = 2; - int i2 = 3; - - for (int i = 0; i < 10000000; i++) { // One 0 less is enough for d64. - testImplWorkWithCompiler(a, i1); - } - testImplWorkWithCompiler(a, i2); - } - - /** - * @param a - * @param i - */ - public void testImplWorkWithCompiler(int[] a, int i) { - try { - assertTrue(a[i] == 2); - } catch (ArrayIndexOutOfBoundsException e) { - e.printStackTrace(); - assertNotNull(e.getMessage()); - } - } - - private Object[] returnArray(String[][] dummy1, int[][][] dummy2, float dummy3) { - return new Object[0]; - } - - /** - * - */ - public static interface DoubleArrayGen { - /** - * @return double Array - */ - public double[] getArray(); - } - - /** - * - */ - public static class DoubleArrayGenImpl implements DoubleArrayGen { - @Override - public double[] getArray() { - return new double[0]; - } - } - - /** - * - */ public static class ArrayGenerator { /** @@ -495,76 +88,6 @@ } } - - /** - * - */ - @Test - public void testMissingLocalVariableTable() { - doTestMissingLocalVariableTable(names); - - System.out.println("Names"); - - for (int i = 0; i < names.size(); ++i) { - System.out.println(names.get(i)); - } - - String[] expectedNames = new String[] { - "Index 0 out-of-bounds for length 0.", - "Index -1 out-of-bounds for length 10.", - "Index 1 out-of-bounds for length 0.", - "Index 7 out-of-bounds for length 5." - }; - - assertEquals(expectedNames.length, names.size()); - - for (int i = 0; i < expectedNames.length; ++i) { - assertEquals(names.get(i), expectedNames[i]); - } - } - - private void doTestMissingLocalVariableTable(ArrayList names) { - curr = names; - doTestMissingLocalVariableTable1(); - doTestMissingLocalVariableTable2(new Object[10], new boolean[0], new double[5][1]); - } - - private void doTestMissingLocalVariableTable1() { - try { - staticArray[0] = 0; - fail(); - } - catch (ArrayIndexOutOfBoundsException e) { - curr.add(e.getMessage()); - } - } - - private void doTestMissingLocalVariableTable2(Object[] o1, boolean z1[], double[][] dd1) { - try { - o1[-1].hashCode(); - fail(); - } - catch (ArrayIndexOutOfBoundsException e) { - curr.add(e.getMessage()); - } - - try { - z1[1] = true; - fail(); - } - catch (ArrayIndexOutOfBoundsException e) { - curr.add(e.getMessage()); - } - - try { - assertTrue(dd1[7][1] == 0); - fail(); - } - catch (ArrayIndexOutOfBoundsException e) { - curr.add(e.getMessage()); - } - } - /** * */ @@ -775,14 +298,14 @@ "Index 0 out-of-bounds for length 0."); } - // Test all five possible messages of arraycopy exceptions thrown in ObjArrayKlass::copy_array() + // Test all five possible messages of arraycopy exceptions thrown in ObjArrayKlass::copy_array(). try { System.arraycopy(oa1, -17, oa2, 0, 5); fail(); } catch (ArrayIndexOutOfBoundsException e) { assertEquals(e.getMessage(), - "while trying to copy from index -17 of an object array with length 10"); + "arraycopy source index -17 out of bounds for object array[10]."); } try { @@ -790,7 +313,7 @@ fail(); } catch (ArrayIndexOutOfBoundsException e) { assertEquals(e.getMessage(), - "while trying to copy to index -18 of an object array with length 5"); + "arraycopy destination index -18 out of bounds for object array[5]."); } try { @@ -798,7 +321,7 @@ fail(); } catch (ArrayIndexOutOfBoundsException e) { assertEquals(e.getMessage(), - "while trying to copy a negative range -19 from an object array with length 10 to an object array with length 5"); + "arraycopy length -19 is negative."); } try { @@ -806,7 +329,7 @@ fail(); } catch (ArrayIndexOutOfBoundsException e) { assertEquals(e.getMessage(), - "while trying to copy from index 13 of an object array with length 10"); + "arraycopy: last source index 13 out of bounds for object array[10]."); } try { @@ -814,17 +337,17 @@ fail(); } catch (ArrayIndexOutOfBoundsException e) { assertEquals(e.getMessage(), - "while trying to copy to index 7 of an object array with length 5"); + "arraycopy: last destination index 7 out of bounds for object array[5]."); } - // Test all five possible messages of arraycopy exceptions thrown in TypeArrayKlass::copy_array() + // Test all five possible messages of arraycopy exceptions thrown in TypeArrayKlass::copy_array(). try { System.arraycopy(da2, -17, da3, 0, 5); fail(); } catch (ArrayIndexOutOfBoundsException e) { assertEquals(e.getMessage(), - "while trying to copy from index -17 of a double array with length 10"); + "arraycopy source index -17 out of bounds for double[10]."); } try { @@ -832,7 +355,7 @@ fail(); } catch (ArrayIndexOutOfBoundsException e) { assertEquals(e.getMessage(), - "while trying to copy to index -18 of a double array with length 5"); + "arraycopy destination index -18 out of bounds for double[5]."); } try { @@ -840,7 +363,7 @@ fail(); } catch (ArrayIndexOutOfBoundsException e) { assertEquals(e.getMessage(), - "while trying to copy a negative range -19 from a double array with length 10 to a double array with length 5"); + "arraycopy length -19 is negative."); } try { @@ -848,7 +371,7 @@ fail(); } catch (ArrayIndexOutOfBoundsException e) { assertEquals(e.getMessage(), - "while trying to copy from index 13 of a double array with length 10"); + "arraycopy: last source index 13 out of bounds for double[10]."); } try { @@ -856,17 +379,17 @@ fail(); } catch (ArrayIndexOutOfBoundsException e) { assertEquals(e.getMessage(), - "while trying to copy to index 7 of a double array with length 5"); + "arraycopy: last destination index 7 out of bounds for double[5]."); } - // Test all possible basic types in the messages of arraycopy exceptions thrown in TypeArrayKlass::copy_array() + // Test all possible basic types in the messages of arraycopy exceptions thrown in TypeArrayKlass::copy_array(). try { System.arraycopy(za2, -17, za3, 0, 5); fail(); } catch (ArrayIndexOutOfBoundsException e) { assertEquals(e.getMessage(), - "while trying to copy from index -17 of a boolean array with length 10"); + "arraycopy source index -17 out of bounds for boolean[10]."); } try { @@ -874,7 +397,7 @@ fail(); } catch (ArrayIndexOutOfBoundsException e) { assertEquals(e.getMessage(), - "while trying to copy to index -18 of a byte array with length 5"); + "arraycopy destination index -18 out of bounds for byte[5]."); } try { @@ -882,7 +405,7 @@ fail(); } catch (ArrayIndexOutOfBoundsException e) { assertEquals(e.getMessage(), - "while trying to copy a negative range -19 from a short array with length 10 to a short array with length 5"); + "arraycopy length -19 is negative."); } try { @@ -890,7 +413,7 @@ fail(); } catch (ArrayIndexOutOfBoundsException e) { assertEquals(e.getMessage(), - "while trying to copy from index 13 of a char array with length 10"); + "arraycopy: last source index 13 out of bounds for char[10]."); } try { @@ -898,7 +421,7 @@ fail(); } catch (ArrayIndexOutOfBoundsException e) { assertEquals(e.getMessage(), - "while trying to copy a negative range -19 from a int array with length 10 to a int array with length 5"); + "arraycopy length -19 is negative."); } try { @@ -906,7 +429,7 @@ fail(); } catch (ArrayIndexOutOfBoundsException e) { assertEquals(e.getMessage(), - "while trying to copy to index 7 of a long array with length 5"); + "arraycopy: last destination index 7 out of bounds for long[5]."); } try { @@ -914,7 +437,7 @@ fail(); } catch (ArrayIndexOutOfBoundsException e) { assertEquals(e.getMessage(), - "while trying to copy to index 7 of a float array with length 5"); + "arraycopy: last destination index 7 out of bounds for float[5]."); } } }