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

Bug 350693

Summary: [exceptions][parser] ArrayIndexOutOfBoundsException in Parser#consumeEmptyStatement on a javascript file when building project
Product: [WebTools] JSDT Reporter: Joc <joconnor>
Component: GeneralAssignee: Project Inbox <jsdt.javascript-inbox>
Status: CLOSED DUPLICATE QA Contact: Nitin Dahyabhai <thatnitind>
Severity: normal    
Priority: P3 CC: aaronkelley, brothermannumber4, cmjaun, earlyster, estelle, Michael_Rennie, nimish50, Olivier_Thomann, roscaf, simpson.cl, slr_msdn, subashini.rajan, tobias.hammerschmidt, vrubezhny
Version: unspecifiedKeywords: needinfo
Target Milestone: Future   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Stack trace from Problems tab none

Description Joc CLA 2011-06-29 08:12:36 EDT
Build Identifier: 20110615-0604

It's not a bug with an obviously recreatable problem as it seems volume related.
I created a new dynamic web project, and dumped code into it from our SCM system, so its a clean project. This is a large single monolithic J2EE project with almost 18,000 files in it.
Added the user libraries and refreshed the project. After a while the build completed, and the Problems tab highlighted one error.

Internal validation error | multiSelectionFiles.js | /AdaptV11.7/WebApp/controls/DocumentLibrary/js | line 0 | JavaScript Problem

On clicking the error in the Problems tab, it takes me to a file. There are no obvious errors in the file (the red X appears on the first line which is just a comment) and right clicking and selecting "validate" also says there is nothing wrong with the file.
If I empty the file and save it, I still get the error.
If I actually delete the file from the project, the error moves on to the next file in the tree. If I delete that one too, that particular error disappears (but I get a lot of other build errors at that point).
If I re-get the files from our SCM and do a clean. The error is back to the original file.

Sorry its not much to go on but I dont have a better way of recreating it as it's not related to the contents of any particular file.

Reproducible: Always

Steps to Reproduce:
I dont have a particular way to recreate it - I'm just getting a project from SCM and hitting refresh.
Comment 1 Joc CLA 2011-06-29 08:14:59 EDT
Created attachment 198821 [details]
Stack trace from Problems tab
Comment 2 Chris Jaun CLA 2011-06-29 14:36:21 EDT
Thanks for the report.

Unfortunately, without a reproducible scenario there is little we can do. These types of problems are often caused by something specific in the code. It most likely does have something to do with the file mentioned below.

If you can provide us a small reproducible scenario (i.e. sample code) that would be great, otherwise, we'll probably end up closing this bug.
Comment 3 Chris Jaun CLA 2011-06-29 14:38:12 EDT
Similar stack reported in BUG350590:

Build Identifier: Indigo SR0 Javascript package

When importing an existing project, I get the following exception

java.lang.ArrayIndexOutOfBoundsException: -4
    at
org.eclipse.wst.jsdt.internal.compiler.parser.Parser.consumeEmptyStatement(Parser.java:1915)
    at
org.eclipse.wst.jsdt.internal.compiler.parser.Parser.consumeRule(Parser.java:2932)
    at
org.eclipse.wst.jsdt.internal.compiler.parser.Parser.parse(Parser.java:5802)
    at
org.eclipse.wst.jsdt.internal.compiler.parser.Parser.parse(Parser.java:6036)
    at
org.eclipse.wst.jsdt.internal.compiler.parser.Parser.parse(Parser.java:5988)
    at
org.eclipse.wst.jsdt.internal.compiler.SourceElementParser.parseCompilationUnit(SourceElementParser.java:1302)
    at
org.eclipse.wst.jsdt.internal.core.CompilationUnit.buildStructure(CompilationUnit.java:192)
    at
org.eclipse.wst.jsdt.internal.core.Openable.generateInfos(Openable.java:241)
    at
org.eclipse.wst.jsdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:538)
    at
org.eclipse.wst.jsdt.internal.core.BecomeWorkingCopyOperation.executeOperation(BecomeWorkingCopyOperation.java:39)
    at
