Community
Participate
Working Groups
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)
Would you have steps to reproduce? This can only happen if the working copy has no source.
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; } }
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.
Ok, though I wonder how this got introduced. We may want to check with Jerome.
Probable cause: using Jadclipse plugin not prepared for Eclipse 3.1
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.
The fix is correct. The bug was introduced with revision 1.70 when changing getBuffer() to possibly return null.
Verified with 3.2 M1
Verified for 3.1.1 using build M20050923-1430. See bug 110771 for fup on related concerns.