Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 359450

Summary: IJavaArray.setValues throws exception when passing in zero-length array
Product: [Eclipse Project] JDT Reporter: Rajeev Dayal <rdayal>
Component: DebugAssignee: Michael Rennie <Michael_Rennie>
Status: VERIFIED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: Michael_Rennie
Version: 3.7   
Target Milestone: 3.8 M3   
Hardware: All   
OS: All   
Whiteboard:

Description Rajeev Dayal CLA 2011-09-29 12:04:58 EDT
Build Identifier: 20110615-0604

Calling IJavaArray.setValues(array) where array is a zero-length array results in an IndexOutOfBoundsException. This case should be handled more gracefully; that is, setValues should do nothing and exit early.

The source of the problem is at ArrayReferenceImpl.java:227:


227: if (index < 0 || index >= arrayLength) {
228:    throw new  IndexOutOfBoundsException(JDIMessages.ArrayReferenceImpl_Invalid_index_1);
229: }

In this case, index == 0, but arrayLength == 0 as well. An additional check needs to be added for the special-case of a zero-length array. 




Reproducible: Always
Comment 1 Michael Rennie CLA 2011-10-17 10:55:16 EDT
> This case should be handled more gracefully; that is, setValues should do 
> nothing and exit early.

Agreed. Pushed fix + regression tests to master.
Comment 2 Michael Rennie CLA 2011-10-28 13:04:37 EDT
verified in I20111027-1800