WIP

Change-Id: If94b298680a77866c0226dffff6421cc73d77b93
diff --git a/bundles/org.eclipse.jface/META-INF/MANIFEST.MF b/bundles/org.eclipse.jface/META-INF/MANIFEST.MF
index 23b58c9..645c9eb 100644
--- a/bundles/org.eclipse.jface/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.jface/META-INF/MANIFEST.MF
@@ -36,7 +36,8 @@
 Require-Bundle: org.eclipse.swt;bundle-version="[3.104.0,4.0.0)";visibility:=reexport,
  org.eclipse.core.commands;bundle-version="[3.4.0,4.0.0)";visibility:=reexport,
  org.eclipse.equinox.common;bundle-version="[3.3.0,4.0.0)",
- org.eclipse.equinox.bidi;bundle-version="[0.10.0,2.0.0)";resolution:=optional
+ org.eclipse.equinox.bidi;bundle-version="[0.10.0,2.0.0)";resolution:=optional,
+ org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Import-Package: javax.xml.parsers,
  org.osgi.framework,
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/SelectionChangedEvent.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/SelectionChangedEvent.java
index ea31c1a..1febed3 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/SelectionChangedEvent.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/SelectionChangedEvent.java
@@ -11,8 +11,8 @@
 package org.eclipse.jface.viewers;
 
 import java.util.EventObject;
-
 import org.eclipse.core.runtime.Assert;
+import org.eclipse.jdt.annotation.NonNull;
 
 /**
  * Event object describing a selection change. The source of these
@@ -33,6 +33,7 @@
     /**
      * The selection.
      */
+	@NonNull
     protected ISelection selection;
 
     /**
@@ -41,7 +42,7 @@
      * @param source the selection provider
      * @param selection the selection
      */
