Bug 57176 NPE while editing Java source file
3.0 M8 Happened a couple of times today, not sure what exact action I was executing. Except for an error dialog, and the log entry, it would go unnoticed (no noticeable change in behaviour). Sorry, no test case. !ENTRY org.eclipse.core.runtime 4 2 Apr 01, 2004 22:30:42.857 !MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.core.ru ntime". !STACK 0 java.lang.NullPointerException at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.setSelection(JavaEd itor.java:2338) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.doSelectionChanged( JavaEditor.java:2482) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor$OutlineSelectionCha ngedListener.selectionChanged(JavaEditor.java:291) at org.eclipse.jface.viewers.StructuredViewer$3.run(StructuredViewer.jav a:431) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatfo rm.java:610) at org.eclipse.core.runtime.Platform.run(Platform.java:521) at org.eclipse.jface.viewers.StructuredViewer.firePostSelectionChanged(S tructuredViewer.java:429) at org.eclipse.jface.viewers.StructuredViewer.handleInvalidSelection(Str ucturedViewer.java:636) at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(Struct uredViewer.java:822) at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.j ava:893) at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.j ava:853) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlinePage$JavaOutlineVie wer.reconcile(JavaOutlinePage.java:405) at org.eclipse.jdt.internal.ui.javaeditor.JavaOutlinePage$1.run(JavaOutl inePage.java:168) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.ja va:106) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:2555) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2260) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1562) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1536) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.jav a:257) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:90 ) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformAct ivator.java:277) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.ja va:239) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.ja va:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:267) at org.eclipse.core.launcher.Main.run(Main.java:692) at org.eclipse.core.launcher.Main.main(Main.java:676)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java
Annotation annotation= getNextAnnotation(selection.getOffset(), selection.getLength(), forward, position);
			setStatusLineErrorMessage(null);
			setStatusLineMessage(null);
			if (annotation != null) {
				updateAnnotationViews(annotation);
				selectAndReveal(position.getOffset(), position.getLength());
				setStatusLineMessage(annotation.getText());
			}
		}
	}
	
	/**
	 * Updates the annotation views that show the given annotation.
	 * 
	 * @param annotation the annotation
	 */
	private void updateAnnotationViews(Annotation annotation) {
		IMarker marker= null;
		if (annotation instanceof MarkerAnnotation)
			marker= ((MarkerAnnotation) annotation).getMarker();
		else if (annotation instanceof IJavaAnnotation) {
			Iterator e= ((IJavaAnnotation) annotation).getOverlaidIterator();
			if (e != null) {
				while (e.hasNext()) {
					Object o= e.next();
					if (o instanceof MarkerAnnotation) {
						marker= ((MarkerAnnotation) o).getMarker();
						break;
					}
				}