Project: Eclipse_Platform_UI
Bug 22360 [Fonts] FontRegistry can not instantiated using resources outside org.eclipse.jface.resource
Reported: 2002-08-12 13:33:12 | Status: closed fixed

I get MissingResourceException when I am trying to create FontRegistry instance for my application as follows: com.company.product.MyClass>>public void createFontRegistry(){ FontRegistry fonts = new FontRegistry("com.company.product.fonts"); } where I do have a file fonts.properties in my com/company/product/ folder. However, if I try this instead: com.company.product.MyClass>>public void createFontRegistry(){ ResourceBundle fonts = ResourceBundle.getBundle(("com.company.product.fonts"); } There is no exception. Moreover, if I create a complete copy of the FontRegsitry class in my com.company.product package - then it works. My guess is - it is a bug in the FontRegistry. It tries to load the fonts resource bundle, but the FontRegistry's class loader is used to do that (see readResourceBundle(String) FontRegistry method). Therefore all the resources that are being looked up are the only ones relative to the location of the FontRegistry class - org.eclipse.jface.resource path. It can be remedied if FontRegistry took a client class (or class loader) as an additional parameter to the constructor. Alternatively it can allow clients to load their own resource bundle and take it as a parameter to the constructor (Vs. name of the bundle).

Files changed in fix:
bundles/org.eclipse.ui/Eclipse JFace/org/eclipse/jface/resource/FontRegistry.java