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

AccessibleBundle.toDisplayString(String, Locale) broken in 1.8.0_161 and later

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      I have an subclass of AccessibleState that overrides the following method from AccessibleBundle thus:

         @Override
         public String toDisplayString(Locale locale) {
            return toDisplayString("rob.resources", locale);
         }

      in order to return a string from my own resource bundle. In 1.8.0_152 and earlier this works. In 1.8.0_161 and later it fails thus:

      loadResourceBundle: java.util.MissingResourceException: Can't find bundle for base name rob.resources, locale en_GB

      As far as I can see this is caused by a change to the classloader used internally in java.util.ResourceBundle,

      REGRESSION : Last worked in version 8u161

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Build and run the attached class. It requires the 'resource.properties' in the same package, i.e. rob/R.class and rob/resources.properties

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      javac rob/R.java
      java rob.R

      R:hello

      ACTUAL -
      javac rob/R.java
      java rob.R
      loadResourceBundle: java.util.MissingResourceException: Can't find bundle for base name rob.resources, locale en_GB
      R:key1


      ---------- BEGIN SOURCE ----------
      rob/R.java:

      package rob;

      import java.util.Locale;
      import javax.accessibility.AccessibleState;

      public class R extends AccessibleState {
         public R(String key) {
            super(key);
         }

         @Override
         public String toDisplayString(Locale locale) {
            return toDisplayString("rob.resources", locale);
         }

         public static void main(String[] args) {
            final R r = new R("key1");
            System.out.println("R:" + r);
         }

      }

      rob/resources.properties:

      key1=hello




      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None known.

      FREQUENCY : always


            abhiscxk Abhishek Kumar
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: