Community
Participate
Working Groups
3.1 RC2 Steps to reproduce: - Checkout project org.eclipse.jdt.ui.vcm - Expand project in the package explorer - Browse through the folders of the JRE_LIB container -> The following exception occurs: java.lang.NullPointerException at org.eclipse.core.internal.content.FileSpec.getMappingKeyFor (FileSpec.java:57) at org.eclipse.core.internal.content.ContentTypeCatalog.getDirectlyAssociated (ContentTypeCatalog.java:454) at org.eclipse.core.internal.content.ContentTypeCatalog.internalFindContentTypesFo r(ContentTypeCatalog.java:409) at org.eclipse.core.internal.content.ContentTypeCatalog.findContentTypesFor (ContentTypeCatalog.java:263) at org.eclipse.core.internal.content.ContentTypeMatcher.findContentTypeFor (ContentTypeMatcher.java:49) at org.eclipse.ui.internal.registry.EditorRegistry.guessAtContentType (EditorRegistry.java:338) at org.eclipse.ui.internal.registry.EditorRegistry.getImageDescriptor (EditorRegistry.java:382) at org.eclipse.jdt.internal.ui.viewsupport.StorageLabelProvider.getDefaultImage (StorageLabelProvider.java:133) at org.eclipse.jdt.internal.ui.viewsupport.StorageLabelProvider.getImageForJarEntr y(StorageLabelProvider.java:11 6) at org.eclipse.jdt.internal.ui.viewsupport.StorageLabelProvider.getImage (StorageLabelProvider.java:52) at org.eclipse.jdt.internal.ui.viewsupport.JavaUILabelProvider.getImage (JavaUILabelProvider.java:140) at org.eclipse.jdt.internal.ui.packageview.WorkingSetAwareLabelProvider.getImage (WorkingSetAwareLabelProvider.ja va:54) at org.eclipse.jface.viewers.DecoratingLabelProvider.getImage (DecoratingLabelProvider.java:82) at org.eclipse.jface.viewers.DecoratingLabelProvider.updateLabel (DecoratingLabelProvider.java:212) at org.eclipse.jface.viewers.StructuredViewer.buildLabel (StructuredViewer.java:1855) at org.eclipse.jface.viewers.TreeViewer.doUpdateItem (TreeViewer.java:228) at org.eclipse.jface.viewers.AbstractTreeViewer$UpdateItemSafeRunnable.run (AbstractTreeViewer.java:85) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:1038) at org.eclipse.core.runtime.Platform.run(Platform.java:775) at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:148) at org.eclipse.jface.viewers.AbstractTreeViewer.doUpdateItem (AbstractTreeViewer.java:621) at org.eclipse.jface.viewers.StructuredViewer$UpdateItemSafeRunnable.run (StructuredViewer.java:434) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:1038) at org.eclipse.core.runtime.Platform.run(Platform.java:775) at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:148) at org.eclipse.jface.viewers.StructuredViewer.updateItem (StructuredViewer.java:1763) at org.eclipse.jface.viewers.AbstractTreeViewer.createTreeItem (AbstractTreeViewer.java:535) at org.eclipse.jface.viewers.AbstractTreeViewer$1.run (AbstractTreeViewer.java:514) at org.eclipse.swt.custom.BusyIndicator.showWhile (BusyIndicator.java:69) at org.eclipse.jface.viewers.AbstractTreeViewer.createChildren (AbstractTreeViewer.java:494) at org.eclipse.jface.viewers.AbstractTreeViewer.handleTreeExpand (AbstractTreeViewer.java:948) at org.eclipse.jface.viewers.AbstractTreeViewer$4.treeExpanded (AbstractTreeViewer.java:959) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:179) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:844) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:868) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:853) at org.eclipse.swt.widgets.Tree.wmNotifyChild(Tree.java:3703) at org.eclipse.swt.widgets.Control.WM_NOTIFY(Control.java:3567) at org.eclipse.swt.widgets.Composite.WM_NOTIFY(Composite.java:1035) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3088) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3679) at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method) at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:1578) at org.eclipse.swt.widgets.Tree.callWindowProc(Tree.java:219) at org.eclipse.swt.widgets.Tree.WM_LBUTTONDOWN(Tree.java:2814) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3070) at org.eclipse.swt.widgets.Tree.windowProc(Tree.java:2390) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3679) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1654) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2686) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1717) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1681) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:366) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:103) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:226) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:376) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:163) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:85) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:58) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:60) at java.lang.reflect.Method.invoke(Method.java:391) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334) at org.eclipse.core.launcher.Main.basicRun(Main.java:278) at org.eclipse.core.launcher.Main.run(Main.java:973) at org.eclipse.core.launcher.Main.main(Main.java:948)
To make the steps more specific: select the package sun.text.resources inside rt.jar (works for me with Sun 1.5). The triggers is to try to expose a file (inside a JAR in the claspath) that has no file extension. The NPE occurs because null is passed to IContentTypeMatcher.findContentTypeFor(String), which is not legal. EditorRegistry will do that when null is passed to IEditorRegistry.getImageDescriptor(String), which does not mention null is allowed as argument, so I assume it is not allowed there either (Kim, please correct me if I am wrong). StorageLabelProvider is explicitly passing null, and it only does that when the file has no file extension. I would have expected clients of the editor registry to always pass the full file name, not only the extension. Moving to JDT/Text.
getImageDescriptor(null) doesn't make a whole lot of sense. The doc for the method mentions that it will extract the file extension itself.
I agree that the Javadoc does not mention null as valid argument, however we (and possibly other clients) used this call since 2001 to get the default image for files that have no editor associated. In addition the Javadoc of getImageDescriptor writes that it does use the unknwon content type i.e. it does not try to derive a content type from the file extension: * Returns the image descriptor associated with a given file. This image is * usually displayed next to the given file. This method assumes an unknown * content type for the given file. So, it might be a good idea to protect the Platform UI code as well.
Moving to JDT UI where this bug belongs. Dirk, I'm the initial owner of this class and I have a trivial fix read. I approve to fix this for 3.1 RC3.
I've entered bug 99679 to address javadoc cleanup + error trapping in the UI code.
+1 for RC3.
Dani, can you take care of the fix.
Fixed in HEAD. Reviewed by Markus.
.
start verifying...
Verified on I20050617-0010 following the steps in comment one. There are four files without an extension in this package. All are displayed fine.