JDK-4834404 : UIDefaults can't find resource bundles from app classloader
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.1
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2003-03-19
  • Updated: 2017-05-23
Description

Name: jk109818			Date: 03/18/2003


FULL PRODUCT VERSION :
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

FULL OPERATING SYSTEM VERSION :
Windows NT Version 4.0

A DESCRIPTION OF THE PROBLEM :
There is a problem with the way that the UIdefaults class
finds ResourceBundles.

Broadly, some application code is running in
classloader A.  If the application code calls
ResourceBundle.getBundle, then there is some magic
code in ResourceBundle that determines that the
caller is in classloader A and ResourceBundle then
uses ClassLoader A to find the resource bundle.

However, if the app code calls addResourceBundle(), then
calls one of UIDefaults methods to get a UI resource from
the added resource bundle, such as using the get(Object
key, Locale locale) method. The UIDefaults class will then
call ResourceBundle.getBundle, then the ResourceBundle
code will see that the call is coming from code
using the system classloader, and will use the
system classloader (rather than classloader A)
to find the bundle.

For apps started by JavaWebStart, the app is running with
its resources in a different classloader than the system
classloader. And thus the problem occurs.

I think a solution similar to the one developped for bug ID
4418820 should be used.

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER WORKAROUND :
One could always try to load the resource bundles for the
appropriate locale and add the content of the resource
bundles to the UIDefaults class using put() or putDefaults
().
(Review ID: 179181) 
======================================================================

Comments
EVALUATION addResourceBundle was intended for internal use only, therefor it doesn't correctly resolve non-system resource bundles. To fix this we could cache the context ClassLoader at the tiem addResourceBundle is called. ###@###.### 2003-03-19
19-03-2003