Bug 19024 - [Perspectives] NPE when switching perspectives and reselecting
Summary: [Perspectives] NPE when switching perspectives and reselecting
Status: RESOLVED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P2 major (vote)
Target Milestone: ---   Edit
Assignee: Eduardo Pereira CLA
QA Contact:
URL:
Whiteboard:
Keywords: investigate
Depends on:
Blocks:
 
Reported: 2002-06-04 09:06 EDT by Tod Creasey CLA
Modified: 2002-11-25 15:41 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tod Creasey CLA 2002-06-04 09:06:53 EDT
F2

When I switched from the Resource to the java perspective and then selected a 
project I got the exception below. My workbench had all of Eclipse loaded as 
binaries except org.eclipse.ui which was source.

STEPS
1) Select a binary project in the Resource perspective
2) Switch to the Java Perspective
3) Select org.eclipse.ui

!ENTRY org.eclipse.ui 4 2 Jun 04, 2002 09:12:19.47
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.ui".
!STACK 0
java.lang.NullPointerException
	at 
	at org.eclipse.ui.internal.PluginAction.refreshEnablement
(PluginAction.java:170)
	at org.eclipse.ui.internal.PluginAction.selectionChanged
(PluginAction.java:232)
	at org.eclipse.ui.internal.PluginAction.selectionChanged
(PluginAction.java:252)
	at org.eclipse.ui.internal.AbstractSelectionService$3.run
(AbstractSelectionService.java:137)
	at org.eclipse.core.runtime.Platform.run(Platform.java(Compiled Code))
	at org.eclipse.core.runtime.Platform.run(Platform.java(Compiled Code))
	at org.eclipse.ui.internal.AbstractSelectionService.fireSelection
(AbstractSelectionService.java:135)
	at org.eclipse.ui.internal.AbstractSelectionService.partActivated
(AbstractSelectionService.java:237)
	at org.eclipse.ui.internal.WWinPartService.partActivated
(WWinPartService.java:103)
	at org.eclipse.ui.internal.PartListenerList$1.run
(PartListenerList.java:39)
	at org.eclipse.core.runtime.Platform.run(Platform.java(Compiled Code))
	at org.eclipse.core.runtime.Platform.run(Platform.java(Compiled Code))
	at org.eclipse.ui.internal.PartListenerList.firePartActivated
(PartListenerList.java:37)
	at org.eclipse.ui.internal.WorkbenchPage.firePartActivated
(WorkbenchPage.java:1032)
	at org.eclipse.ui.internal.WorkbenchPage.setActivePart
(WorkbenchPage.java:2040)
	at org.eclipse.ui.internal.WorkbenchPage.requestActivation
(WorkbenchPage.java:1819)
	at org.eclipse.ui.internal.PartPane.requestActivation(PartPane.java:332)
	at org.eclipse.ui.internal.PartPane.handleEvent(PartPane.java:306)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java(Compiled Code))
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java(Compiled Code))
	at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:757)
	at org.eclipse.swt.widgets.Shell.WM_MOUSEACTIVATE(Shell.java:1117)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled 
Code))
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java
(Compiled Code))
	at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled 
Code))
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled 
Code))
	at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled 
Code))
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled 
Code))
	at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled 
Code))
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled 
Code))
	at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled 
Code))
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled 
Code))
	at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled 
Code))
	at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
	at org.eclipse.swt.widgets.Tree.callWindowProc(Tree.java(Compiled Code))
	at org.eclipse.swt.widgets.Tree.callWindowProc(Tree.java(Compiled Code))
	at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled 
Code))
	at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled 
Code))
	at org.eclipse.swt.internal.win32.OS.PeekMessageW(Native Method)
	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.ui.internal.Workbench.runEventLoop(Workbench.java
(Compiled Code))
	at org.eclipse.ui.internal.Workbench.run(Workbench.java:1160)
	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:244)
	at org.eclipse.core.launcher.Main.run(Main.java:693)
	at org.eclipse.core.launcher.Main.main(Main.java:526)
