Project: JDT
Bug 212263 [dnd] NPE if selection of SelectionTransfer is null or not a StructuredSelection
Reported: 2007-12-07 08:54:43 | Status: resolved fixed

I've written editor that has drag source with LocalSelectionTransfer. I have not set selection to the transfer and got this NPE while dragging element from my editor to the package explorer. I guess that we should perform safety check in drop target adapter. java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgUtils.getJavaElements(ReorgUtils.java:262) at org.eclipse.jdt.internal.ui.packageview.SelectionTransferDropAdapter.internalDetermineOperation(SelectionTransferDropAdapter.java:144) at org.eclipse.jdt.internal.ui.packageview.SelectionTransferDropAdapter.determineOperation(SelectionTransferDropAdapter.java:124) at org.eclipse.jdt.internal.ui.dnd.JdtViewerDropAdapter.doDropValidation(JdtViewerDropAdapter.java:184) at org.eclipse.jdt.internal.ui.dnd.JdtViewerDropAdapter.dragOver(JdtViewerDropAdapter.java:230) at org.eclipse.jface.util.DelegatingDropAdapter$2.run(DelegatingDropAdapter.java:191) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.core.runtime.Platform.run(Platform.java:857) at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:46) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:199) at org.eclipse.jface.util.DelegatingDropAdapter.dragOver(DelegatingDropAdapter.java:189) at org.eclipse.swt.dnd.DNDListener.handleEvent(DNDListener.java:80) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1521) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1545) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1530) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1321) at org.eclipse.swt.dnd.DropTarget.dragTrackingHandler(DropTarget.java:472) at org.eclipse.swt.dnd.DropTarget.DragTrackingHandler(DropTarget.java:257) at org.eclipse.swt.internal.carbon.OS.TrackDrag(Native Method) at org.eclipse.swt.dnd.DragSource.drag(DragSource.java:347) at org.eclipse.swt.dnd.DragSource$1.handleEvent(DragSource.java:163) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1521) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1545) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1530) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1321) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3401) at org.eclipse.swt.widgets.Control.sendTrackEvents(Control.java:2877) at org.eclipse.swt.widgets.Control.actionProc(Control.java:116) at org.eclipse.swt.widgets.Display.actionProc(Display.java:355) at org.eclipse.swt.internal.carbon.OS.CallNextEventHandler(Native Method) at org.eclipse.swt.widgets.Widget.kEventControlTrack(Widget.java:1072) at org.eclipse.swt.widgets.Control.kEventControlTrack(Control.java:1992) at org.eclipse.swt.widgets.Widget.controlProc(Widget.java:368) at org.eclipse.swt.widgets.Display.controlProc(Display.java:839) at org.eclipse.swt.internal.carbon.OS.SendEventToEventTarget(Native Method) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2983) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2395) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2359) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2225) at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:468) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:463) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:362) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:175) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:515) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:455) at org.eclipse.equinox.launcher.Main.run(Main.java:1193) at org.eclipse.equinox.launcher.Main.main(Main.java:1169)

Files changed in fix:
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/navigator/JavaDropAdapterAssistant.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/SelectionTransferDropAdapter.java