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
/**
	 * Creates an annotation model derrived from the given class file editor input.
	 * @param the editor input from which to query the annotations
	 * @return the created annotation model
	 * @exception CoreException if the editor input could not be accessed
	 */
	protected IAnnotationModel createClassFileAnnotationModel(IClassFileEditorInput classFileEditorInput) throws CoreException {
		IResource resource= null;
		IClassFile classFile= classFileEditorInput.getClassFile();
		
		IResourceLocator locator= (IResourceLocator) classFile.getAdapter(IResourceLocator.class);
		if (locator != null)
			resource= locator.getContainingResource(classFile);
		
		if (resource != null) {
			ClassFileMarkerAnnotationModel model= new ClassFileMarkerAnnotationModel(resource);
			model.setClassFile(classFile);
			return model;
		}
		
		return null;
	}
	
	/*
	 * @see AbstractDocumentProvider#createDocument(Object)
	 */
	protected IDocument createDocument(Object element) throws CoreException {
		IDocument document= super.createDocument(element);
		if (document != null) {
			JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools();