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

REGRESSION: loading from a parent Resource Bundle does not work

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.3.0
    • core-libs



      Name: rmT116609 Date: 01/03/2001


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      if you try to load {"text2", "Got Parent"} from the parent class
      you'll get "MissingResourceException".
      This worked fine in JDK1.2.2!

      //GetRB.java
      import java.util.ResourceBundle;
      import java.util.Locale;

      public class GetRB {
          public static void main(String[] args) {
              Locale.setDefault(Locale.US);
              ResourceBundle myResource = ResourceBundle.getBundle("RBBase_en", new Locale("",""));
              System.out.println(myResource.getString("text2"));
          }
      }
      //RBBase.java
      public class RBBase extends java.util.ListResourceBundle{
         public Object[][] getContents() {
      return contents;
          }
          static final Object[][] contents = {
      {"text2", "Got Parent"},
          };
      }
      //RBBase_en.java
      public class RBBase_en extends RBBase{
          public RBBase_en(){
      super();
      setParent(new RBBase());
          }
          public Object[][] getContents() {
      return contents;
          }
          static final Object[][] contents = { {"text1", "Got child"},};
      }
      in JDK1.3:
      D:\tmp>D:\jdk1.3\bin\java GetRB
      Exception in thread "main" java.util.MissingResourceException: Can't find resour
      ce for bundle RBBase_en, key text2
              at java.util.ResourceBundle.getObject(ResourceBundle.java:382)
              at java.util.ResourceBundle.getString(ResourceBundle.java:354)
              at GetRB.main(GetRB.java:8)

      in JDK1.2.2:
      D:\tmp>D:\jdk1.2.2\bin\java GetRB
      Got Parent
      (Review ID: 114491)
      ======================================================================

            nlindenbsunw Norbert Lindenberg (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: