JDK-4832630 : Charset.isSupported() doesn't throw IllegalCharsetNameException
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_8
  • CPU: sparc
  • Submitted: 2003-03-14
  • Updated: 2003-03-14
  • Resolved: 2003-03-14
Related Reports
Duplicate :  
Description

Name: auR10023			Date: 03/14/2003



Javadoc for java.nio.charset.Charset says:
...
 The empty string is not a legal charset name.
...
So, java.nio.charset.Charset.isSupported(String)  should throw 
IllegalCharsetNameException with empty string.

Here is the example:

-------test.java---------
import java.nio.charset.*;

public class test {
    public static void main (String [] args) {
        try {
            Charset.isSupported("");
            System.out.println("IllegalCharsetNameException expected");
            return;
        } catch(IllegalCharsetNameException e) {
        }
        System.out.println("OKAY");
    }
}

Here is the result
#java -version

java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b16)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b16, mixed mode)

#java test

IllegalCharsetNameException expected

======================================================================

Comments
EVALUATION Duplicate 4786884. -- iag@sfbay 2003-03-14
14-03-2003