Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4481957

Unexpected java.util.MissingResourceException in applet mode

XMLWordPrintable

    • tiger
    • generic
    • generic
    • Verified



      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]

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

            campbell Christopher Campbell (Inactive)
            ipsunw Ip Ip (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: