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

Bug 358288

Summary: Initialization fails for some kinds of lists
Product: z_Archived Reporter: Matt Heitz <mheitz>
Component: EDTAssignee: Matt Heitz <mheitz>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

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.