Project: JDT
Bug 135112 viewsupport.ImageDescriptorRegistry creates multiple images
Reported: 2006-04-05 15:08:55 | Status: resolved fixed

viewsupport.ImageDescriptorRegistry creates multiple images for the same descriptor. When a tree is expanded with, say, 8 warning icons, the registry opens up org.eclipse.jdt.ui_3.2.0.jar:icons/full/ovr16/warning_co.gif 8 times. That means that the registry does not work correctly. I have seen that image being opened up 800 times for a really large project. The offending method: public Image get(ImageDescriptor descriptor) { ..... Image result= (Image)fRegistry.get(descriptor); if (result != null) return result; ..... result= descriptor.createImage(); <--- is always called if (result != null) fRegistry.put(descriptor, result); return result; } The reason why this does not work is simple. I am assuming the equals() or hashCode() method for JavaElementImageDescriptor are incorrect. Here is the repeated stack trace for each image being recreated: java.util.zip.ZipFile.getInputStream(ZipFile.java:324) org.eclipse.osgi.baseadaptor.bundlefile.ZipBundleEntry.getInputStream(ZipBundleEntry.java:51) org.eclipse.osgi.framework.internal.core.BundleURLConnection.connect(BundleURLConnection.java:53) org.eclipse.osgi.framework.internal.core.BundleURLConnection.getInputStream(BundleURLConnection.java:99) java.net.URL.openStream(URL.java:1041) org.eclipse.jface.resource.URLImageDescriptor.getStream(URLImageDescriptor.java:82) org.eclipse.jface.resource.URLImageDescriptor.getImageData(URLImageDescriptor.java:54) org.eclipse.jdt.ui.JavaElementImageDescriptor.getImageData(JavaElementImageDescriptor.java:186) org.eclipse.jdt.ui.JavaElementImageDescriptor.drawBottomLeft(JavaElementImageDescriptor.java:269) org.eclipse.jdt.ui.JavaElementImageDescriptor.drawCompositeImage(JavaElementImageDescriptor.java:180) org.eclipse.jface.resource.CompositeImageDescriptor.getImageData(CompositeImageDescriptor.java:208) org.eclipse.jface.resource.ImageDescriptor.createImage(ImageDescriptor.java:279) org.eclipse.jface.resource.ImageDescriptor.createImage(ImageDescriptor.java:233) org.eclipse.jface.resource.ImageDescriptor.createImage(ImageDescriptor.java:211) org.eclipse.jdt.internal.ui.viewsupport.ImageDescriptorRegistry.get(ImageDescriptorRegistry.java:67) org.eclipse.jdt.ui.ProblemsLabelDecorator.decorateImage(ProblemsLabelDecorator.java:159) org.eclipse.ui.internal.decorators.FullDecoratorDefinition.decorateImage(FullDecoratorDefinition.java:114) org.eclipse.ui.internal.decorators.FullImageDecoratorRunnable.run(FullImageDecoratorRunnable.java:28) org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) org.eclipse.core.runtime.Platform.run(Platform.java:816) org.eclipse.ui.internal.decorators.DecoratorManager.safeDecorateImage(DecoratorManager.java:418) org.eclipse.ui.internal.decorators.DecoratorManager.decorateImage(DecoratorManager.java:387) org.eclipse.jface.viewers.DecoratingLabelProvider.getImage(DecoratingLabelProvider.java:89) org.eclipse.jface.viewers.DecoratingLabelProvider.updateLabel(DecoratingLabelProvider.java:348) org.eclipse.jface.viewers.StructuredViewer.buildLabel(StructuredViewer.java:2023) org.eclipse.jface.viewers.TreeViewer.doUpdateItem(TreeViewer.java:247) org.eclipse.jface.viewers.AbstractTreeViewer$UpdateItemSafeRunnable.run(AbstractTreeViewer.java:88) org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) org.eclipse.core.runtime.Platform.run(Platform.java:816) org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44) org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:149) org.eclipse.jface.viewers.AbstractTreeViewer.doUpdateItem(AbstractTreeViewer.java:833) org.eclipse.jface.viewers.StructuredViewer$UpdateItemSafeRunnable.run(StructuredViewer.java:464) org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) org.eclipse.core.runtime.Platform.run(Platform.java:816) org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44) org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:149) org.eclipse.jface.viewers.StructuredViewer.updateItem(StructuredViewer.java:1901) org.eclipse.jface.viewers.AbstractTreeViewer.createTreeItem(AbstractTreeViewer.java:737) org.eclipse.jface.viewers.AbstractTreeViewer$1.run(AbstractTreeViewer.java:715) org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69) org.eclipse.jface.viewers.AbstractTreeViewer.createChildren(AbstractTreeViewer.java:689) org.eclipse.jface.viewers.TreeViewer.createChildren(TreeViewer.java:869) org.eclipse.jface.viewers.AbstractTreeViewer.internalExpand(AbstractTreeViewer.java:1331) org.eclipse.jface.viewers.AbstractTreeViewer.setSelectionToWidget(AbstractTreeViewer.java:2180) org.eclipse.jface.viewers.StructuredViewer.setSelectionToWidget(StructuredViewer.java:1590) org.eclipse.jface.viewers.AbstractTreeViewer.setSelectionToWidget(AbstractTreeViewer.java:2531) org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$PackageExplorerProblemTreeViewer.setSelectionToWidget(PackageExplorerPart.java:422) org.eclipse.jface.viewers.StructuredViewer.setSelection(StructuredViewer.java:1546) org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart.showInput(PackageExplorerPart.java:1317) org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart.editorActivated(PackageExplorerPart.java:1282) org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart.setLinkingEnabled(PackageExplorerPart.java:1550) org.eclipse.jdt.internal.ui.packageview.ToggleLinkingAction.run(ToggleLinkingAction.java:40) org.eclipse.jface.action.Action.runWithEvent(Action.java:499) org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:539) org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488) org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:441) org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:925) org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3340) org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2960) org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1909) org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1873) org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:418) org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:107) org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78) org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92) org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68) org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:374) org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:169) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:615) org.eclipse.core.launcher.Main.invokeFramework(Main.java:338) org.eclipse.core.launcher.Main.basicRun(Main.java:282) org.eclipse.core.launcher.Main.run(Main.java:977) org.eclipse.core.launcher.Main.main(Main.java:952)

Files changed in fix:
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPluginImages.java