-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.2.0
-
sparc
-
solaris_2.5
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
======================================================================