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

Using Hashtables in ResourceBundles

    XMLWordPrintable

Details

    Description



      Name: rm29839 Date: 11/11/97


      Hi,

      Sorry if this is user error; but the following
      ResourceBundle returns a NullPointerException
      during RB.handleGetObject("routeNameNull").

      java.lang.NullPointerException
              at mp/MPResourceBundle.handleGetObject
              at java/util/ResourceBundle.getObject
              at java/util/ResourceBundle.getString
              at mp/MPException.toLocalString
              at mp/MPTest.main

      Seems as though ClassLoader can load a class
      but never fires the constructor for the loaded
      class. I can step into handleGetObject; but
      Res returns null for "routeNameNull". Apparently
      there are additional requirements to using
      Hashtables, static arrays work ok. Thanks.

      Don Hamson
      Bartlett Consulting, Inc.

      import java.util.*;

      public class MPResourceBundle extends ResourceBundle
      {
           Hashtable Res;

           public MPResourceBundle()
           {
                Hashtable Res = new Hashtable();

                // Load US English Resources
                Res.put("nullFilenameSave", "Cannot save to null filename.");

                Res.put("nullFilenameRestore", "Cannot restore from null
      filename.");
                Res.put("routeNameExists", "Route name already exists: {0}");

                Res.put("routeNameNull", "Route name cannot be null");
                Res.put("routeNameNotFound", "Route namd not found: {0}");
           }
           public Object handleGetObject(String key) { return Res.get(key); }
           public Enumeration getKeys() { return Res.keys(); }
      }
      (Review ID: 19288)
      ======================================================================

      Attachments

        Activity

          People

            rgillamsunw Richard Gillam (Inactive)
            rmandelsunw Ronan Mandel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: