JDK-4481957 : Unexpected java.util.MissingResourceException in applet mode
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.imageio
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2001-07-19
  • Updated: 2004-03-20
  • Resolved: 2003-08-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Related Reports
Relates :  
Relates :  
Description

Name: ipR10067			Date: 07/19/2001



Some new (JCK1.4) javax.imageio tests failed in applet mode in JDK 1.4.0-beta build b65.
however these tests passed in application mode.

To reproduce the bug use files in attachment.
Just run demo_bug.
NOTE. Please change activeHost value in applet.html
and TESTJAVADIR in demo_bug script to actual values.

I have an idea why it happens.
The bug occurs when calling method 
java.util.ResourceBundle.getBundle(String baseName, Locale locale)
within some javax.imageio classes, such as javax.imageio.ImageReader,
javax.imageio.ImageWriter and javax.imageio.metadata.IIOMetadataFormatImpl.

Method getBundle of ResourceBundle class uses method getLoader:

 private static ClassLoader getLoader() {
        Class[] stack = getClassContext();
        /* Magic number 2 identifies our caller's caller */
        Class c = stack[2];
        ClassLoader cl = (c == null) ? null : c.getClassLoader();
        if (cl == null) {
            cl = ClassLoader.getSystemClassLoader();
        }
        return cl;
    }

In our case getClassLoader for abstract class javax.imageio.ImageReader
returns null and therefore getLoader returns system class loader.
In application mode system class loader and loader for application match
but in applet mode they are different. Loader returned by getLoader() is used for 
searching for bundle in getBundleImpl method. In applet mode 
system class loader does not allow to find bundles.
As a result java.util.MissingResourceException is thrown.
-------------------------------------------------------------------
The tests failed due to this bug:

api/javax_imageio/ImageWriter/index.html#writeWarningListener[writeWarningListener001]
api/javax_imageio/ImageReader/index.html#readWarningListener[readWarningListener001]
api/javax_imageio/metadata/IIOMetadataFormatImpl/index.html#getElementDescription[getElementDescription003]
api/javax_imageio/metadata/IIOMetadataFormatImpl/index.html#getAttrDescription[getAttributeDescription005]

======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b15 VERIFIED IN: tiger
14-06-2004

EVALUATION If an applet supplies resource bundles along with an implementation of ImageReader, ImageWriter, or IIOMetadataFormatImpl, then the resource bundle will need to be accessed via the applet class loader. The fix is to first try the context class loader to locate the resource bundle. If that throws MissingResourceException, then try the system class loader. Failing that, we can still throw the MissingResourceException, as before, which indicates that the bundle cannot be found for reasons other than applet security restrictions. ###@###.### 2003-07-23
23-07-2003