-
Bug
-
Resolution: Fixed
-
P3
-
8, 9
-
b149
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8177834 | 8-pool | Ramanand Patil | P3 | Open | Unresolved |
------
[1] https://docs.oracle.com/javase/6/docs/api/java/util/Locale.html#getISO3Country%28%29
[2] https://docs.oracle.com/javase/7/docs/api/java/util/Locale.html#getISO3Country%28%29
[3] http://www.iso.ch/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html
[4] https://docs.oracle.com/javase/6/docs/api/java/util/Locale.html
[5] https://www.iso.org/obp/ui/#search
[6] http://web.archive.org/web/20061205090748/http://www.iso.ch/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html
Issue description:
------------------
The Locale.getISO3Country() javadoc states as follows:
Java SE 6 [1]:
Returns a three-letter abbreviation for this locale's country. If the locale
doesn't specify a country, this will be the empty string. Otherwise, this
will be an uppercase ISO 3166 3-letter country code. The ISO 3166-2 country
codes can be found on-line at http://www.davros.org/misc/iso3166.txt.
Throws:
MissingResourceException - Throws MissingResourceException if the
three-letter country abbreviation is not available for this locale.
Java SE 7 [2]:
Returns a three-letter abbreviation for this locale's country. If the
country matches an ISO 3166-1 alpha-2 code, the corresponding ISO 3166-1 alpha-3
uppercase code is returned. If the locale doesn't specify a country, this will
be the empty string.The ISO 3166-1 codes can be found on-line.
Returns:
A three-letter abbreviation of this locale's country.
Throws:
MissingResourceException - Throws MissingResourceException if the
three-letter country abbreviation is not available for this locale.
(Notice that the link [3], mentioned in the class javadoc for [4], makes a redirection
to [5] (official ISO site), but it still can be found at [6].)
The above javadocs do not say anything concrete about the "Status" field for
country codes in ISO-3166 standard, so someone can expect that getISOCountries() in
the specific Java SE release has consistent behaviour for all countries with
"Transitionally Reserved" status. Unfortunately, there is a contradiction between
JDK6 vs JDK7(and 8), as demonstrated by the minimized test below.
Minimized test:
---------------
$ cat TestTRISOs.java
import java.util.*;
public class TestTRISOs {
public static void main(String... args) {
final String[] trCodes = {"AN", "BU", "CS"};
for (String trc : trCodes) {
Locale loc = new Locale("", trc);
try {
String ic = loc.getISO3Country();
System.out.println(trc + " => " + ic);
} catch(MissingResourceException e) {
System.out.println("(" + trc +") Unexpected exception thrown " + e);
}
}
}
}
$ /cygdrive/c/java/6/binaries/windows-x64/bin/java TestTRISOs
AN => ANT
(BU) Unexpected exception thrown java.util.MissingResourceException: Couldn't find 3-letter country code for BU
CS => SCG
$ /cygdrive/c/java/7/binaries/windows-x64/bin/java TestTRISOs
AN => ANT
(BU) Unexpected exception thrown java.util.MissingResourceException: Couldn't find 3-letter country code for BU
(CS) Unexpected exception thrown java.util.MissingResourceException: Couldn't find 3-letter country code for CS
$ /cygdrive/c/java/8/binaries/windows-x64/bin/java TestTRISOs
AN => ANT
(BU) Unexpected exception thrown java.util.MissingResourceException: Couldn't find 3-letter country code for BU
(CS) Unexpected exception thrown java.util.MissingResourceException: Couldn't find 3-letter country code for CS
Such behaviour looks inconsistent and can be fixed or at least documented.
- backported by
-
JDK-8177834 Locale.getISOCountries() has inconsistent behaviour for "AN", "BU" and "CS" country codes
- Open
- duplicates
-
JDK-8177797 Locale.getISOCountries() still contains country code "AN"
- Closed
- relates to
-
JDK-8170875 Problem list LocaleTest.java until JDK-8170840 is fixed
- Resolved
-
JDK-6786276 Locale.getISOCountries() still contains country code "CS"
- Resolved
-
JDK-8170840 java/util/Locale/LocaleTest.java failed with "Uncaught exception thrown in test method TestGetLangsAndCountries"
- Closed
-
JDK-6475525 ISO 3166 changes for Serbia and Montenegro
- Closed