Bug 17143 NPE when attaching source
20020521 F1 1. I set the source attchment of a JRE lib in the preferences. 2. An editor was open on a file of this lib (no source -> attach source button) org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException) at org.eclipse.swt.SWT.error(SWT.java:1887) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java(Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.window.Window.runEventLoop(Window.java(Compiled Code)) at org.eclipse.jface.window.Window.open(Window.java:538) at org.eclipse.jface.dialogs.ErrorDialog.open(ErrorDialog.java:209) at org.eclipse.jface.dialogs.ErrorDialog.openError(ErrorDialog.java:257) at org.eclipse.jface.dialogs.ErrorDialog.openError(ErrorDialog.java:231) at org.eclipse.ui.texteditor.AbstractTextEditor.setInput (AbstractTextEditor.java:1597) at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor$3.run (ClassFileEditor.java:563) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java(Compiled Code)) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java(Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java(Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java(Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java(Compiled Code)) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.jdt.internal.debug.ui.launcher.VMPreferencePage.updateDefaultVMInsta ll(VMPreferencePage.java:400) at org.eclipse.jdt.internal.debug.ui.launcher.VMPreferencePage.commitVMInstalls (VMPreferencePage.java:393) at org.eclipse.jdt.internal.debug.ui.launcher.VMPreferencePage.performOk (VMPreferencePage.java:370) at org.eclipse.jface.preference.PreferenceDialog.okPressed (PreferenceDialog.java:575) at org.eclipse.jface.preference.PreferenceDialog.buttonPressed (PreferenceDialog.java:175) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:398) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:85) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.window.Window.runEventLoop(Window.java(Compiled Code)) at org.eclipse.jface.window.Window.open(Window.java:538) at org.eclipse.ui.internal.OpenPreferencesAction.run (OpenPreferencesAction.java:47) at org.eclipse.jface.action.Action.runWithEvent(Action.java:590) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1068) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:739) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:462) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:200) at org.eclipse.core.launcher.Main.run(Main.java:643) at org.eclipse.core.launcher.Main.main(Main.java:476) !ENTRY org.eclipse.core.resources 1 4 Mai 23, 2002 10:44:50.44 !MESSAGE *** Stack trace of contained exception *** !ENTRY org.eclipse.ui 4 0 Mai 23, 2002 10:44:50.44 !MESSAGE java.lang.NullPointerException !STACK 0 java.lang.NullPointerException at at org.eclipse.ui.texteditor.StatusTextEditor.doSetInput (StatusTextEditor.java:160) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.doSetInput (JavaEditor.java:543) at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor.doSetInput (ClassFileEditor.java:468) at org.eclipse.ui.texteditor.AbstractTextEditor.setInput (AbstractTextEditor.java:1591) at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor$3.run (ClassFileEditor.java:563) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java(Compiled Code)) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java(Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.window.Window.runEventLoop(Window.java(Compiled Code)) at org.eclipse.jface.window.Window.open(Window.java:538) at org.eclipse.jface.dialogs.ErrorDialog.open(ErrorDialog.java:209) at org.eclipse.jface.dialogs.ErrorDialog.openError(ErrorDialog.java:257) at org.eclipse.jface.dialogs.ErrorDialog.openError(ErrorDialog.java:231) at org.eclipse.ui.texteditor.AbstractTextEditor.setInput (AbstractTextEditor.java:1597) at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor$3.run (ClassFileEditor.java:563) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java(Compiled Code)) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages (Synchronizer.java(Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java(Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java(Compiled Code)) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block (ModalContext.java(Compiled Code)) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:258) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:335) at org.eclipse.jdt.internal.debug.ui.launcher.VMPreferencePage.updateDefaultVMInsta ll(VMPreferencePage.java:400) at org.eclipse.jdt.internal.debug.ui.launcher.VMPreferencePage.commitVMInstalls (VMPreferencePage.java:393) at org.eclipse.jdt.internal.debug.ui.launcher.VMPreferencePage.performOk (VMPreferencePage.java:370) at org.eclipse.jface.preference.PreferenceDialog.okPressed (PreferenceDialog.java:575) at org.eclipse.jface.preference.PreferenceDialog.buttonPressed (PreferenceDialog.java:175) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:398) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:85) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.window.Window.runEventLoop(Window.java(Compiled Code)) at org.eclipse.jface.window.Window.open(Window.java:538) at org.eclipse.ui.internal.OpenPreferencesAction.run (OpenPreferencesAction.java:47) at org.eclipse.jface.action.Action.runWithEvent(Action.java:590) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1068) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:739) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:462) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:200) at org.eclipse.core.launcher.Main.run(Main.java:643) at org.eclipse.core.launcher.Main.main(Main.java:476)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClassFileDocumentProvider.java
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.editors.text.FileDocumentProvider;
import org.eclipse.jdt.core.ElementChangedEvent;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.IElementChangedListener;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaElementDelta;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.ui.text.JavaTextTools;
import org.eclipse.jdt.internal.ui.IResourceLocator;
import org.eclipse.jdt.internal.ui.JavaPlugin;
/**
 * A document provider for class files. Class files can be either inside 
 */
public class ClassFileDocumentProvider extends FileDocumentProvider {
	/**
	 * An input change listener to request the editor to reread the input.
	 */
	public interface InputChangeListener {
		void inputChanged(IClassFileEditorInput input);	
	}
		
	/**
	 * Synchronizes the document with external resource changes.
	 */
	protected class ClassFileSynchronizer implements IElementChangedListener {