Bug 47160 - ArrayIndexOutOfBoundsException from CodeSnippetParser
Summary: ArrayIndexOutOfBoundsException from CodeSnippetParser
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: 3.0 M5   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-11-20 15:28 EST by Jared Burns CLA
Modified: 2003-11-21 13:44 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jared Burns CLA 2003-11-20 15:28:57 EST
Build 200311192030

1. Create a Java project.
2. Create a Scrapbook page in the project.
3. Add org.eclipse.debug.core to the project build path.
4. Enter the following text in the scrapbook and try to evaluate it.
import org.eclipse.debug.core.DebugPlugin;
DebugPlugin.getDefault()
5. The following exception is dumped to the console. Nothing is written to the log.

java.lang.ArrayIndexOutOfBoundsException: -1
        at org.eclipse.jdt.internal.eval.CodeSnippetParser.consumeStatementRetur 
n(CodeSnippetParser.java:424)
        at org.eclipse.jdt.internal.eval.CodeSnippetParser.endParse(CodeSnippetP arser.java:481)
        at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:531 7)
        at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:556 7)
        at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.parseStatemen 
ts(MethodDeclaration.java:97)
        at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.parseMethod(Typ eDeclaration.java:
710)
        at org.eclipse.jdt.internal.compiler.parser.Parser.getMethodBodies(Parse r.java:4615)
        at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:504)
        at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:328)
        at org.eclipse.jdt.internal.eval.Evaluator.getClasses(Evaluator.java:130 )
        at org.eclipse.jdt.internal.eval.EvaluationContext.evaluate(EvaluationCo ntext.java:232)
        at org.eclipse.jdt.internal.eval.EvaluationContext.evaluate(EvaluationCo ntext.java:261)
        at org.eclipse.jdt.internal.core.eval.EvaluationContextWrapper.evaluateC 
odeSnippet(EvaluationContextWrapper.java:252)
        at org.eclipse.jdt.internal.debug.eval.LocalEvaluationEngine$1.run(Local EvaluationEngine.
java:437)
        at java.lang.Thread.run(Thread.java:536)
Comment 1 Darin Wright CLA 2003-11-20 15:32:49 EST
The scrapbook does not support import statements. You have to use the import 
action in the toolbar.
Comment 2 Jared Burns CLA 2003-11-20 15:36:54 EST
I know. I'm just thinking that dumping a stack trace to the console is not the desired behavior here. 
;-)
Comment 3 Olivier Thomann CLA 2003-11-20 15:53:57 EST
this.expressionLengthPtr = -1.
Need to investigate why.
Comment 4 Olivier Thomann CLA 2003-11-21 08:48:51 EST
I will investigate how to fail more nicely.
Comment 5 Olivier Thomann CLA 2003-11-21 09:11:22 EST
I think the fix is that the error recovery in the code snippet parser should not
be reentrant. We try to recover expression and then we go for headers.
Removing the reentrance and the scrapbook page returns:

Syntax error on token "import", assert expected

Is this good enough?
Comment 6 Olivier Thomann CLA 2003-11-21 09:42:36 EST
Fixed and released in HEAD.
The error message is consistent with what you would get if you defined an import
statement in a method body.
Comment 7 Olivier Thomann CLA 2003-11-21 13:44:56 EST
Verified in 200311211210