Bug 5136

Summary: ArrayIndexOutOfBoundsException when a field declaration is an anonymous class
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0   
Target Milestone: 2.0 M1   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Olivier Thomann CLA 2001-10-22 10:32:37 EDT
205.

When a class has a field declaration that is an anonymous class and multiple 
constructors, we can get an ArrayIndexOutOfBoundsException.
Here is a test case to reproduce:

package p1;

import java.util.*;

public class A  {
	Object o1 = new Object() {
       public void foo() {
          Object o = A.this.bar();
          if(o !=null)
             o.toString();
       }
	  };
   public A()
   {
   }
   public A(TableModel aM)
   {
   }

    public A(int aNumRows, int aNumColumns)
   {
   }

    public A(Vector aRowData, Vector aColumnNames)
   {
   }

    public A(Object[][] aRowData, Object[][] aColumnNames)
   {

   }
   Object bar() { return null; }
}
Comment 1 Olivier Thomann CLA 2001-10-22 10:34:39 EDT
This problem is fixed and the fix is released in HEAD.
The reason of the exception is that the local variable binding didn't reset its 
initialization count.
This was a side-effect of the fact that we regenerate multiple times the 
anonymous class. The field declaration is included in each constructor.
Comment 2 Jerome Lanneluc CLA 2001-12-05 06:30:22 EST
Fixed in 1.0 Rollup 139