Bug 245563 - npe in reconciler
Summary: npe in reconciler
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-28 13:35 EDT by Brian Miller CLA
Modified: 2008-09-15 12:20 EDT (History)
3 users (show)

See Also:


Attachments
Proposed fix + regression test (3.00 KB, patch)
2008-08-28 14:57 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 Brian Miller CLA 2008-08-28 13:35:32 EDT
Build ID: I20080617-2000  (3.4.0)

Steps To Reproduce:
As soon as this source class is opened, crashes appear in the error log.

----------------------- Bug.java ---------------
class Bug {
	{
		for(Object obj:new Object[]{new Object(){
			int field=method(});
		}});
	}
	int method(int...args){return args.length;}
}

More information:
java.lang.NullPointerException
	at org.eclipse.jdt.internal.compiler.ast.ForeachStatement.traverse(ForeachStatement.java:528)
	at org.eclipse.jdt.internal.compiler.ast.Block.traverse(Block.java:127)
	at org.eclipse.jdt.internal.compiler.ast.Initializer.traverse(Initializer.java:128)
	at org.eclipse.jdt.internal.compiler.parser.Parser.recoverStatements(Parser.java:10124)
	at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:9322)
	at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:9533)
	at org.eclipse.jdt.internal.compiler.ast.Initializer.parseStatements(Initializer.java:82)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.parseMethods(TypeDeclaration.java:813)
	at org.eclipse.jdt.internal.compiler.parser.Parser.getMethodBodies(Parser.java:8513)
	at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:849)
	at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:904)
	at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:182)
	at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:243)
	at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:190)
Comment 1 Olivier Thomann CLA 2008-08-28 14:56:08 EDT
I think in case of recovered statement we simply need to check for null.
Adding a null check makes the statement recovery to complete and the result in the ASTView is pretty good.
Comment 2 Olivier Thomann CLA 2008-08-28 14:57:37 EDT
Created attachment 111238 [details]
Proposed fix + regression test
Comment 3 Olivier Thomann CLA 2008-08-28 14:58:01 EDT
Released for 3.5M2.
Added regression test in org.eclipse.jdt.core.tests.dom.ASTConverter15Test#test0323
Comment 4 Jerome Lanneluc CLA 2008-09-15 12:20:59 EDT
Verified for 3.5M2 using I20080914-2000