Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 359450 - IJavaArray.setValues throws exception when passing in zero-length array
Summary: IJavaArray.setValues throws exception when passing in zero-length array
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: 3.8 M3   Edit
Assignee: Michael Rennie CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-29 12:04 EDT by Rajeev Dayal CLA
Modified: 2011-10-28 13:04 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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