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

Bug 408312

Summary: Unhandled Event Loop Exception | java.lang.ArrayIndexOutOfBoundsException
Product: [Eclipse Project] JDT Reporter: Dirk Coligado <dirkjan521>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: jarthana
Version: 4.2   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard: stalebug
Attachments:
Description Flags
Sample Android Project none

Description Dirk Coligado CLA 2013-05-17 04:06:23 EDT
Whenever I use content assist, the chosen code doesn't get completed. Instead, it returns an error. Error occurs only to some codes such as findViewById() and View.onClickListener Inner Type. By the way, I am developing an app for Android OS.

To reproduce the error:
To better illustrate it, here is a sample code.
Button button = (Button)findView (CTRL + SPACE)
I use (CTRL + SPACE) to complete the line of code easier. Then, when I am about to choose findViewById(), the code does not get completed and returns an error in my error log.

It also happens when I try to complete the code:
button.setOnClickListener (new View.onClick (CTRL + SPACE)
This is very annoying because instead of just pressing CTRL + SPACE, I have to type the long code!

Here is the error in the error log:

Message: Unhandled event loop exception

Plugin: org.eclipse.ui

Exception Stack Trace:

java.lang.ArrayIndexOutOfBoundsException
	at java.lang.System.arraycopy(Native Method)
	at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:533)
	at java.lang.StringBuffer.append(StringBuffer.java:323)
	at org.eclipse.jdt.internal.core.util.MementoTokenizer.nextToken(MementoTokenizer.java:112)
	at org.eclipse.jdt.internal.core.JavaModel.getHandleFromMemento(JavaModel.java:165)
	at org.eclipse.jdt.internal.core.JavaElement.getHandleFromMemento(JavaElement.java:276)
	at org.eclipse.jdt.core.JavaCore.create(JavaCore.java:2928)
	at org.eclipse.jdt.core.JavaCore.create(JavaCore.java:2903)
	at org.eclipse.jdt.internal.core.util.Util.getPackageFragment(Util.java:946)
	at org.eclipse.jdt.internal.core.util.Util.getClassFile(Util.java:759)
	at org.eclipse.jdt.internal.core.util.Util.getUnresolvedJavaElement(Util.java:1526)
	at org.eclipse.jdt.internal.core.util.Util.getUnresolvedJavaElement(Util.java:1535)
	at org.eclipse.jdt.internal.core.util.Util.getUnresolvedJavaElement(Util.java:1371)
	at org.eclipse.jdt.core.dom.MethodBinding.getUnresolvedJavaElement(MethodBinding.java:254)
	at org.eclipse.jdt.core.dom.MethodBinding.getJavaElement(MethodBinding.java:240)
	at org.eclipse.jdt.internal.corext.codemanipulation.StubUtility.suggestArgumentNames(StubUtility.java:1254)
	at org.eclipse.jdt.internal.corext.codemanipulation.StubUtility2.createParameters(StubUtility2.java:485)
	at org.eclipse.jdt.internal.corext.codemanipulation.StubUtility2.createImplementationStub(StubUtility2.java:416)
	at org.eclipse.jdt.internal.ui.text.java.AnonymousTypeCompletionProposal.createNewBody(AnonymousTypeCompletionProposal.java:234)
	at org.eclipse.jdt.internal.ui.text.java.AnonymousTypeCompletionProposal.updateReplacementString(AnonymousTypeCompletionProposal.java:370)
	at org.eclipse.jdt.internal.ui.text.java.JavaTypeCompletionProposal.apply(JavaTypeCompletionProposal.java:107)
	at org.eclipse.jdt.internal.ui.text.java.AnonymousTypeCompletionProposal.apply(AnonymousTypeCompletionProposal.java:359)
	at org.eclipse.jdt.internal.ui.text.java.AbstractJavaCompletionProposal.apply(AbstractJavaCompletionProposal.java:477)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:940)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertSelectedProposalWithMask(CompletionProposalPopup.java:891)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(CompletionProposalPopup.java:1323)
	at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey(ContentAssistant.java:808)
	at org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey(TextViewer.java:491)
	at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:65)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1276)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1300)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1285)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1079)
	at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5932)
	at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5629)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1276)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1300)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1285)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1312)
	at org.eclipse.swt.widgets.Widget.gtk_key_press_event(Widget.java:748)
	at org.eclipse.swt.widgets.Control.gtk_key_press_event(Control.java:3050)
	at org.eclipse.swt.widgets.Composite.gtk_key_press_event(Composite.java:741)
	at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1773)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:5116)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4377)
	at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method)
	at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:8317)
	at org.eclipse.swt.widgets.Display.eventProc(Display.java:1193)
	at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
	at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:2342)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3184)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1053)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:942)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
Comment 1 Jay Arthanareeswaran CLA 2013-05-17 04:20:19 EDT
I can't reproduce this behavior with 4.2 or the 4.3 RC1. Do you see the same behavior with a plain Java project as well? It would be great if you can try and isolate the problem and share it with us. Thanks!
Comment 2 Dirk Coligado CLA 2013-05-17 04:24:41 EDT
The problem only happens on an Android Application project. The findViewById and onClickListener are from the Android SDK I think.
Comment 3 Dirk Coligado CLA 2013-05-17 04:29:42 EDT
It is somehow similar to this bug.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=221723

But instead of the override/implement methods, I get this using content assist.
Comment 4 Jay Arthanareeswaran CLA 2013-05-17 05:39:23 EDT
I am having trouble creating a Android Application Project. Would you mind attaching a test project with the bug so I could import and try it out.
Comment 5 Dirk Coligado CLA 2013-05-17 05:48:39 EDT
Created attachment 231140 [details]
Sample Android Project

On the src/com...../AddSubjectActivity.java

I commented on the line where the error occurs.
After trying to use content assistant, look at the error log and see if it happened.
Comment 6 Dirk Coligado CLA 2013-05-17 05:50:32 EDT
I uploaded the sample project. Please also take note that it was just yesterday that I received this error. I don't remember doing any changes before I get the unhandled exception.
Comment 7 Eclipse Genie CLA 2018-09-11 16:24:27 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.