Project: Eclipse_Platform_UI
Bug 82914 [KeyBindings] performance: Too many MissingResourceException from NativeKeyFormatter
Reported: 2005-01-15 12:53:41 | Status: verified fixed

I'm trying to debug Eclipse plugins in Eclipse 3.1, and I have *tons* of MissingResourceException from NativeKeyFormatter (I have added exception breakpoint on RuntimeException). Here is the stack trace from debugger: Thread [main] (Suspended (exception MissingResourceException)) PropertyResourceBundle(ResourceBundle).getObject(String) line: 326 PropertyResourceBundle(ResourceBundle).getString(String) line: 286 Util.translateString(ResourceBundle, String, String, boolean, boolean) line: 453 NativeKeyFormatter(AbstractKeyFormatter).format(Key) line: 66 NativeKeyFormatter.format(Key) line: 123 NativeKeyFormatter(AbstractKeyFormatter).format(KeyStroke) line: 110 NativeKeyFormatter(AbstractKeyFormatter).format(KeySequence) line: 79 KeySequence.format() line: 272 CommandCallback.getAcceleratorText(String) line: 170 ActionContributionItem.update(String) line: 792 SubContributionItem.update(String) line: 160 MenuManager.update(String) line: 680 MenuManager.update(String) line: 680 Workbench.updateActiveWorkbenchWindowMenuManager(boolean) line: 2070 Workbench.access$0(Workbench, boolean) line: 2058 Workbench$3.windowActivated(IWorkbenchWindow) line: 2042 Workbench$8.run() line: 406 InternalPlatform.run(ISafeRunnable) line: 1007 Platform.run(ISafeRunnable) line: 747 Workbench.fireWindowActivated(IWorkbenchWindow) line: 404 WorkbenchWindow$5.shellActivated(ShellEvent) line: 2215 TypedListener.handleEvent(Event) line: 163 EventTable.sendEvent(Event) line: 82 Shell(Widget).sendEvent(Event) line: 833 Shell(Widget).sendEvent(int, Event, boolean) line: 857 Shell(Widget).sendEvent(int) line: 838 Shell(Decorations).WM_ACTIVATE(int, int) line: 1507 Shell.WM_ACTIVATE(int, int) line: 1444 Shell(Control).windowProc(int, int, int, int) line: 3016 Shell(Decorations).windowProc(int, int, int, int) line: 1483 Display.windowProc(int, int, int, int) line: 3376 OS.PeekMessageW(MSG, int, int, int, int) line: not available [native method] OS.PeekMessage(MSG, int, int, int, int) line: 1999 Display.readAndDispatch() line: 2449 Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 1577 Workbench.runUI() line: 1543 Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 287 PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 144 IDEApplication.run(Object) line: 102 PlatformActivator$1.run(Object) line: 220 EclipseStarter.run(Object) line: 274 EclipseStarter.run(String[], Runnable) line: 129 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: 585 Main.basicRun(String[]) line: 255 Main.run(String[]) line: 811 Main.main(String[]) line: 795 The problem is, that NativeKeyFormatter tries to get internationalized keys for all possible key strokes for many menu entries in Eclipse, and for most of them (like ',', 'A', 'B', 'C', ... , 'Z') there is no translation in resource bundle. Ergo => ResourceBundle create and throws every time a new MissingResourceException, which will be ignored by NativeKeyFormatter and this happens *every time* on *every* mouse/key move in Eclipse. Two reasons to fix this behavoir: 1) Create and throw an exception is costly - it takes time and memory. In this case, this happens on *every* typeEvent and is therefore *very* bad for Eclipse editor performance. 2) I can't filter out *my* RuntimeExceptions because there are simply too many MissingResourceException from AbstractKeyFormatter. I would propose simply remember missing keys in internal cache of org.eclipse. ui.internal.util.Util class (or wherever it could be stored) and do not ask PropertyResourceBundle any time for key, if this key is already in "MissingKeysCache". eclipse.buildId=I200411050810 java.runtime.version=1.5.0_01-b08 osgi.nl=de_DE osgi.os=win32

Files changed in fix:
bundles/org.eclipse.jface/src/org/eclipse/jface/bindings/keys/formatting/AbstractKeyFormatter.java