Bug 68557 - [1.5] ArrayIndexOutOfBoundsException in SourceTypeConverter
Summary: [1.5] ArrayIndexOutOfBoundsException in SourceTypeConverter
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.1 M1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-24 19:33 EDT by Igor Fedorenko CLA
Modified: 2005-01-11 11:01 EST (History)
0 users

See Also:


Attachments
few obvious fixes to SourceTypeConverter (2.21 KB, patch)
2004-06-24 21:40 EDT, Igor Fedorenko CLA
no flags Details | Diff
This patch supposed to fix problem with multiple parametrized parameter types (1.92 KB, patch)
2004-06-25 10:42 EDT, Igor Fedorenko CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Fedorenko CLA 2004-06-24 19:33:27 EDT
This may be related to bug 59052. Trying I get ArrayIndexOutOfBoundsException
trying to save second of the two files (see below). The problem is triggered by
parametrized parameter type (like in Stack< List<Object> >) in the first file.
It is really bad as I cannot save affected .java files.

Cheetah from CVS as of Jun 24, 7:20pm EDT.

==========================================================
package test.cheetah;
import java.util.List;
import java.util.Stack;
public class NestedGenerics {
    Stack< List<Object> > stack = new Stack< List<Object> >();
}
==========================================================
package test.cheetah;
public class NestedGenericsTest {
    void test() {
        new NestedGenerics();
    }
}
==========================================================


Here is the stack trace

!ENTRY org.eclipse.jdt.core 4 4 Jun 24, 2004 19:27:54.136
!MESSAGE Exception occurred during problem detection: 
!STACK 0
java.lang.ArrayIndexOutOfBoundsException: 0
	at
org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter.decodeType(SourceTypeConverter.java:494)
	at
org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter.decodeTypeArguments(SourceTypeConverter.java:510)
	at
org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter.decodeType(SourceTypeConverter.java:418)
	at
org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter.createTypeReference(SourceTypeConverter.java:386)
	at
org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter.convert(SourceTypeConverter.java:153)
	at
org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter.convert(SourceTypeConverter.java:284)
	at
org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter.convert(SourceTypeConverter.java:135)
	at
org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter.buildCompilationUnit(SourceTypeConverter.java:90)
	at
org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.accept(CompilationUnitProblemFinder.java:100)
	at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:118)
	at
org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:169)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:1928)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getType(Scope.java:1721)
	at
org.eclipse.jdt.internal.compiler.ast.SingleTypeReference.getTypeBinding(SingleTypeReference.java:38)
	at
org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType(TypeReference.java:117)
	at
org.eclipse.jdt.internal.compiler.ast.AllocationExpression.resolveType(AllocationExpression.java:229)
	at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:449)
	at
org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:382)
	at
org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:133)
	at
org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:360)
	at
org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:920)
	at
org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:969)
	at
org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:280)
	at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:564)
	at
org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:176)
	at
org.eclipse.jdt.internal.core.CompilationUnit.buildStructure(CompilationUnit.java:146)
	at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:183)
	at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:572)
	at
org.eclipse.jdt.internal.core.CompilationUnit.makeConsistent(CompilationUnit.java:976)
	at
org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:58)
	at
org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:700)
	at
org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:739)
	at
org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1098)
	at
org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1060)
	at
org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.commitWorkingCopy(CompilationUnitDocumentProvider.java:886)
	at
org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider$2.execute(CompilationUnitDocumentProvider.java:951)
	at
org.eclipse.ui.editors.text.TextFileDocumentProvider$DocumentProviderOperation.run(TextFileDocumentProvider.java:105)
	at
org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation.execute(WorkspaceModifyDelegatingOperation.java:67)
	at
org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:91)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1673)
	at
org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:105)
	at
org.eclipse.ui.internal.editors.text.WorkspaceOperationRunner.run(WorkspaceOperationRunner.java:73)
	at
org.eclipse.ui.internal.editors.text.WorkspaceOperationRunner.run(WorkspaceOperationRunner.java:63)
	at
org.eclipse.ui.editors.text.TextFileDocumentProvider.executeOperation(TextFileDocumentProvider.java:403)
	at
org.eclipse.ui.editors.text.TextFileDocumentProvider.saveDocument(TextFileDocumentProvider.java:623)
	at
org.eclipse.ui.texteditor.AbstractTextEditor.performSave(AbstractTextEditor.java:3444)
	at
org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.performSave(CompilationUnitEditor.java:1357)
	at
org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.doSave(CompilationUnitEditor.java:1410)
	at org.eclipse.ui.internal.EditorManager$12.run(EditorManager.java:1160)
	at org.eclipse.ui.internal.EditorManager$10.run(EditorManager.java:1015)
	at
org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:303)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:253)
	at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:588)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
	at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:585)
	at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:1653)
	at
org.eclipse.ui.internal.EditorManager.runProgressMonitorOperation(EditorManager.java:1021)
	at org.eclipse.ui.internal.EditorManager.savePart(EditorManager.java:1165)
	at org.eclipse.ui.internal.WorkbenchPage.savePart(WorkbenchPage.java:2528)
	at org.eclipse.ui.internal.WorkbenchPage.saveEditor(WorkbenchPage.java:2540)
	at org.eclipse.ui.internal.SaveAction.run(SaveAction.java:69)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:881)
	at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:141)
	at org.eclipse.ui.internal.commands.Command.execute(Command.java:132)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:469)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:887)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:928)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:546)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$2(WorkbenchKeyboard.java:494)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard$1.handleEvent(WorkbenchKeyboard.java:259)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:714)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:795)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:820)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:805)
	at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1734)
	at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1730)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3067)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:2970)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:3298)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1467)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2396)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1375)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1346)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:252)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141)
	at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:96)
	at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:335)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:272)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:128)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:186)
	at org.eclipse.core.launcher.Main.run(Main.java:647)
	at org.eclipse.core.launcher.Main.main(Main.java:631)
Comment 1 Igor Fedorenko CLA 2004-06-24 21:40:35 EDT
Created attachment 12819 [details]
few obvious fixes to SourceTypeConverter

I've fixed couple problems in SourceTypeConverter. Unfortunately I do not know
the code enough to see if the fix breaks anything or there are other problems.
I'll update the patch should I find anything else.
Comment 2 Philipe Mulet CLA 2004-06-25 09:13:28 EDT
I was working on it. These changes are indeed necessary. 
Comment 3 Philipe Mulet CLA 2004-06-25 09:14:29 EDT
Fixed in latest, also needed a couple more tweaks but along same line.
Comment 4 Igor Fedorenko CLA 2004-06-25 10:39:01 EDT
Thank you for the fix Philippe. There are however couple of other problems with
this code that become apparent with multiple parametrized parameter types (like
in  Map<List<Object>,List<Object>>.
Comment 5 Igor Fedorenko CLA 2004-06-25 10:42:52 EDT
Created attachment 12831 [details]
This patch supposed to fix problem with multiple parametrized parameter types

This patch fixes the editor problem however i am not 100% sure about AST it
creates. TypeReference#toString returns "List<Object>.List<Object>" instead of
"List<Object>,List<Object>" which does not look right.
Comment 6 Philipe Mulet CLA 2004-06-25 12:21:12 EDT
I did notice the problem with multiple arguments, and had released a fix for 
it as well (simpler than your patch). There was some confusion in offset of 
#decodeArgumentTypes, when returning it is supposed to be on trailing '>', and 
was off by one causing grief.

Can you reproduce the issue with the released version ?
Comment 7 Philipe Mulet CLA 2004-06-25 12:45:25 EDT
Closing
Comment 8 Igor Fedorenko CLA 2004-06-25 12:52:22 EDT
That worked. Thank you again.
Comment 9 Philipe Mulet CLA 2004-06-26 19:56:10 EDT
I released another version which supports wildcards.