ArrayIndexOutOfBoundsException in ASTConverter.isPrimitiveType
Migrated from http://lampsvn.epfl.ch/trac/scala/ticket/2785
Reporter boia01
I get the following stacktrace in the Error Log window (even after doing Project -> Clean All)
Scala Eclipse Plugin 2.8.0.r20062-b20091209043719
Reporter boia01
I get the following stacktrace in the Error Log window (even after doing Project -> Clean All)
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.ArrayIndexOutOfBoundsException: 0)
at org.eclipse.swt.SWT.error(SWT.java:3884)
at org.eclipse.swt.SWT.error(SWT.java:3799)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:137)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3468)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3115)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
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:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
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:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.eclipse.jdt.core.dom.ASTConverter.isPrimitiveType(ASTConverter.java:3540)
at org.eclipse.jdt.core.dom.ASTConverter.convertType(ASTConverter.java:3117)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2663)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1264)
at scala.tools.eclipse.contribution.weaving.jdt.core.DOMAspect.ajc$around$scala_tools_eclipse_contribution_weaving_jdt_core_DOMAspect$1$3b9eae81(DOMAspect.aj:138)
at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:801)
at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:657)
at org.eclipse.jdt.internal.ui.text.correction.ASTResolving.createQuickFixAST(ASTResolving.java:1126)
at org.eclipse.jdt.internal.ui.text.correction.AssistContext.getASTRoot(AssistContext.java:115)
at org.eclipse.jdt.internal.ui.text.java.hover.ProblemHover$ProblemInfo.getJavaAnnotationFixes(ProblemHover.java:212)
at org.eclipse.jdt.internal.ui.text.java.hover.ProblemHover$ProblemInfo.getCompletionProposals(ProblemHover.java:192)
at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.deferredCreateContent(AbstractAnnotationHover.java:275)
at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.setInput(AbstractAnnotationHover.java:181)
at org.eclipse.jface.text.AbstractInformationControlManager.internalShowInformationControl(AbstractInformationControlManager.java:1170)
at org.eclipse.jface.text.AbstractInformationControlManager.presentInformation(AbstractInformationControlManager.java:1139)
at org.eclipse.jface.text.AbstractHoverInformationControlManager.presentInformation(AbstractHoverInformationControlManager.java:902)
at org.eclipse.jface.text.TextViewerHoverManager.doPresentInformation(TextViewerHoverManager.java:243)
at org.eclipse.jface.text.TextViewerHoverManager$5.run(TextViewerHoverManager.java:233)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
... 23 more
Configuration information:Scala Eclipse Plugin 2.8.0.r20062-b20091209043719
eclipse.buildId=M20090917-0800
java.version=1.6.0_17
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US
Framework arguments: -product org.eclipse.epp.package.java.product
Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.java.product
Leave a comment
on 2009-12-09 23:15 *
By
This will be caused by a specific Scala construct in one of your sources. If you're able to narrow the issue down to a simple reproducible example that would be very helpful.
Trac author: boia01
on 2009-12-10 00:02 *
By tracImporter
Trac author: boia01
Can't reproduce anymore. I'll reopen if I can reproduce. I didn't know if the stacktrace would be useful on its own right without a reproducible example.
Can't reproduce anymore. I'll reopen if I can reproduce. I didn't know if the stacktrace would be useful on its own right without a reproducible example.
on 2009-12-10 00:02 *
By tracImporter
Closed As: worksforme
To reproduce:
Make use of a java class from a jar file in your class path.
in the .scala file make sure that the class is used in the code but not imported. (no import statement for the used java class.)
Perform ctrl+space at the end of the java class. (mouse click directly after the java class name and press ctrl+space)
Example:
package org.app.control
//note no imports.
class Activator extends AbstractUIPlugin<- ctrl+space here{
override def start(context : BundleContext) {
super.start(context)
ConsultantActivator.plugin = this
}
}
See the error in the problems view in eclipse IDE.
Make use of a java class from a jar file in your class path.
in the .scala file make sure that the class is used in the code but not imported. (no import statement for the used java class.)
Perform ctrl+space at the end of the java class. (mouse click directly after the java class name and press ctrl+space)
Example:
package org.app.control
//note no imports.
class Activator extends AbstractUIPlugin<- ctrl+space here{
override def start(context : BundleContext) {
super.start(context)
ConsultantActivator.plugin = this
}
}
See the error in the problems view in eclipse IDE.
on 2010-11-02 20:48 *
By Matthew Farwell
This is reproducible. Using the following scala file:
package uk.co.farwell
object Main {
def main(args: Array[String]) = {
println("Hello world")
}
}
class Activator extends AbstractUIPlugin{
override def start(context : BundleContext) {
super.start(context)
ConsultantActivator.plugin = this
}
}
Hovering over the AbstractUIPlugin (line 10) causes the ArrayOutOfBoundsException (see ArrayOutOfBoundsException.stacktrace.txt). This looks like a similar problem to #1885, the offending method is:
protected boolean isPrimitiveType(char[] name) {
switch(name[0]) {
case 'i' :
if (name.length == 3 && name[1] == 'n' && name[2] == 't') {
return true;
}
return false;
and name is an empty string, therefore ArrayOutOfBoundsException
If, however, the auto-completion is attempted after the AbstractUIPlugin, then we get an java.lang.UnsupportedOperationException, (See UnsupportedOperationException.stacktrace.txt).
This is due to ScalaCompletionEngine.acceptSymbol
def acceptSymbol(sym : compiler.Symbol, tpe0 : compiler.Type, accessible : Boolean, inherited : Boolean, viaView : compiler.Symbol) {
// some lines ...
val sig0 = encodedJavaType(tpe).getSignature.replace('/', '.')
val sig = if (sig0.startsWith("(")) sig0 else "()"+sig0
val jtOwner = encodedJavaType(sym.owner.tpe)
if (jtOwner != JType.UNKNOWN)
proposal.setDeclarationSignature(jtOwner.getSignature.replace('/', '.').toArray)
encodedJavaType(tpe) returns JType.UNKNOWN, therefore we get an UnsupportedOperationException from JType.getSIgnature(). The call needs to be protected.
Using:
eclipse.buildId=M20100211-1343
java.version=1.6.0_11
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=fr_CH
Framework arguments: -product org.eclipse.sdk.ide
Command-line arguments: -product org.eclipse.sdk.ide -data C:\Developpement\scala-ide\workspace/../runtime-scala-ide -dev file:C:/Developpement/scala-ide/workspace/.metadata/.plugins/org.eclipse.pde.core/Scala-IDE/dev.properties -os win32 -ws win32 -arch x86 -clean -console
package uk.co.farwell
object Main {
def main(args: Array[String]) = {
println("Hello world")
}
}
class Activator extends AbstractUIPlugin{
override def start(context : BundleContext) {
super.start(context)
ConsultantActivator.plugin = this
}
}
Hovering over the AbstractUIPlugin (line 10) causes the ArrayOutOfBoundsException (see ArrayOutOfBoundsException.stacktrace.txt). This looks like a similar problem to #1885, the offending method is:
protected boolean isPrimitiveType(char[] name) {
switch(name[0]) {
case 'i' :
if (name.length == 3 && name[1] == 'n' && name[2] == 't') {
return true;
}
return false;
and name is an empty string, therefore ArrayOutOfBoundsException
If, however, the auto-completion is attempted after the AbstractUIPlugin, then we get an java.lang.UnsupportedOperationException, (See UnsupportedOperationException.stacktrace.txt).
This is due to ScalaCompletionEngine.acceptSymbol
def acceptSymbol(sym : compiler.Symbol, tpe0 : compiler.Type, accessible : Boolean, inherited : Boolean, viaView : compiler.Symbol) {
// some lines ...
val sig0 = encodedJavaType(tpe).getSignature.replace('/', '.')
val sig = if (sig0.startsWith("(")) sig0 else "()"+sig0
val jtOwner = encodedJavaType(sym.owner.tpe)
if (jtOwner != JType.UNKNOWN)
proposal.setDeclarationSignature(jtOwner.getSignature.replace('/', '.').toArray)
encodedJavaType(tpe) returns JType.UNKNOWN, therefore we get an UnsupportedOperationException from JType.getSIgnature(). The call needs to be protected.
Using:
eclipse.buildId=M20100211-1343
java.version=1.6.0_11
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=fr_CH
Framework arguments: -product org.eclipse.sdk.ide
Command-line arguments: -product org.eclipse.sdk.ide -data C:\Developpement\scala-ide\workspace/../runtime-scala-ide -dev file:C:/Developpement/scala-ide/workspace/.metadata/.plugins/org.eclipse.pde.core/Scala-IDE/dev.properties -os win32 -ws win32 -arch x86 -clean -console
file:dbg1xu5Sir36VMeJe5cbCb: ArrayOutOfBoundsException.stacktrace.txt
on 2010-11-02 20:49 *
By Matthew Farwell
Attachment UnsupportedOperationException.stacktrace.txt added
file:dbn7J65Sir36VMeJe5cbCb: UnsupportedOperationException.stacktrace.txt
on 2010-11-03 21:34 *
By Matthew Farwell
Attachment 0001-re-2785-ArrayIndexOutOfBoundsException-in-ASTConvert.patch added
file:aNX05I55ir34PjeJe5cbLA: Patch for UnsupportedOperationException
on 2010-11-07 22:26 *
By Matthew Farwell
Attachment 0002-re-2785-ArrayIndexOutOfBoundsException-in-ASTConvert.patch added
file:aziVGY6R4r37gWeJe5cbLA: second patch
on 2010-11-07 22:26 *
By Matthew Farwell
Attachment 0003-re-2785-ArrayIndexOutOfBoundsException-in-ASTConvert.patch added
file:azBAtG6R4r37gWeJe5cbLA: third patch
Ready to test.
I'll check, and apply your (Matthew) path.
Thanks
Thanks
on 2010-11-09 14:58 *
By
Actually, I'm just waiting on a signed Scala CLA from Matthew before applying ...
(In revision:015cf198263f2a48f5453efb80c11fb09651ffd2) adapt patch from Matthew Farwell
Fix #2785 ArrayIndexOutOfBoundsException in ASTConverter.isPrimitiveType
Branch:master
Fix #2785 ArrayIndexOutOfBoundsException in ASTConverter.isPrimitiveType
Branch:master
on 2010-11-09 15:46 *
By David Bernard
Sorry Miles,
I didn't saw your message before push. The patch was apply by copy/paste adaptation as it can't be "git am/apply" as is (mismatch on line position). I also clean import for ASTConverterAspect. And test before/after.
I didn't saw your message before push. The patch was apply by copy/paste adaptation as it can't be "git am/apply" as is (mismatch on line position). I also clean import for ASTConverterAspect. And test before/after.
on 2010-11-09 15:52 *
By
Not a big problem, but we do need to make sure that all the paperwork gets done.
on 2010-11-26 21:14 *
By David Bernard
(In revision:8cab00e000139f84bf1efb2d29ce139f08414fdb) adapt patch from Matthew Farwell
Fix #2785 ArrayIndexOutOfBoundsException in ASTConverter.isPrimitiveType
Branch:wip_exp_backport
Fix #2785 ArrayIndexOutOfBoundsException in ASTConverter.isPrimitiveType
Branch:wip_exp_backport
on 2010-11-27 10:11 *
By David Bernard
(In revision:52ec63eb992e6f8008fee47946810036fc463b91) adapt patch from Matthew Farwell
Fix #2785 ArrayIndexOutOfBoundsException in ASTConverter.isPrimitiveType
Branch:wip_experiment
Fix #2785 ArrayIndexOutOfBoundsException in ASTConverter.isPrimitiveType
Branch:wip_experiment
on 2010-12-01 01:31 *
By David Bernard
(In revision:c8a5f49f3725baa6a3ecc25c77a43536ef331490) try to fix (at least log via Defensive) definition of invalid source range start/end (may be some bugs could be introducted instead of fixing, Can someone review (especially comments and application of -1) ?
see #2785, see #1000158
Branch:wip_exp_backport
see #2785, see #1000158
Branch:wip_exp_backport
on 2010-12-01 01:37 *
By David Bernard
I also rewrite the patch in branch wip_exp_backport and remove the ASTConverterAspect.aj
http://www.assembla.com/code/scala-ide/git/changesets/82e6b9fd5aa1596c675d82484bea191466e68390
http://www.assembla.com/code/scala-ide/git/changesets/82e6b9fd5aa1596c675d82484bea191466e68390