Bug 5136 - ArrayIndexOutOfBoundsException when a field declaration is an anonymous class
Summary: ArrayIndexOutOfBoundsException when a field declaration is an anonymous class
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 M1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-10-22 10:32 EDT by Olivier Thomann CLA
Modified: 2002-01-11 09:08 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 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