org.eclipse.wst.jsdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:742)
    at
org.eclipse.wst.jsdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:802)
    at
org.eclipse.wst.jsdt.internal.core.CompilationUnit.getWorkingCopy(CompilationUnit.java:967)
    at
org.eclipse.wst.jsdt.internal.core.CompilationUnit.getWorkingCopy(CompilationUnit.java:936)
    at
org.eclipse.wst.jsdt.internal.ui.wizards.ClassPathDetector.visitCompilationUnit(ClassPathDetector.java:142)
    at
org.eclipse.wst.jsdt.internal.ui.wizards.ClassPathDetector.visit(ClassPathDetector.java:227)
Comment 4 Chris Jaun CLA 2011-06-29 14:40:04 EDT
*** Bug 350590 has been marked as a duplicate of this bug. ***
Comment 5 slr_msdn CLA 2011-08-17 12:48:49 EDT
I see this problem when I include the source for d3.js (http://mbostock.github.com/d3/) in the WebContent directory of my dynamic web project.
Comment 6 Chuck Simpson CLA 2011-09-04 16:42:42 EDT
I see the same problem when I create a Dynamic Web project and import the code from the jQuery in Action book. (http://www.manning.com/bibeault2/jqia2.source.zip) into the WebContent folder. The error I get is:

Internal validation error java.lang.ArrayIndexOutOfBoundsException: -3 at 
 org.eclipse.wst.jsdt.internal.compiler.parser.Parser.consumeEmptyStatement(Parser.ja
 va:1915) at 
 org.eclipse.wst.jsdt.internal.compiler.parser.Parser.consumeRule(Parser.java:2932) at 
 org.eclipse.wst.jsdt.internal.compiler.parser.Parser.parse(Parser.java:5802) at 
 org.eclipse.wst.jsdt.internal.compiler.parser.Parser.parse(Parser.java:6036) at 
 org.eclipse.wst.jsdt.internal.compiler.parser.Parser.parse(Parser.java:5988) at 
 org.eclipse.wst.jsdt.internal.compiler.parser.Parser.dietParse(Parser.java:4593) at 
 org.eclipse.wst.jsdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.jav
 a:549) at 
 org.eclipse.wst.jsdt.internal.compiler.Compiler.beginToCompile(Compiler.java:319) 
 at org.eclipse.wst.jsdt.internal.compiler.Compiler.compile(Compiler.java:333) at 
 org.eclipse.wst.jsdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImag
 eBuilder.java:288) at 
 org.eclipse.wst.jsdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuil
 der.java:86) at 
 org.eclipse.wst.jsdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImag
 eBuilder.java:227) at 
 org.eclipse.wst.jsdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.
 java:58) at 
 org.eclipse.wst.jsdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:291) at 
 org.eclipse.wst.jsdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:199) at 
 org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728) at 
 org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at 
 org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199) at 
 org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239) at 
 org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292) at 
 org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at 
 org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295) at 
 org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:
 351) at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374) at 
 org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143) at 
 org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241) at 
 org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Comment 7 Chuck Simpson CLA 2011-09-04 16:46:02 EDT
I fixed the problem I was having by removing the jquery-1.6.2.js file I had copied into the scripts folder. That folder already had jquery-1.4.js.
Comment 8 Florin Rosca CLA 2011-11-17 19:50:11 EST
On Eclipse Indigo SR1

For a simple project with just one JS file, everything works fine.
For a large project with many JS files (including linked resources) I am getting this:


Internal validation error java.lang.ArrayIndexOutOfBoundsException: -2 at org.eclipse.wst.jsdt.internal.compiler.parser.Parser.consumeEmptyStatement(Parser.java:1915) at org.eclipse.wst.jsdt.internal.compiler.parser.Parser.consumeRule(Parser.java:2932) at 
 org.eclipse.wst.jsdt.internal.compiler.parser.Parser.parse(Parser.java:5802) at org.eclipse.wst.jsdt.internal.compiler.parser.Parser.parse(Parser.java:6036) at org.eclipse.wst.jsdt.internal.compiler.parser.Parser.parse(Parser.java:5988) at 
 org.eclipse.wst.jsdt.internal.compiler.parser.Parser.dietParse(Parser.java:4593) at org.eclipse.wst.jsdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:559) at org.eclipse.wst.jsdt.internal.compiler.Compiler.beginToCompile(Compiler.java:328) at 
 org.eclipse.wst.jsdt.internal.compiler.Compiler.compile(Compiler.java:342) at org.eclipse.wst.jsdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:288) at 
 org.eclipse.wst.jsdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuilder.java:86) at org.eclipse.wst.jsdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:227) at 
 org.eclipse.wst.jsdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:58) at org.eclipse.wst.jsdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:291) at org.eclipse.wst.jsdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:199) at 
 org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199) at 
 org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239) at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at 
 org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295) at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351) at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374) at 
 org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143) at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Comment 9 Victor Rubezhny CLA 2012-05-04 16:42:30 EDT
The patch proposed for the issue in https://bugs.eclipse.org/bugs/show_bug.cgi?id=356446 (which is a duplicate of this issue)
Comment 10 Victor Rubezhny CLA 2012-05-05 05:06:48 EDT
About the code to reproduce.

I didn't search for a real and working code which makes this issue happen but you'll see the exceptions in Error log if you insert the following line at the very beginning of any JavaScript file:

{code}
f{} 
{code}

Probably some jQuery minified scripts contain a constructions like this (not sure) but also this code is possible to be often typed manually by a developer, who's starting to type his own JavaScript.
Comment 11 Victor Rubezhny CLA 2012-05-05 05:11:32 EDT
Don't use "{code}" word while reproducing the issue. the only text between "{code}" words is to be used. It's just to divide the text of the comment from the text of JS-code.

Sorry, forgot that formatting like "{code}" is not working here.
Comment 12 Nimish Shah CLA 2012-05-12 05:02:50 EDT
I am also running into the problem when trying to include the d3.js source in my web project as well.

The problem is very reproducible.  Just download http://d3js.org/d3.v2.js and stick it into the WebContent directory of any Dynamic Web Project.  When you perform a build (or autobuild), the error occurs in the parser.

(In reply to comment #5)
> I see this problem when I include the source for d3.js
> (http://mbostock.github.com/d3/) in the WebContent directory of my dynamic web
> project.
Comment 13 Michael Rennie CLA 2012-05-24 16:55:55 EDT
*** Bug 380478 has been marked as a duplicate of this bug. ***
Comment 14 Joc CLA 2012-06-28 08:07:56 EDT
(In reply to comment #13)
> *** Bug 380478 has been marked as a duplicate of this bug. ***

Still seeing the same problem in Juno. 
Have got so used to running with the javascript validator turned off I had forgotten about it though.
Comment 15 Justin Early CLA 2013-01-29 12:57:25 EST
Per this thread [1] vjet team was asked to look at this bug to see if it also applies to vjet.

I am not able to reproduce this bug with VJET. The only validation module that JSDT and VJET share is the syntax validation. The semantic / flow validation that is done by VJET is done on the VJET Jst model not on the raw AST produced by JSDT parser. 

[1] http://dev.eclipse.org/mhonarc/lists/vjet-dev/msg00022.html
Comment 16 Michael Rennie CLA 2013-05-02 15:12:49 EDT
Marking as a dupe of bug 356446 (even though it is newer) because there is a patch attached there.

*** This bug has been marked as a duplicate of bug 356446 ***
Comment 17 Subashini S CLA 2014-10-28 18:01:48 EDT
I'm still seeing the problem in

 Version: Juno Service Release 2
 Build id: 20130225-0426.

Was the patch applied for this version?
Comment 18 Subashini S CLA 2014-10-28 18:02:08 EDT
I'm still seeing the problem in

 Version: Juno Service Release 2
 Build id: 20130225-0426.

Was the patch applied for this version?