!ENTRY org.eclipse.ui 4 2 Jun 04, 2002 09:12:19.567
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.ui".
!STACK 0
java.lang.NullPointerException
	at 
	at org.eclipse.ui.internal.PluginAction.refreshEnablement
(PluginAction.java:170)
	at org.eclipse.ui.internal.PluginAction.selectionChanged
(PluginAction.java:232)
	at org.eclipse.ui.internal.PluginAction.selectionChanged
(PluginAction.java:252)
	at org.eclipse.ui.internal.AbstractSelectionService$3.run
(AbstractSelectionService.java:137)
	at org.eclipse.core.runtime.Platform.run(Platform.java(Compiled Code))
	at org.eclipse.core.runtime.Platform.run(Platform.java(Compiled Code))
	at org.eclipse.ui.internal.AbstractSelectionService.fireSelection
(AbstractSelectionService.java:135)
	at org.eclipse.ui.internal.AbstractSelectionService$1.selectionChanged
(AbstractSelectionService.java:50)
	at org.eclipse.jface.viewers.Viewer.fireSelectionChanged
(Viewer.java:147)
	at org.eclipse.jface.viewers.StructuredViewer.updateSelection
(StructuredViewer.java:1153)
	at org.eclipse.jface.viewers.StructuredViewer.handleSelect
(StructuredViewer.java:544)
	at org.eclipse.jface.viewers.StructuredViewer$1.widgetSelected
(StructuredViewer.java:568)
	at org.eclipse.jface.util.OpenStrategy.fireSelectionEvent
(OpenStrategy.java:171)
	at org.eclipse.jface.util.OpenStrategy.access$3(OpenStrategy.java:168)
	at org.eclipse.jface.util.OpenStrategy$1.handleEvent
(OpenStrategy.java:297)
	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:558)
	at org.eclipse.jface.window.Window.open(Window.java:538)
	at org.eclipse.jface.dialogs.MessageDialog.openError
(MessageDialog.java:318)
	at org.eclipse.jface.util.SafeRunnable.handleException
(SafeRunnable.java:42)
	at org.eclipse.ui.internal.AbstractSelectionService$3.handleException
(AbstractSelectionService.java:140)
	at org.eclipse.core.internal.runtime.InternalPlatform.handleException
(InternalPlatform.java:427)
	at org.eclipse.core.runtime.Platform.run(Platform.java(Compiled Code))
	at org.eclipse.core.runtime.Platform.run(Platform.java(Compiled Code))
	at org.eclipse.ui.internal.AbstractSelectionService.fireSelection
(AbstractSelectionService.java:135)
	at org.eclipse.ui.internal.AbstractSelectionService.partActivated
(AbstractSelectionService.java:237)
	at org.eclipse.ui.internal.WWinPartService.partActivated
(WWinPartService.java:103)
	at org.eclipse.ui.internal.PartListenerList$1.run
(PartListenerList.java:39)
	at org.eclipse.core.runtime.Platform.run(Platform.java(Compiled Code))
	at org.eclipse.core.runtime.Platform.run(Platform.java(Compiled Code))
	at org.eclipse.ui.internal.PartListenerList.firePartActivated
(PartListenerList.java:37)
	at org.eclipse.ui.internal.WorkbenchPage.firePartActivated
(WorkbenchPage.java:1032)
	at org.eclipse.ui.internal.WorkbenchPage.setActivePart
(WorkbenchPage.java:2040)
	at org.eclipse.ui.internal.WorkbenchPage.requestActivation
(WorkbenchPage.java:1819)
	at org.eclipse.ui.internal.PartPane.requestActivation(PartPane.java:332)
	at org.eclipse.ui.internal.PartPane.handleEvent(PartPane.java:306)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java(Compiled Code))
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java(Compiled Code))
	at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:757)
	at org.eclipse.swt.widgets.Shell.WM_MOUSEACTIVATE(Shell.java:1117)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled 
Code))
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java
(Compiled Code))
	at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled 
Code))
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled 
Code))
	at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled 
Code))
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled 
Code))
	at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled 
Code))
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled 
Code))
	at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled 
Code))
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled 
Code))
	at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled 
Code))
	at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
	at org.eclipse.swt.widgets.Tree.callWindowProc(Tree.java(Compiled Code))
	at org.eclipse.swt.widgets.Tree.callWindowProc(Tree.java(Compiled Code))
	at org.eclipse.swt.widgets.Control.windowProc(Control.java(Compiled 
Code))
	at org.eclipse.swt.widgets.Display.windowProc(Display.java(Compiled 
Code))
	at org.eclipse.swt.internal.win32.OS.PeekMessageW(Native Method)
	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.ui.internal.Workbench.runEventLoop(Workbench.java
(Compiled Code))
	at org.eclipse.ui.internal.Workbench.run(Workbench.java:1160)
	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:244)
	at org.eclipse.core.launcher.Main.run(Main.java:693)
	at org.eclipse.core.launcher.Main.main(Main.java:526)
Comment 1 Nick Edgar CLA 2002-06-04 17:14:57 EDT
I could not reproduce this.  Can you?  Which views were you using?
Comment 2 Tod Creasey CLA 2002-06-05 08:24:21 EDT
I was using a straight up Java Perspective and Resource Perspective. I had just 
imported the world from plug-ins and was switching back to the Java Perspective 
to look up a type.

I have tried replicating with no luck either.
Comment 3 Nick Edgar CLA 2002-06-05 13:14:21 EDT
Unfortunately the stacks are missing the top frame, so this may be hard to 
track down.
Comment 4 Nick Edgar CLA 2002-06-11 01:32:09 EDT
Line 170 in PluginAction.refreshEnablement is:
	delegate.selectionChanged(this, selection);

We have no way of knowing which delegate was the culprit, since this is not 
reproduceable.  

Is it possible that the selection itself was null?
refreshEnablement() simply refers to a field for the selection here, which is 
initialized to null and is only set in selectionChanged.
PluginAction implements INullSelectionListener so it allows null selections, 
however selectionChanged converts null to an empty selection.
createDelegate calls refreshEnablement() without calling selectionChanged, so 
that's one possible flow that could cause this.  But that's not what's 
indicated here: the stack goes through selectionChanged.
So this seems to indicate a failure in the delegate itself.

Could initialize the selection field with an empty selection, but there may be 
delegates relying on the current behaviour, and that would not fix this 
particular bug.

This is an area which should be protected by a SafeRunnable.
However, this is a fairly performance-sensitive area, so I would prefer not to 
make further changes here in 2.0.

Note that there is a SafeRunnable a bit earlier in the stack, for the 
selection service.  So it is handled, it just means that actions after one 
that fails will not get updated properly.

Comment 5 Nick Edgar CLA 2002-06-11 02:04:41 EDT
Checked all declarations of IActionDelegate.selectionChanged.
The only ones I found that made assumptions about the selection were in JDT-
Debug: 
- BreakpointToggleAction assumes it is non-null.
- BreakpointSuspendPolicyToggleAction assumes it is an IStructuredSelection.

But as noted above, in this case the selection must be non-null anyway.
Comment 6 Randy Giffen CLA 2002-08-12 10:42:17 EDT
Reopened for investigation
Comment 7 Eduardo Pereira CLA 2002-11-25 14:27:48 EST
Closing as WorksForMe. We do not have enough info here and I don't think this 
is still a problem.

Darin, do you guys have any idea why some times the top line of the exception 
is not printed?
Comment 8 Darin Wright CLA 2002-11-25 15:41:26 EST
Not sure why top line appears incomplete. We just read std error, and echo it.