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

Bug 356446

Summary: [exceptions] Errors running builder 'JavaScript Validator' on project with ArrayIndexOutOfBoundsException
Product: [WebTools] JSDT Reporter: andreas.rabus
Component: GeneralAssignee: Project Inbox <jsdt.javascript-inbox>
Status: RESOLVED WORKSFORME QA Contact: Chris Jaun <cmjaun>
Severity: normal    
Priority: P3 CC: aaronkelley, ben, brothermannumber4, cmjaun, earlyster, eclipse, eclipsebugs.machineghost, joconnor, jpadilla, lists+eclipse, Michael_Rennie, p.rader, tobias.hammerschmidt, vrubezhny
Version: unspecifiedFlags: cmjaun: review+
Target Milestone: 3.5.2   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
validation
none
The patch fixes the issue none

Description andreas.rabus CLA 2011-09-01 05:55:28 EDT
Build Identifier:  20110615-0604

On an PDT project with JS nature i got on every save multiple popups about one single  error

This is really annoying as it comes at every save (not only js files, or file containig JS).
Disabling the Validator on Project > Builders helps, but also renders JSDT pretty useless....

The message in the .log:

!MESSAGE Errors occurred during the build.
!SUBENTRY 1 org.eclipse.wst.jsdt.core 4 75 2011-09-01 11:15:45.679
!MESSAGE Errors running builder 'JavaScript Validator' on project 'GlamStudioUS'.
!STACK 0

Internal validation error
java.lang.ArrayIndexOutOfBoundsException: -3
	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: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(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)

Reproducible: Always

Steps to Reproduce:
1. Install JSDT and PDT
2. use some strange JS (its a working minified jQeruy plugin)
3. change save any file in the project.
4. click the popups...
Comment 1 muherman CLA 2011-10-12 03:26:00 EDT
Created attachment 204995 [details]
validation

please help
Comment 2 Victor Rubezhny CLA 2012-05-04 16:06:06 EDT
Created attachment 215101 [details]
The patch fixes the issue

The problem is that check for a unicode character in org.eclipse.wst.jsdt.internal.compiler.parser.Parser.consumeEmptyStatement() method doesn't ensures that the end of statement at least 4 characters later than the beginning of text. Patch adds such check.
Comment 3 Victor Rubezhny CLA 2012-05-04 16:45:04 EDT
This is a duplicate of #350693.

(Probably the patch should be moved to #350693?)
Comment 4 Sultan Flucas CLA 2012-05-23 17:41:23 EDT
Its not allowing me to apply the patch
Comment 5 Victor Rubezhny CLA 2012-05-23 17:56:41 EDT
(In reply to comment #4)
> Its not allowing me to apply the patch

How did you tried to apply it? And what was the problem?
Comment 6 Sultan Flucas CLA 2012-05-23 18:01:03 EDT
(In reply to comment #5)
> (In reply to comment #4)
> > Its not allowing me to apply the patch
> 
> How did you tried to apply it? And what was the problem?

Team > Apply Patch> Select Patch File


And It gave me the same error stack along with :
Console Configuration "Project name" does not exist.
It also stated it was a JPA problem
Comment 7 Victor Rubezhny CLA 2012-05-23 18:18:04 EDT
(In reply to comment #6)
> (In reply to comment #5)
> > (In reply to comment #4)
> > > Its not allowing me to apply the patch
> > 
> > How did you tried to apply it? And what was the problem?
> 
> Team > Apply Patch> Select Patch File
> 
> 
> And It gave me the same error stack along with :
> Console Configuration "Project name" does not exist.
> It also stated it was a JPA problem

It seems that you have no org.eclipse.wst.jsdt.core checked out in your workspace. It's not as trivial as just to invoke 'Apply patch'... This action doesn't apply patches to binaries. 

You need to have source code checked out before applying the patch. If you have it but still can't apply, just read the patch content (it's pretty simple text to understand where and what is changed) and manually make this change.

Then you have to build the plug-in and install it instead of the existing one.

Off course, you could apply any patch you find at your own, but it's alway better to wait while the issue will be fixed, verified and released. Yes, it takes much more time, since the issue is not targeted yet, so, I can't tell you when it will really be fixed. But at least you'll be sure that the issue is fixed properly.

So, please, be patient.
Comment 8 Sultan Flucas CLA 2012-05-23 18:30:24 EDT
(In reply to comment #7)
> (In reply to comment #6)
> > (In reply to comment #5)
> > > (In reply to comment #4)
> > > > Its not allowing me to apply the patch
> > > 
> > > How did you tried to apply it? And what was the problem?
> > 
> > Team > Apply Patch> Select Patch File
> > 
> > 
> > And It gave me the same error stack along with :
> > Console Configuration "Project name" does not exist.
> > It also stated it was a JPA problem
> 
> It seems that you have no org.eclipse.wst.jsdt.core checked out in your
> workspace. It's not as trivial as just to invoke 'Apply patch'... This action
> doesn't apply patches to binaries. 
> 
> You need to have source code checked out before applying the patch. If you have
> it but still can't apply, just read the patch content (it's pretty simple text
> to understand where and what is changed) and manually make this change.
> 
> Then you have to build the plug-in and install it instead of the existing one.
> 
> Off course, you could apply any patch you find at your own, but it's alway
> better to wait while the issue will be fixed, verified and released. Yes, it
> takes much more time, since the issue is not targeted yet, so, I can't tell you
> when it will really be fixed. But at least you'll be sure that the issue is
> fixed properly.
> 
> So, please, be patient.

I understand. manually applying the patch requires me to find the Parser.java file. This file has been compiled and is currently a .class file that i can not edit.

I guess it would be best to wait for the release.
Comment 9 Michael Rennie CLA 2012-05-24 16:59:37 EDT
Victor, could you test to see if your patch also fixes bug 350693? The stacktraces are close between the two bugs, and if your fix works for that one, we could dupe it against this one.
Comment 10 Victor Rubezhny CLA 2012-05-24 19:43:45 EDT
(In reply to comment #9)
> Victor, could you test to see if your patch also fixes bug 350693? The
> stacktraces are close between the two bugs, and if your fix works for that one,
> we could dupe it against this one.

Yes, this is the same issue and my patch fixes it. (I wrote it here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=350693#c9)
Comment 11 Jeremy Walker CLA 2012-11-15 17:12:16 EST
Something is seriously wrong with the development process here: this ticket has had a working patch (which also fixes another ticket) for over half a year, and no one has even bothered to look at it since.  With all due respect, why even keep a bug like this around if you're not going to fix it?

Any normal dev team would either close this as a wontfix or ... you know ... fix it.  Especially when someone else already did all the work.
Comment 12 Jeremy Walker CLA 2012-11-15 17:16:19 EST
(/rant off ... Sorry, but it just seems really unfair to me to leave this ticket around, let users think it might get fixed someday, let someone else spend a whole bunch of their time fixing it, and then ensure that they completely wasted their time and that users will keep waiting forever in vain.)
Comment 13 Justin Early CLA 2013-01-29 11:58:33 EST
Per this thread [1] vjet team was asked to look at this bug to see if it also applies to vjet.

I tried to reproduce this bug with the validation attachment and without the patch provided and there is no error in logs. AST is built with no syntax errors and format works on this file. 

[1] http://dev.eclipse.org/mhonarc/lists/vjet-dev/msg00022.html
Comment 14 Michael Rennie CLA 2013-05-02 15:12:49 EDT
*** Bug 350693 has been marked as a duplicate of this bug. ***
Comment 15 Michael Rennie CLA 2013-05-02 15:15:05 EDT
*** Bug 389045 has been marked as a duplicate of this bug. ***
Comment 16 Michael Rennie CLA 2013-05-02 15:16:50 EDT
There is also an alternate patch for this issue (plus a tests) on bug 391491
Comment 17 Michael Rennie CLA 2013-05-02 15:18:25 EDT
*** Bug 391491 has been marked as a duplicate of this bug. ***
Comment 18 Michael Rennie CLA 2013-05-02 15:18:52 EDT
*** Bug 405534 has been marked as a duplicate of this bug. ***
Comment 19 Jorge Padilla CLA 2013-06-19 13:47:59 EDT
Chris, I have reviewed this patch and validated it resolves this problem. I recommend it to be included in 3.5.1.  Could you officially complete 
this review?
Comment 20 Chris Jaun CLA 2013-07-09 14:56:58 EDT
Victor,

If you haven't yet, you need to sign the Contributor License Agreement for us to pull in your patch.

See point #1 and #2 in the Bugzilla section at this link for details: http://wiki.eclipse.org/Development_Resources/Handling_Git_Contributions

Thanks,
Chris
Comment 21 Victor Rubezhny CLA 2013-07-09 15:56:32 EDT
Chris, 

I've signed it.

Please, let me know if there is still something wrong.

Thanks, 
Victor
Comment 22 Chris Jaun CLA 2013-10-29 13:39:26 EDT
I was just reviewing this patch and noticed the same fix was already included for another unrelated bug, so I will just resolve this one.

Is included in 3.5.2 and master.