[Patch] java.nio.charset.Charset

Michael Koch konqueror@gmx.de
Fri Feb 18 20:38:00 GMT 2005


Hi list,


I just commited the attached patch to merge a small fix for
java.nio.charset.Charset.forName. This is backed up by a Mauve testcase.


Michael


2005-02-18  Robert Schuster <thebohemian@gmx.net>

	* java/nio/charset/Charset.java (forName): Throws
	IllegalArgumentException when argument is null
	and added documentation.

-------------- next part --------------
Index: java/nio/charset/Charset.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/charset/Charset.java,v
retrieving revision 1.7
diff -u -r1.7 Charset.java
--- java/nio/charset/Charset.java	22 Oct 2004 17:14:19 -0000	1.7
+++ java/nio/charset/Charset.java	18 Feb 2005 07:43:49 -0000
@@ -117,9 +117,24 @@
   {
     return charsetForName (charsetName) != null;
   }
- 
+
+  /**
+   * Returns the Charset instance for the charset of the given name.
+   * 
+   * @param charsetName
+   * @return
+   * @throws UnsupportedCharsetException if this VM does not support
+   * the charset of the given name.
+   * @throws IllegalCharsetNameException if the given charset name is
+   * legal.
+   * @throws IllegalArgumentException if <code>charsetName</code> is null.
+   */
   public static Charset forName (String charsetName)
   {
+    // Throws IllegalArgumentException as the JDK does.
+    if(charsetName == null)
+        throw new IllegalArgumentException("Charset name must not be null.");
+    
     Charset cs = charsetForName (charsetName);
     if (cs == null)
       throw new UnsupportedCharsetException (charsetName);


More information about the Java-patches mailing list