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

java.util.Locale.getDisplayName(null) works wrong

    Details

      Description



      Name: avC70361 Date: 09/24/98



        The java.util.Local.getDisplayName(null) works wrong for the locale with language, country and variant
      fields all empty. It throws NullPointerException but Locale.getDisplayName() spec states "If the language,
      country and variant fields are all empty, this function returns the empty string".

      Here is a test demonstrating the bug.
      ----------------GetDisplayNameTest.java---------------
      import java.util.Locale;

      public class GetDisplayNameTest {
        public static void main(String args[]) {
          Locale l = new Locale("", "", "");

          try {
            String name = l.getDisplayName(null);

            if (l.equals("")) {
              System.out.println("Passed");
            } else {
              System.out.println(
                "Failed. Name returned = " + name + ", expected name = \"\""
              );
            }
          } catch(NullPointerException e) {
            System.out.println("Failed. NullPointerException was thrown");
          }
        }
      }
      ---------------The test output-------------------------
      > java -version
      java version "1.2fcs"
      Classic VM (build JDK-1.2fcs-K, green threads, sunwjit)
      > java GetDisplayNameTest
      Failed. NullPointerException was thrown

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

        Attachments

          Activity

            People

            • Assignee:
              aliusunw Alan Liu (Inactive)
              Reporter:
              ovlasov Oleksandr Vlasov (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: