classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: IllegalArgumentException in Charset.forName


From: Robert Schuster
Subject: [cp-patches] FYI: IllegalArgumentException in Charset.forName
Date: Fri, 18 Feb 2005 02:42:28 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.7.5) Gecko/20050107

Hi,
this patch adds support for the officially undocumented behavior of throwing an IllegalArgumentException in
java.nio.charset.Charset.forName(String charsetName) if charsetName is null.

A mauve testcase is already provided.

2005-02-18  Robert Schuster <address@hidden>

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


cu
Robert

Index: java/nio/charset/Charset.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/charset/Charset.java,v
retrieving revision 1.14
diff -u -r1.14 Charset.java
--- java/nio/charset/Charset.java       8 Jan 2005 11:48:28 -0000       1.14
+++ java/nio/charset/Charset.java       18 Feb 2005 01:28:38 -0000
@@ -127,9 +127,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);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]