Project: Eclipse_Platform_UI
Bug 362501 [Compatibility] NPE when showing view with non-existant part class
Reported: 2011-10-31 11:17:14 | Status: verified fixed

BuildId: I20111028-1100 I'm getting an NPE when my code tries to open a view whose part class does not exist. The process seems to be: 1. CompatibilityPart#create() attempts to instantiate the part class (line 227) 2. The instantiation fails causing PartInitException to be thrown 3. The PartInitException exception is caught and the handling eventually calls at line 240 into CompatibilityView#disposeSite(). 4. #disposeSite assumes the site has been created but it has not as ViewReference#initialize() hadn't yet been been called in CompatibilityPart#create() I wondered if #disposeSite() should simply return if getReference().getSite() == null? Ful stack trace: Daemon Thread [Thread-1] (Suspended (exception NullPointerException)) CompatibilityView.disposeSite() line: 151 CompatibilityView(CompatibilityPart).create() line: 240 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 Method.invoke(Object, Object...) line: 597 MethodRequestor.execute() line: 56 InjectorImpl.processAnnotated(Class<Annotation>, Object, Class<?>, PrimaryObjectSupplier, PrimaryObjectSupplier, ArrayList<Class<?>>) line: 838 InjectorImpl.processAnnotated(Class<Annotation>, Object, Class<?>, PrimaryObjectSupplier, PrimaryObjectSupplier, ArrayList<Class<?>>) line: 818 InjectorImpl.inject(Object, PrimaryObjectSupplier, PrimaryObjectSupplier) line: 110 InjectorImpl.internalMake(Class<?>, PrimaryObjectSupplier, PrimaryObjectSupplier) line: 317 InjectorImpl.make(Class<T>, PrimaryObjectSupplier) line: 239 ContextInjectionFactory.make(Class<T>, IEclipseContext) line: 153 ReflectionContributionFactory.createFromBundle(Bundle, IEclipseContext, IEclipseContext, URI) line: 90 ReflectionContributionFactory.doCreate(String, IEclipseContext, IEclipseContext) line: 64 ReflectionContributionFactory.create(String, IEclipseContext) line: 53 ContributedPartRenderer.createWidget(MUIElement, Object) line: 141 PartRenderingEngine.createWidget(MUIElement, Object) line: 861 PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 615 PartRenderingEngine$6.run() line: 504 SafeRunner.run(ISafeRunnable) line: 42 PartRenderingEngine.createGui(MUIElement, Object, IEclipseContext) line: 489 ElementReferenceRenderer.createWidget(MUIElement, Object) line: 74 PartRenderingEngine.createWidget(MUIElement, Object) line: 861 PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 615 PartRenderingEngine.safeCreateGui(MUIElement) line: 717 PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 688 PartRenderingEngine$7.run() line: 682 SafeRunner.run(ISafeRunnable) line: 42 PartRenderingEngine.createGui(MUIElement) line: 667 StackRenderer.showTab(MUIElement) line: 723 StackRenderer(LazyStackRenderer).postProcess(MUIElement) line: 98 PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 631 PartRenderingEngine.safeCreateGui(MUIElement) line: 717 PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 688 PartRenderingEngine$7.run() line: 682 SafeRunner.run(ISafeRunnable) line: 42 PartRenderingEngine.createGui(MUIElement) line: 667 SashRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 59 PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 627 PartRenderingEngine.safeCreateGui(MUIElement) line: 717 PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 688 PartRenderingEngine$7.run() line: 682 SafeRunner.run(ISafeRunnable) line: 42 PartRenderingEngine.createGui(MUIElement) line: 667 SashRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 59 PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 627 PartRenderingEngine.safeCreateGui(MUIElement) line: 717 PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 688 PartRenderingEngine$7.run() line: 682 SafeRunner.run(ISafeRunnable) line: 42 PartRenderingEngine.createGui(MUIElement) line: 667 PerspectiveRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 59 PerspectiveRenderer.processContents(MElementContainer<MUIElement>) line: 59 PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 627 PartRenderingEngine.safeCreateGui(MUIElement) line: 717 PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 688 PartRenderingEngine$7.run() line: 682 SafeRunner.run(ISafeRunnable) line: 42 PartRenderingEngine.createGui(MUIElement) line: 667 PerspectiveStackRenderer.showTab(MUIElement) line: 103 PerspectiveStackRenderer(LazyStackRenderer).postProcess(MUIElement) line: 98 PerspectiveStackRenderer.postProcess(MUIElement) line: 77 PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 631 PartRenderingEngine.safeCreateGui(MUIElement) line: 717 PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 688 PartRenderingEngine$7.run() line: 682 SafeRunner.run(ISafeRunnable) line: 42 PartRenderingEngine.createGui(MUIElement) line: 667 SashRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 59 PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 627 PartRenderingEngine.safeCreateGui(MUIElement) line: 717 PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 688 PartRenderingEngine$7.run() line: 682 SafeRunner.run(ISafeRunnable) line: 42 PartRenderingEngine.createGui(MUIElement) line: 667 WBWRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 59 WBWRenderer.processContents(MElementContainer<MUIElement>) line: 581 PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 627 PartRenderingEngine.safeCreateGui(MUIElement) line: 717 PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 688 PartRenderingEngine$7.run() line: 682 SafeRunner.run(ISafeRunnable) line: 42 PartRenderingEngine.createGui(MUIElement) line: 667 PartRenderingEngine$9.run() line: 933 Realm.runWithDefault(Realm, Runnable) line: 332 PartRenderingEngine.run(MApplicationElement, IEclipseContext) line: 888 E4Workbench.createAndRunUI(MApplicationElement) line: 90 Workbench$3.run() line: 565 Realm.runWithDefault(Realm, Runnable) line: 332 Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 520 PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149 ProjectExplorerApplication.start(IApplicationContext) line: 14 EclipseAppHandle.run(Object) line: 196 EclipseAppLauncher.runApplication(Object) line: 110 EclipseAppLauncher.start(Object) line: 79 EclipseStarter.run(Object) line: 352 EclipseStarter.run(String[], Runnable) line: 179 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 Method.invoke(Object, Object...) line: 597 Main.invokeFramework(String[], URL[]) line: 624 Main.basicRun(String[]) line: 579 Main.run(String[]) line: 1431 Main.main(String[]) line: 1407

Files changed in fix:
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/CompatibilityEditor.java bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/CompatibilityPart.java bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/CompatibilityView.java