This patch checks that the country of the locale is valid. That is,
checks that the country is supported by the ISO3166 code. If it is not,
an IllegalArgumentException is thrown, as stated by the reference
specifications.
This patch causes the failing mauve test to now pass:
gnu.testlet.java.util.Currency.getInstance.
2007-06-22 Tania Bento <[EMAIL PROTECTED]>
* java/util/Currency.java:
(getInstance (Locale)): Check that the country of the
locale given is valid. If it is not, throw an
IllegalArgumentException.
Index: java/util/Currency.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Currency.java,v
retrieving revision 1.18
diff -u -r1.18 Currency.java
--- java/util/Currency.java 2 Jan 2007 21:40:20 -0000 1.18
+++ java/util/Currency.java 22 Jun 2007 18:19:01 -0000
@@ -273,6 +273,11 @@
throw new
NullPointerException("The locale or its country is null.");
}
+
+ /* Check that country of locale given is valid. */
+ if (country.length() != 2)
+ throw new IllegalArgumentException();
+
/* Attempt to get the currency from the cache */
String code = (String) countryMap.get(country);
if (code == null)