Bug 102305 - Error in JDT Core during reconcile
Summary: Error in JDT Core during reconcile
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1.1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-30 08:18 EDT by David Pérez CLA
Modified: 2005-09-27 05:45 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Pérez CLA 2005-06-30 08:18:37 EDT
I have seen this worrying message in the Eclipse log file:

Error in JDT Core during reconcile

java.lang.NullPointerException
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1127)
at org.eclipse.jdt.core.dom.AST.convertCompilationUnit(AST.java:261)
at
org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:84)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:718)
at
org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:777)
at
org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1081)
at
org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:98)
at
org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1044)
at org.eclipse.core.runtime.Platform.run(Platform.java:783)
at
org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:82)
at
org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:147)
at
org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:86)
at
org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:94)
at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:75)
at org.eclipse.jdt.internal.ui.text.JavaReconciler.process(JavaReconciler.java:339)
at
org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:204)
Comment 1 Olivier Thomann CLA 2005-06-30 09:30:11 EDT
Would you have steps to reproduce?
This can only happen if the working copy has no source.
Comment 2 Olivier Thomann CLA 2005-06-30 10:45:13 EDT
I think the problem comes from the getContents() method on ICompilationUnit.
Right now we have:
public char[] getContents() {
	try {
		IBuffer buffer = this.getBuffer();
		return buffer == null ? null : buffer.getCharacters();
	} catch (JavaModelException e) {
		return CharOperation.NO_CHAR;
	}
}
instead of:
public char[] getContents() {
	try {
		IBuffer buffer = this.getBuffer();
		return buffer == null ? CharOperation.NO_CHAR : buffer.getCharacters();
	} catch (JavaModelException e) {
		return CharOperation.NO_CHAR;
	}
}
Comment 3 Olivier Thomann CLA 2005-06-30 17:12:27 EDT
Philippe, this might be a good candidate for 3.1.1.
I believe getContents() should never return null, but an empty array. Right now
the implementation is clearly inconsistent.
Comment 4 Philipe Mulet CLA 2005-06-30 17:50:39 EDT
Ok, though I wonder how this got introduced.
We may want to check with Jerome.
Comment 5 David Pérez CLA 2005-07-01 01:59:12 EDT
Probable cause: using Jadclipse plugin not prepared for Eclipse 3.1
Comment 6 Olivier Thomann CLA 2005-07-01 12:15:38 EDT
Fixed and released in 3.1. maintenance stream.
No regression test added as this is a case where no buffer is available.

Jérôme, please comment if this is not desired, but there is no null check for
the result of getContents(). So I am tempted to believe that null should not be
returned.
Comment 7 Jerome Lanneluc CLA 2005-08-09 08:52:21 EDT
The fix is correct. The bug was introduced with revision 1.70 when changing
getBuffer() to possibly return null.
Comment 8 Jerome Lanneluc CLA 2005-08-09 08:52:44 EDT
Verified with 3.2 M1
Comment 9 Maxime Daniel CLA 2005-09-27 05:43:57 EDT
Verified for 3.1.1 using build M20050923-1430.

See bug 110771 for fup on related concerns.