-    public SelectionChangedEvent(ISelectionProvider source, ISelection selection) {
+	public SelectionChangedEvent(ISelectionProvider source, @NonNull ISelection selection) {
         super(source);
         Assert.isNotNull(selection);
         this.selection = selection;
@@ -52,6 +53,7 @@
      *
      * @return the selection
      */
+	@NonNull
     public ISelection getSelection() {
         return selection;
     }
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IDecoratorManager.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IDecoratorManager.java
index 16cb772..98328d1 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IDecoratorManager.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IDecoratorManager.java
@@ -48,13 +48,15 @@
     ILabelDecorator getLabelDecorator();
 
     /**
-     * Return the IBaseLabelProvider that corresponds to the
-     * decoratorId. This can handle both lightweight and full
-     * decorators.
-     *
-     * @param decoratorId the decorator id
-     * @return the label provider
-     */
+	 * Return the IBaseLabelProvider that corresponds to the decoratorId if it
+	 * is enabled. Otherwise returns <code>null</code>. This can handle both
+	 * lightweight and full decorators.
+	 *
+	 * @param decoratorId
+	 *            the decorator id
+	 * @return the label provider
+	 */
+	@Nullable
     IBaseLabelProvider getBaseLabelProvider(String decoratorId);
 
     /**
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IEditorPart.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IEditorPart.java
index cd8f3721..e239c8f 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IEditorPart.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IEditorPart.java
@@ -11,6 +11,8 @@
 
 package org.eclipse.ui;
 
+import org.eclipse.jdt.annotation.Nullable;
+
 /**
  * An editor is a visual component within a workbench page. It is
  * typically used to edit or browse a document or input object. The input
@@ -61,11 +63,12 @@
     public static final int PROP_INPUT = IWorkbenchPartConstants.PROP_INPUT;
 
     /**
-     * Returns the input for this editor.  If this value changes the part must
-     * fire a property listener event with <code>PROP_INPUT</code>.
-     *
-     * @return the editor input
-     */
+	 * Returns the input for this editor. If this value changes the part must
+	 * fire a property listener event with <code>PROP_INPUT</code>.
+	 *
+	 * @return the editor input or {@code null} if none
+	 */
+	@Nullable
     public IEditorInput getEditorInput();
 
     /**
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/INavigationHistory.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/INavigationHistory.java
index ac52aca..81e7587 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/INavigationHistory.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/INavigationHistory.java
@@ -10,6 +10,8 @@
  *******************************************************************************/
 package org.eclipse.ui;
 
+import org.eclipse.jdt.annotation.Nullable;
+
 /**
  * Manages a list of entries to keep a history of locations on editors,
  * enabling the user to go back and forward without losing context.
@@ -50,6 +52,7 @@
      *
      * @return the current location
      */
+	@Nullable
     public INavigationLocation getCurrentLocation();
 
     /**
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/INullSelectionListener.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/INullSelectionListener.java
index 4d84f5f..1e96526 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/INullSelectionListener.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/INullSelectionListener.java
@@ -10,6 +10,9 @@
  *******************************************************************************/
 package org.eclipse.ui;
 
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.jface.viewers.ISelection;
+
 /**
  * Interface for listening to <code>null</code> selection changes.
  * <p>
@@ -28,4 +31,6 @@
  * @since 2.0
  */
 public interface INullSelectionListener extends ISelectionListener {
+	@Override
+	void selectionChanged(@Nullable IWorkbenchPart part, @Nullable ISelection selection);
 }
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/ISelectionListener.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/ISelectionListener.java
index 5d0a3c9..0ebd339 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/ISelectionListener.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/ISelectionListener.java
@@ -11,7 +11,6 @@
 package org.eclipse.ui;
 
 import java.util.EventListener;
-import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jface.viewers.ISelection;
 
 /**
@@ -39,5 +38,5 @@
      * @param selection the current selection. This may be <code>null</code>
      * 		if <code>INullSelectionListener</code> is implemented.
      */
-	public void selectionChanged(IWorkbenchPart part, @Nullable ISelection selection);
+	public void selectionChanged(IWorkbenchPart part, ISelection selection);
 }
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/ISelectionService.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/ISelectionService.java
index d8fda56..5572b08 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/ISelectionService.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/ISelectionService.java
@@ -10,6 +10,7 @@
  *******************************************************************************/
 package org.eclipse.ui;
 
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jface.viewers.ISelection;
 
 /**
@@ -126,6 +127,7 @@
      *
      * @return the current selection, or <code>null</code> if undefined
      */
+	@Nullable
     public ISelection getSelection();
 
     /**
@@ -137,6 +139,7 @@
      * @return the current selection, or <code>null</code> if undefined
      * @since 2.0
      */
+	@Nullable
     public ISelection getSelection(String partId);
 
     /**
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IWorkbenchPage.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IWorkbenchPage.java
index 9ed4c39..81c1b65 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IWorkbenchPage.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IWorkbenchPage.java
@@ -366,6 +366,7 @@
 	 * @return the view reference, or <code>null</code> if none is found
 	 * @since 3.0
 	 */
+	@Nullable
 	public IViewReference findViewReference(String viewId, @Nullable String secondaryId);
 
 	/**
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/NavigationLocation.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/NavigationLocation.java
index 0a7d621..e82bc5e 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/NavigationLocation.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/NavigationLocation.java
@@ -11,6 +11,8 @@
 
 package org.eclipse.ui;
 
+import org.eclipse.jdt.annotation.Nullable;
+
 /**
  * Default implementation of INavigationLocation.
  *
@@ -20,6 +22,7 @@
 
     private IWorkbenchPage page;
 
+	@Nullable
     private IEditorInput input;
 
     /**
@@ -37,7 +40,9 @@
      *
      * @return IEditorPart
      */
+	@Nullable
     protected IEditorPart getEditorPart() {
+		IEditorInput input = this.input; // to keep nullness happy
         if (input == null) {
 			return null;
 		}
@@ -45,6 +50,7 @@
     }
 
     @Override
+	@Nullable
 	public Object getInput() {
         return input;
     }
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/OpenAndLinkWithEditorHelper.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/OpenAndLinkWithEditorHelper.java
index e516a71..8116a62 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/OpenAndLinkWithEditorHelper.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/OpenAndLinkWithEditorHelper.java
@@ -11,6 +11,7 @@
 package org.eclipse.ui;
 
 import org.eclipse.core.runtime.Assert;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jface.util.OpenStrategy;
 import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.IDoubleClickListener;
@@ -33,6 +34,7 @@
 
 	private boolean isLinkingEnabled;
 
+	@Nullable
 	private ISelection lastOpenSelection;
 
 	private InternalListener listener;
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/AbstractPartSelectionTracker.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/AbstractPartSelectionTracker.java
index f70c4f2..20b486e 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/AbstractPartSelectionTracker.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/AbstractPartSelectionTracker.java
@@ -12,6 +12,7 @@
 
 import org.eclipse.core.runtime.ListenerList;
 import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jface.util.SafeRunnable;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.ui.INullSelectionListener;
@@ -108,14 +109,20 @@
      * @param sel the selection or <code>null</code> if no active selection
      * @param listeners the list of listeners to notify
      */
-    protected void fireSelection(final IWorkbenchPart part, final ISelection sel) {
+	protected void fireSelection(@Nullable final IWorkbenchPart part, @Nullable final ISelection sel) {
 		for (final ISelectionListener l : fListeners) {
-            if ((part != null && sel != null)
-                    || l instanceof INullSelectionListener) {
+			if (part != null && sel != null) {
+				SafeRunner.run(new SafeRunnable() {
+					@Override
+					public void run() {
+						l.selectionChanged(part, sel);
+					}
+				});
+			} else if (l instanceof INullSelectionListener) {
                 SafeRunner.run(new SafeRunnable() {
                     @Override
 					public void run() {
-                        l.selectionChanged(part, sel);
+						((INullSelectionListener) l).selectionChanged(part, sel);
                     }
                 });
             }
@@ -129,15 +136,20 @@
      * @param sel the selection or <code>null</code> if no active selection
      * @param listeners the list of listeners to notify
      */
-    protected void firePostSelection(final IWorkbenchPart part,
-            final ISelection sel) {
+	protected void firePostSelection(@Nullable final IWorkbenchPart part, @Nullable final ISelection sel) {
 		for (final ISelectionListener l : postListeners) {
-            if ((part != null && sel != null)
-                    || l instanceof INullSelectionListener) {
+			if (part != null && sel != null) {
+				SafeRunner.run(new SafeRunnable() {
+					@Override
+					public void run() {
+						l.selectionChanged(part, sel);
+					}
+				});
+			} else if (l instanceof INullSelectionListener) {
                 SafeRunner.run(new SafeRunnable() {
                     @Override
 					public void run() {
-                        l.selectionChanged(part, sel);
+						((INullSelectionListener) l).selectionChanged(part, sel);
                     }
                 });
             }
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/AbstractSelectionService.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/AbstractSelectionService.java
index 08471cb..4f28b20 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/AbstractSelectionService.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/AbstractSelectionService.java
@@ -12,6 +12,7 @@
 
 import java.util.Hashtable;
 import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jface.viewers.IPostSelectionProvider;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -117,15 +118,17 @@
      * @param part the part or <code>null</code> if no active part
      * @param sel the selection or <code>null</code> if no active selection
      */
-    protected void fireSelection(final IWorkbenchPart part, final ISelection sel) {
+	protected void fireSelection(@Nullable final IWorkbenchPart part, @Nullable final ISelection sel) {
 		for (final ISelectionListener l : listeners) {
-			if ((part != null && sel != null) || l instanceof INullSelectionListener) {
-                try {
+			try {
+				if (l instanceof INullSelectionListener) {
+					((INullSelectionListener) l).selectionChanged(part, sel);
+				} else if (part != null && sel != null) {
                     l.selectionChanged(part, sel);
-                } catch (Exception e) {
-                    WorkbenchPlugin.log(e);
-                }
-            }
+				}
+			} catch (Exception e) {
+				WorkbenchPlugin.log(e);
+			}
         }
     }
 
@@ -135,18 +138,19 @@
      * @param part the part or <code>null</code> if no active part
      * @param sel the selection or <code>null</code> if no active selection
      */
-    protected void firePostSelection(final IWorkbenchPart part,
-            final ISelection sel) {
+	protected void firePostSelection(@Nullable final IWorkbenchPart part, @Nullable final ISelection sel) {
 		for (final ISelectionListener l : postListeners) {
-			if ((part != null && sel != null) || l instanceof INullSelectionListener) {
-                try {
-                    l.selectionChanged(part, sel);
-                } catch (Exception e) {
-                    WorkbenchPlugin.log(e);
-                }
-            }
-        }
-    }
+			try {
+				if (l instanceof INullSelectionListener) {
+					((INullSelectionListener) l).selectionChanged(part, sel);
+				} else if (part != null && sel != null) {
+					l.selectionChanged(part, sel);
+				}
+			} catch (Exception e) {
+				WorkbenchPlugin.log(e);
+			}
+		}
+	}
 
     /**
      * Returns the per-part selection tracker for the given part id.
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorReference.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorReference.java
index f68a4dc..739f349 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorReference.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorReference.java
@@ -20,6 +20,7 @@
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+import org.eclipse.core.runtime.Assert;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.core.runtime.IConfigurationElement;
@@ -129,16 +130,18 @@
 
 		// If the editor hasn't been rendered yet then see if we can grab the
 		// info from the model
-		if (editor == null && getModel() != null) {
-			String savedState = getModel().getPersistedState().get(MEMENTO_KEY);
-			if (savedState != null) {
-				StringReader sr = new StringReader(savedState);
-				try {
-					XMLMemento memento = XMLMemento.createReadRoot(sr);
-					return memento;
-				} catch (WorkbenchException e) {
-					WorkbenchPlugin.log(e);
-					return null;
+		if (editor == null) {
+			if (getModel() != null) {
+				String savedState = getModel().getPersistedState().get(MEMENTO_KEY);
+				if (savedState != null) {
+					StringReader sr = new StringReader(savedState);
+					try {
+						XMLMemento memento = XMLMemento.createReadRoot(sr);
+						return memento;
+					} catch (WorkbenchException e) {
+						WorkbenchPlugin.log(e);
+						return null;
+					}
 				}
 			}
 			return null;
@@ -262,6 +265,7 @@
 			throw new PartInitException(NLS.bind(
 					WorkbenchMessages.EditorManager_no_input_factory_ID, editorId, editorName));
 		}
+		Assert.isNotNull(inputMem);
 		IAdaptable input = null;
 		IElementFactory factory = PlatformUI.getWorkbench().getElementFactory(factoryID);
 		if (factory == null) {
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/NavigationHistory.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/NavigationHistory.java
index 7dc7463..16a769b 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/NavigationHistory.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/NavigationHistory.java
@@ -173,7 +173,7 @@
     }
 
     private Display getDisplay() {
-        return page.getWorkbenchWindow().getShell().getDisplay();
+		return page.getWorkbenchWindow().getWorkbench().getDisplay();
     }
 
     private boolean isPerTabHistoryEnabled() {
@@ -586,9 +586,10 @@
     void restoreState(IMemento memento) {
         IMemento editorsMem = memento.getChild(IWorkbenchConstants.TAG_EDITORS);
         IMemento items[] = memento.getChildren(IWorkbenchConstants.TAG_ITEM);
-        if (items.length == 0 || editorsMem == null) {
-            if (page.getActiveEditor() != null) {
-				markLocation(page.getActiveEditor());
+		IEditorPart activeEditor = page.getActiveEditor();
+		if (items.length == 0 || editorsMem == null) {
+            if (activeEditor != null) {
+				markLocation(activeEditor);
 			}
             return;
         }
@@ -603,8 +604,12 @@
 
         for (int i = 0; i < items.length; i++) {
             IMemento item = items[i];
-            int index = item.getInteger(IWorkbenchConstants.TAG_INDEX)
-                    .intValue();
+			Integer indexValue = item.getInteger(IWorkbenchConstants.TAG_INDEX);
+			if (indexValue == null) {
+				// should never happen
+				continue;
+			}
+			int index = indexValue.intValue();
             NavigationHistoryEditorInfo info = editorsInfo[index];
             info.refCount++;
             NavigationHistoryEntry entry = new NavigationHistoryEntry(info,
@@ -618,7 +623,7 @@
 
         final NavigationHistoryEntry entry = getEntry(activeEntry);
         if (entry != null && entry.editorInfo.editorInput != null) {
-            if (page.getActiveEditor() == page
+            if (activeEditor == page
                     .findEditor(entry.editorInfo.editorInput)) {
             	StartupThreading.runWithoutExceptions(new StartupRunnable() {
 
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartSite.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartSite.java
index 357251c..41ab1f0 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartSite.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartSite.java
@@ -15,6 +15,7 @@
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Iterator;
+import org.eclipse.core.runtime.Assert;
 import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.e4.core.contexts.ContextFunction;
@@ -402,7 +403,9 @@
 	 */
 	@Override
 	public IWorkbenchPage getPage() {
-		return getWorkbenchWindow().getActivePage();
+		IWorkbenchPage activePage = getWorkbenchWindow().getActivePage();
+		Assert.isNotNull(activePage);
+		return activePage;
 	}
 
 
@@ -450,7 +453,9 @@
 			// IWorkbenchSite.getShell() was called outside the UI thread. Fix
 			// this code.")); //$NON-NLS-1$
 
-			return getWorkbenchWindow().getShell();
+			Shell shell = getWorkbenchWindow().getShell();
+			Assert.isNotNull(shell);
+			return shell;
 		}
 
 		Control control = (Control) model.getWidget();
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WWinActionBars.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WWinActionBars.java
index 4c11d67..68df2e2 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WWinActionBars.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WWinActionBars.java
@@ -10,7 +10,6 @@
  *******************************************************************************/
 package org.eclipse.ui.internal;
 
-import org.eclipse.core.runtime.Assert;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.ICoolBarManager;
 import org.eclipse.jface.action.IMenuManager;
@@ -92,8 +91,7 @@
     @Override
 	public IToolBarManager getToolBarManager() {
         // This should never be called
-        Assert.isTrue(false);
-        return null;
+		throw new UnsupportedOperationException();
     }
 
     /**
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java
index 29808c5..71615de 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java
@@ -386,7 +386,7 @@
 	 *
 	 * @since 3.0
 	 */
-	private Display display;
+	private final Display display;
 
 	private boolean workbenchAutoSave = true;
 
@@ -416,7 +416,7 @@
 	 *
 	 * @since 3.0
 	 */
-	private WorkbenchAdvisor advisor;
+	private final WorkbenchAdvisor advisor;
 
 	/**
 	 * Object for configuring the workbench. Lazily initialized to an instance
@@ -430,7 +430,7 @@
 	/**
 	 * ExtensionEventHandler handles extension life-cycle events.
 	 */
-	private ExtensionEventHandler extensionEventHandler;
+	private final ExtensionEventHandler extensionEventHandler;
 
 	/**
 	 * A count of how many large updates are going on. This tracks nesting of
@@ -457,17 +457,17 @@
 	/**
 	 * Listener list for registered IWorkbenchListeners .
 	 */
-	private ListenerList<IWorkbenchListener> workbenchListeners = new ListenerList<>(ListenerList.IDENTITY);
+	private final ListenerList<IWorkbenchListener> workbenchListeners = new ListenerList<>(ListenerList.IDENTITY);
 
 	private ServiceRegistration workbenchService;
 
-	private MApplication application;
+	private final MApplication application;
 
-	private IEclipseContext e4Context;
+	private final IEclipseContext e4Context;
 
-	private IEventBroker eventBroker;
+	private final IEventBroker eventBroker;
 
-	private IExtensionRegistry registry;
+	private final IExtensionRegistry registry;
 
 	boolean initializationDone = false;
 
@@ -477,7 +477,7 @@
 
 	private Job autoSaveJob;
 
-	private String id;
+	private final String id;
 	private ServiceRegistration<?> e4WorkbenchService;
 
 
@@ -1469,8 +1469,16 @@
 			return iWorkbenchWindow;
 		}
 		// otherwise create new IWorkbenchWindow instance
-		return createWorkbenchWindow(getDefaultPageInput(), getPerspectiveRegistry()
-				.findPerspectiveWithId(getPerspectiveRegistry().getDefaultPerspective()),
+		String defaultPerspectiveId = getPerspectiveRegistry().getDefaultPerspective();
+		if (defaultPerspectiveId == null) {
+			return null;
+		}
+		IPerspectiveDescriptor defaultPerspective = getPerspectiveRegistry()
+				.findPerspectiveWithId(defaultPerspectiveId);
+		if (defaultPerspective == null) {
+			return null;
+		}
+		return createWorkbenchWindow(getDefaultPageInput(), defaultPerspective,
 				activeWindow, false);
 	}
 
@@ -1909,6 +1917,7 @@
 					for (Object removed : UIEvents.asIterable(event,
 							UIEvents.EventTags.OLD_VALUE)) {
 						MWindow window = (MWindow) removed;
+						Assert.isNotNull(window, "object was removed"); //$NON-NLS-1$
 						IEclipseContext windowContext = window.getContext();
 						if (windowContext != null) {
 							IWorkbenchWindow wwindow = windowContext.get(IWorkbenchWindow.class);
@@ -2566,8 +2575,9 @@
 	@Override
 	public IWorkbenchWindow openWorkbenchWindow(String perspectiveId, IAdaptable input)
 			throws WorkbenchException {
-		IPerspectiveDescriptor descriptor = getPerspectiveRegistry().findPerspectiveWithId(
-				perspectiveId);
+		IPerspectiveDescriptor descriptor = perspectiveId != null
+				? getPerspectiveRegistry().findPerspectiveWithId(perspectiveId)
+				: null;
 		try {
 			MWindow window = BasicFactoryImpl.eINSTANCE.createTrimmedWindow();
 			return openWorkbenchWindow(input, descriptor, window, true);
@@ -2988,14 +2998,14 @@
 
 		if (targetWindow != null) {
 			IWorkbenchPage page = targetWindow.getActivePage();
-			if (activate(perspectiveId, page, input)) {
+			if (page != null && activate(perspectiveId, page, input)) {
 				return page;
 			}
 		}
 
 		for (IWorkbenchWindow window : getWorkbenchWindows()) {
 			IWorkbenchPage page = window.getActivePage();
-			if (activate(perspectiveId, page, input)) {
+			if (page != null && activate(perspectiveId, page, input)) {
 				return page;
 			}
 		}
@@ -3006,7 +3016,10 @@
 			int mode = store.getInt(IPreferenceConstants.OPEN_PERSP_MODE);
 
 			if (IPreferenceConstants.OPM_NEW_WINDOW != mode) {
-				targetWindow.getShell().open();
+				// XXX: are we sure there's a shell? vestige from pre-model wb?
+				Shell shell = targetWindow.getShell();
+				Assert.isNotNull(shell);
+				shell.open();
 				if (page == null) {
 					page = targetWindow.openPage(perspectiveId, input);
 				} else {
@@ -3016,7 +3029,10 @@
 			}
 		}
 
-		return openWorkbenchWindow(perspectiveId, input).getActivePage();
+		IWorkbenchWindow newWindow = openWorkbenchWindow(perspectiveId, input);
+		IWorkbenchPage newWindowPage = newWindow.getActivePage();
+		Assert.isNotNull(newWindowPage);
+		return newWindowPage;
 	}
 
 	/*
@@ -3489,7 +3505,9 @@
 		menuSourceProvider.addShowingMenus(menuIds, localSelection, localEditorInput);
 		Map currentState = menuSourceProvider.getCurrentState();
 		for (String key : menuSourceProvider.getProvidedSourceNames()) {
-			e4Context.set(key, currentState.get(key));
+			if (currentState != null) {
+				e4Context.set(key, currentState.get(key));
+			}
 		}
 	}
 
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java
index af02a2e..82269cd 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java
@@ -371,6 +371,7 @@
 
 	public static String WorkbenchWindow_close;
 	public static String WorkbenchPage_ErrorCreatingPerspective;
+	public static String WorkbenchPage_NoDefaultPerspective;
 
 	public static String SelectWorkingSetAction_text;
 	public static String SelectWorkingSetAction_toolTip;
@@ -1006,7 +1007,4 @@
 	// Util
 	public static String Util_List;
 	public static String Util_listNull;
-
-
-
 }
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java
index 217db7d..d88c219 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPartReference.java
@@ -17,6 +17,7 @@
 import java.util.Iterator;
 import java.util.Map;
 import org.eclipse.core.runtime.Adapters;
+import org.eclipse.core.runtime.Assert;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.ListenerList;
 import org.eclipse.e4.core.contexts.IEclipseContext;
@@ -43,7 +44,6 @@
 import org.eclipse.ui.IWorkbenchPartConstants;
 import org.eclipse.ui.IWorkbenchPartReference;
 import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.internal.e4.compatibility.CompatibilityPart;
 import org.eclipse.ui.internal.misc.UIListenerLogging;
 import org.eclipse.ui.internal.util.Util;
@@ -324,7 +324,10 @@
 	@Override
 	public final Image getTitleImage() {
 		if (isDisposed()) {
-			return getSite().getWorkbenchWindow().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_DEF_VIEW);
+			Image defaultImage = getSite().getWorkbenchWindow().getWorkbench().getSharedImages()
+					.getImage(ISharedImages.IMG_DEF_VIEW);
+			Assert.isNotNull(defaultImage);
+			return defaultImage;
 		}
 
 		WorkbenchWindow wbw = (WorkbenchWindow) getSite().getWorkbenchWindow();
@@ -336,7 +339,10 @@
 			}
 		}
 
-		return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_DEF_VIEW);
+		Image defaultImage = getSite().getWorkbenchWindow().getWorkbench().getSharedImages()
+				.getImage(ISharedImages.IMG_DEF_VIEW);
+		Assert.isNotNull(defaultImage);
+		return defaultImage;
 	}
 
     /* package */ void fireVisibilityChange() {
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java
index 4497a7a..9699eee 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java
@@ -778,7 +778,7 @@
 			preferenceStore.setValue(IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS,
 					enableAnimations);
 
-			getShell().setData(this);
+			shell.setData(this);
 			trackShellActivation();
 		} finally {
 			HandlerServiceImpl.pop();
@@ -826,7 +826,10 @@
 		}
 
 		if (perspective == null) {
-			perspective = registry.findPerspectiveWithId(registry.getDefaultPerspective());
+			String defaultPerspectiveId = registry.getDefaultPerspective();
+			if (defaultPerspectiveId != null) {
+				perspective = registry.findPerspectiveWithId(defaultPerspectiveId);
+			}
 		}
 
 		// the perspective stack doesn't have a selected element what means that
@@ -2089,7 +2092,11 @@
 
 	@Override
 	public IWorkbenchPage openPage(IAdaptable input) throws WorkbenchException {
-		return openPage(workbench.getPerspectiveRegistry().getDefaultPerspective(), input);
+		String defaultPerspectiveId = workbench.getPerspectiveRegistry().getDefaultPerspective();
+		if (defaultPerspectiveId == null) {
+			throw new WorkbenchException(WorkbenchMessages.WorkbenchPage_NoDefaultPerspective);
+		}
+		return openPage(defaultPerspectiveId, input);
 	}
 
 	/*
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/cpd/CustomizeActionBars.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/cpd/CustomizeActionBars.java
index 9859e5d..bec7a9c 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/cpd/CustomizeActionBars.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/cpd/CustomizeActionBars.java
@@ -120,7 +120,7 @@
 
 	@Override
 	public IToolBarManager getToolBarManager() {
-		return null;
+		throw new UnsupportedOperationException();
 	}
 
 	@Override
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/SelectionService.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/SelectionService.java
index 2fe7a35..eedbde2f 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/SelectionService.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/SelectionService.java
@@ -26,6 +26,7 @@
 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
 import org.eclipse.e4.ui.services.IServiceConstants;
 import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.ISelectionProvider;
@@ -232,22 +233,26 @@
 		targetedPostSelectionListeners.clear();
 	}
 
-	private void notifyListeners(IWorkbenchPart workbenchPart, ISelection selection,
+	private void notifyListeners(@Nullable IWorkbenchPart workbenchPart, @Nullable ISelection selection,
 			ListenerList<ISelectionListener> listenerList) {
 		for (ISelectionListener listener : listenerList) {
-			if (selection != null || listener instanceof INullSelectionListener) {
+			if (listener instanceof INullSelectionListener) {
+				((INullSelectionListener) listener).selectionChanged(workbenchPart, selection);
+			} else if (workbenchPart != null && selection != null) {
 				listener.selectionChanged(workbenchPart, selection);
 			}
 		}
 	}
 
-	private void notifyListeners(IWorkbenchPart workbenchPart, ISelection selection, String id,
+	private void notifyListeners(IWorkbenchPart workbenchPart, @Nullable ISelection selection, String id,
 			Map<String, Set<ISelectionListener>> listenerMap) {
 		if (id != null) {
 			Set<ISelectionListener> listeners = listenerMap.get(id);
 			if (listeners != null) {
 				for (ISelectionListener listener : listeners) {
-					if (selection != null || listener instanceof INullSelectionListener) {
+					if (listener instanceof INullSelectionListener) {
+						((INullSelectionListener) listener).selectionChanged(workbenchPart, selection);
+					} else if (selection != null) {
 						listener.selectionChanged(workbenchPart, selection);
 					}
 				}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/ActionDelegateHandlerProxy.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/ActionDelegateHandlerProxy.java
index 865857d..081c005 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/ActionDelegateHandlerProxy.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/ActionDelegateHandlerProxy.java
@@ -22,6 +22,7 @@
 import org.eclipse.core.expressions.EvaluationResult;
 import org.eclipse.core.expressions.Expression;
 import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.core.runtime.Assert;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.ISafeRunnable;
@@ -471,12 +472,13 @@
 				if ((objectDelegate != null) && (activePart != null)) {
 					objectDelegate.setActivePart(action, activePart);
 					updateActivePart(activePart);
-				} else if (editorDelegate != null) {
+				} else if (editorDelegate != null && (activeEditor != null)) {
 					editorDelegate.setActiveEditor(action, activeEditor);
 					updateActivePart(activeEditor);
 				} else if ((viewId != null) && (page != null)
 						&& (viewDelegate != null)) {
 					final IViewPart viewPart = page.findView(viewId);
+					Assert.isNotNull(viewPart); // checked above
 					viewDelegate.init(viewPart);
 				} else if (windowDelegate != null) {
 					windowDelegate.init(window);
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/ClosePerspectiveHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/ClosePerspectiveHandler.java
index a61f243..7a83d49 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/ClosePerspectiveHandler.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/ClosePerspectiveHandler.java
@@ -37,7 +37,10 @@
 				String value = (String) parameters
 						.get(IWorkbenchCommandConstants.WINDOW_CLOSE_PERSPECTIVE_PARM_ID);
 				if (value == null) {
-					page.closePerspective(page.getPerspective(), true, true);
+					IPerspectiveDescriptor perspective = page.getPerspective();
+					if (perspective != null) {
+						page.closePerspective(perspective, true, true);
+					}
 				} else {
 					IPerspectiveDescriptor perspective = activeWorkbenchWindow
 							.getWorkbench().getPerspectiveRegistry()
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties
index 6a5d8ab..0ac5be2 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties
@@ -318,6 +318,7 @@
 
 WorkbenchWindow_close = &Close
 WorkbenchPage_ErrorCreatingPerspective = Unable to create perspective ''{0}''.  There is no corresponding perspective extension.
+WorkbenchPage_NoDefaultPerspective = There is no default perspective.
 
 SelectWorkingSetAction_text= Select &Working Set...
 SelectWorkingSetAction_toolTip= Select a working set
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/part/StatusPart.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/part/StatusPart.java
index 2f4cde8..14643d0 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/part/StatusPart.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/part/StatusPart.java
@@ -29,6 +29,8 @@
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.internal.WorkbenchMessages;
 import org.eclipse.ui.internal.WorkbenchPlugin;
@@ -196,8 +198,9 @@
 			public void widgetSelected(SelectionEvent e) {
 				try {
 					IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-					if(window != null && window.getActivePage() != null) {
-						window.getActivePage().showView(LOG_VIEW_ID);
+					IWorkbenchPage page = window != null ? window.getActivePage() : null;
+					if (page != null) {
+						page.showView(LOG_VIEW_ID);
 					}
 				} catch (CoreException ce) {
 					StatusManager.getManager().handle(ce, WorkbenchPlugin.PI_WORKBENCH);
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorRegistry.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorRegistry.java
index 6d7db57..236b45a 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorRegistry.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorRegistry.java
@@ -35,6 +35,7 @@
 import java.util.Map.Entry;
 import java.util.StringTokenizer;
 import org.eclipse.core.commands.common.EventManager;
+import org.eclipse.core.runtime.Assert;
 import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.IExtension;
 import org.eclipse.core.runtime.IExtensionPoint;
@@ -325,7 +326,9 @@
 	public IEditorDescriptor getDefaultEditor() {
         // the default editor will always be the system external editor
         // this should never return null
-        return findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
+		IEditorDescriptor descriptor = findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
+		Assert.isNotNull(descriptor);
+		return descriptor;
     }
 
     @Override
@@ -1082,7 +1085,7 @@
 
     @Override
 	public void setDefaultEditor(String fileName, String editorId) {
-		IEditorDescriptor desc = findEditor(editorId);
+		IEditorDescriptor desc = editorId != null ? findEditor(editorId) : null;
 		setDefaultEditor(fileName, desc);
 	}
 
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/FileEditorMapping.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/FileEditorMapping.java
index 6aca357..4b9b6b0 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/FileEditorMapping.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/FileEditorMapping.java
@@ -17,6 +17,7 @@
 import java.util.Iterator;
 import java.util.List;
 import org.eclipse.core.runtime.Assert;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.osgi.util.TextProcessor;
 import org.eclipse.ui.IEditorDescriptor;
@@ -235,12 +236,16 @@
      *
      * @param editor the editor to be set as default
      */
-	public void setDefaultEditor(IEditorDescriptor editor) {
-		Assert.isNotNull(editor);
-        editors.remove(editor);
-        editors.add(0, editor);
-        declaredDefaultEditors.remove(editor);
-        declaredDefaultEditors.add(0, editor);
+	public void setDefaultEditor(@Nullable IEditorDescriptor editor) {
+		if (editor != null) {
+			editors.remove(editor);
+			editors.add(0, editor);
+			declaredDefaultEditors.remove(editor);
+			declaredDefaultEditors.add(0, editor);
+		} else {
+			deletedEditors.addAll(editors);
+			editors.clear();
+		}
     }
 
     /**
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/services/WorkbenchSourceProvider.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/services/WorkbenchSourceProvider.java
index 953592b..b2f83da 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/services/WorkbenchSourceProvider.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/services/WorkbenchSourceProvider.java
@@ -16,6 +16,8 @@
 import java.util.Map;
 import org.eclipse.core.expressions.IEvaluationContext;
 import org.eclipse.core.runtime.Adapters;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionProvider;
@@ -108,6 +110,7 @@
 	}
 
 	@Override
+	@NonNull
 	public Map getCurrentState() {
 
 		final Map currentState = new HashMap();
@@ -130,12 +133,10 @@
 		Object object = currentState.get(ISources.ACTIVE_PART_NAME);
 		if (object instanceof IWorkbenchPart) {
 			IWorkbenchPart part = (IWorkbenchPart) object;
-			if (part.getSite() != null
-					&& part.getSite().getSelectionProvider() != null) {
+			ISelectionProvider provider = part.getSite() != null ? part.getSite().getSelectionProvider() : null;
+			if (provider != null) {
 				sources = ISources.ACTIVE_CURRENT_SELECTION;
-				ISelection currentSelection = part.getSite()
-						.getSelectionProvider()
-						.getSelection();
+				ISelection currentSelection = provider.getSelection();
 				currentState.put(ISources.ACTIVE_CURRENT_SELECTION_NAME,
 						currentSelection);
 			}
@@ -144,7 +145,7 @@
 	}
 
 	@Override
-	public final void selectionChanged(final IWorkbenchPart part,
+	public final void selectionChanged(@Nullable final IWorkbenchPart part,
 			final ISelection newSelection) {
 
 		if (Util.equals(selection, newSelection))
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/util/ConfigurationElementMemento.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/util/ConfigurationElementMemento.java
index 9bd5873..c8b078b 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/util/ConfigurationElementMemento.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/util/ConfigurationElementMemento.java
@@ -29,12 +29,12 @@
 
     @Override
 	public IMemento createChild(String type) {
-        return null;
+		throw new UnsupportedOperationException();
     }
 
     @Override
 	public IMemento createChild(String type, String id) {
-        return null;
+		throw new UnsupportedOperationException();
     }
 
     @Override
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/EditorPart.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/EditorPart.java
index 5e79a34..f093dd1 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/EditorPart.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/EditorPart.java
@@ -172,11 +172,11 @@
 
 
     /*
-	 * Returns whether the "save as" operation is supported by this editor. 
+	 * Returns whether the "save as" operation is supported by this editor.
 	 * <p>
 	 * Subclasses must override this method to implement the open-save-close
 	 * lifecycle for an editor. For greater details, see
-	 * <code>IEditorPart</code> 
+	 * <code>IEditorPart</code>
 	 * </p>
 	 *
 	 * @see IEditorPart
@@ -247,7 +247,7 @@
             compatibilityTitleListener = null;
         }
 
-        super.setContentDescription(description);
+		super.setContentDescription(description);
     }
 
     @Override
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/MultiEditorInput.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/MultiEditorInput.java
index dde7be8..5af276f 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/MultiEditorInput.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/MultiEditorInput.java
@@ -66,7 +66,7 @@
      */
     @Override
 	public ImageDescriptor getImageDescriptor() {
-        return null;
+		return ImageDescriptor.getMissingImageDescriptor();
     }
 
     /*
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/PageBookView.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/PageBookView.java
index 47e8661..339a215 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/PageBookView.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/PageBookView.java
@@ -1021,27 +1021,34 @@
 	private IPartListener2 partListener = new IPartListener2() {
 		@Override
 		public void partActivated(IWorkbenchPartReference partRef) {
-			if (partRef == null) {
-				WorkbenchPlugin.log("partRef is null in PageBookView partActivated"); //$NON-NLS-1$
-				return;
-			}
 			IWorkbenchPart part = partRef.getPart(false);
-			PageBookView.this.partActivated(part);
+			if (part != null) {
+				PageBookView.this.partActivated(part);
+			}
 		}
 
 		@Override
 		public void partBroughtToTop(IWorkbenchPartReference partRef) {
-			PageBookView.this.partBroughtToTop(partRef.getPart(false));
+			IWorkbenchPart part = partRef.getPart(false);
+			if (part != null) {
+				PageBookView.this.partBroughtToTop(part);
+			}
 		}
 
 		@Override
 		public void partClosed(IWorkbenchPartReference partRef) {
-			PageBookView.this.partClosed(partRef.getPart(false));
+			IWorkbenchPart part = partRef.getPart(false);
+			if (part != null) {
+				PageBookView.this.partClosed(part);
+			}
 		}
 
 		@Override
 		public void partDeactivated(IWorkbenchPartReference partRef) {
-			PageBookView.this.partDeactivated(partRef.getPart(false));
+			IWorkbenchPart part = partRef.getPart(false);
+			if (part != null) {
+				PageBookView.this.partDeactivated(part);
+			}
 		}
 
 		@Override
@@ -1055,12 +1062,18 @@
 
 		@Override
 		public void partOpened(IWorkbenchPartReference partRef) {
-			PageBookView.this.partOpened(partRef.getPart(false));
+			IWorkbenchPart part = partRef.getPart(false);
+			if (part != null) {
+				PageBookView.this.partOpened(part);
+			}
 		}
 
 		@Override
 		public void partVisible(IWorkbenchPartReference partRef) {
-			PageBookView.this.partVisible(partRef.getPart(false));
+			IWorkbenchPart part = partRef.getPart(false);
+			if (part != null) {
+				PageBookView.this.partVisible(part);
+			}
 		}
 	};
 
@@ -1075,8 +1088,8 @@
 		}
 		// if we've minimized the editor stack, that's no reason to
 		// drop our content
-		if (getSite().getPage().getPartState(
-				getSite().getPage().getReference(part)) == IWorkbenchPage.STATE_MINIMIZED) {
+		IWorkbenchPartReference ref = getSite().getPage().getReference(part);
+		if (ref != null && getSite().getPage().getPartState(ref) == IWorkbenchPage.STATE_MINIMIZED) {
 			return;
 		}
 		// if we're switching from a part source in our own stack,
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/WorkbenchPart.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/WorkbenchPart.java
index 80dd7a9..0e380a7 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/WorkbenchPart.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/WorkbenchPart.java
@@ -22,6 +22,7 @@
 import org.eclipse.core.runtime.ListenerList;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.jface.util.IPropertyChangeListener;
@@ -359,7 +360,7 @@
      *
      * @since 3.0
      */
-    protected void setPartName(String partName) {
+	protected void setPartName(@NonNull String partName) {
 
         internalSetPartName(partName);
 
@@ -410,7 +411,7 @@
      *
      * @since 3.0
      */
-    protected void setContentDescription(String description) {
+	protected void setContentDescription(@NonNull String description) {
         internalSetContentDescription(description);
 
         setDefaultTitle();