Community
Participate
Working Groups
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)
The scrapbook does not support import statements. You have to use the import action in the toolbar.
I know. I'm just thinking that dumping a stack trace to the console is not the desired behavior here. ;-)
this.expressionLengthPtr = -1. Need to investigate why.
I will investigate how to fail more nicely.
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?
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.
Verified in 200311211210