Bug 178861 - Executing run() in a scrapbook page leads to a NPE
Summary: Executing run() in a scrapbook page leads to a NPE
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-22 14:49 EDT by Olivier Thomann CLA
Modified: 2007-04-27 08:10 EDT (History)
1 user (show)

See Also:


Attachments
Proposed fix (1.73 KB, patch)
2007-03-23 09:22 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2007-03-22 14:49:51 EDT
Using I20070321-1800, executing:
run()

in a scrapbook page leads to a NPE and the scrapbook page is unresponsive.
See bug 178860 for the jdt.debug issue.
With the patch for bug 178860 released, you get:
Internal compiler error
java.lang.NullPointerException
	at org.eclipse.jdt.internal.compiler.codegen.CodeStream.getfield(CodeStream.java:2842)
	at org.eclipse.jdt.internal.eval.CodeSnippetThisReference.generateCode(CodeSnippetThisReference.java:61)
	at org.eclipse.jdt.internal.eval.CodeSnippetMessageSend.generateCode(CodeSnippetMessageSend.java:73)
	at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.generateCode(ReturnStatement.java:126)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:229)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:176)
	at org.eclipse.jdt.internal.eval.CodeSnippetTypeDeclaration.generateCode(CodeSnippetTypeDeclaration.java:60)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:581)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:215)
	at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:624)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:391)
	at org.eclipse.jdt.internal.eval.Evaluator.getClasses(Evaluator.java:130)
	at org.eclipse.jdt.internal.eval.EvaluationContext.evaluate(EvaluationContext.java:273)
	at org.eclipse.jdt.internal.eval.EvaluationContext.evaluate(EvaluationContext.java:302)
	at org.eclipse.jdt.internal.core.eval.EvaluationContextWrapper.evaluateCodeSnippet(EvaluationContextWrapper.java:237)
	at org.eclipse.jdt.internal.debug.eval.LocalEvaluationEngine$1.run(LocalEvaluationEngine.java:428)
	at java.lang.Thread.run(Thread.java:595)

inside the scrapbook page.
Comment 1 Olivier Thomann CLA 2007-03-22 14:54:04 EDT
The type of the delegateThis field binding is null.
Comment 2 Olivier Thomann CLA 2007-03-22 14:55:54 EDT
If I explicitely use "this", I get:
Cannot use this in a static context 

so this.run() works fine, but we don't report the error properly in case the implicit 'this' is used.
Comment 3 Olivier Thomann CLA 2007-03-23 09:22:06 EDT
Created attachment 61817 [details]
Proposed fix

This patch will report an error for accessing this in a static context if the delegateThis field cannot be resolved.
Comment 4 Olivier Thomann CLA 2007-03-26 13:20:11 EDT
Released for 3.3M7
Comment 5 Maxime Daniel CLA 2007-04-27 08:10:16 EDT
Verified for 3.3 M7 using build I20070427-0010.