Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 358288 - Initialization fails for some kinds of lists
Summary: Initialization fails for some kinds of lists
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Matt Heitz CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-20 14:47 EDT by Matt Heitz CLA
Modified: 2017-02-23 14:16 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Heitz CLA 2011-09-20 14:47:15 EDT
The generated code for the line below throws an exception at run time.

i1 int[] = new int[2];

The problem is that we're passing in Integer.class to the EglList constructor, and we're calling its newInstance method to create the elements of the list.  But Integer doesn't have a default constructor, so it fails.

The same problem can happen when list.resize() is called.
Comment 1 Matt Heitz CLA 2011-09-20 22:09:48 EDT
Fixed by creating an interface for objects that can create elements, and passing it to the constructor and the resize function.  We have various implementors of the interface, to cover the various cases of list of primitives, objects, and multi-dimensional lists.
  
Note that it's valid to declare an array of non-nullable anys without an initializer, like this:
    x any[];
You're also allowed to call resize on the array, but if new elements need to be added, the resize function will throw an exception.  This is what Tim wants (it's better than having some special check that prevents you from calling resize on an array of anys).
Comment 2 Matt Heitz CLA 2011-10-04 15:30:49 EDT
Verified.