JDK-4832657 : (cs) Charset("", ...) should throw IllegalCharsetNameException
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 1.4.0,5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,solaris_8
  • CPU: generic,sparc
  • Submitted: 2003-03-14
  • Updated: 2004-03-29
  • Resolved: 2003-11-27
Related Reports
Duplicate :  
Description

Name: auR10023			Date: 03/14/2003



java.nio.charset.Charset(String canonicalName, String[] aliases) should 
throw IllegalCharsetNameException with empty canonicalName.

Here is the example:

-------test.java---------

import java.nio.charset.*;

public class test {
    static class TestCharset extends Charset {
        public TestCharset(String canonicalName, String[] aliases) {
            super(canonicalName, aliases);
        }
        public CharsetDecoder newDecoder() {
           return null;
        }

        public CharsetEncoder newEncoder() {
           return null;
        }

        public boolean contains(Charset cs) {
            return false;
        }

    }

    public static void main (String [] args) {
        try {
            new TestCharset("", null);
            System.out.println("IllegalCharsetNameException should be thrown");
        } 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 should be thrown

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

Comments
EVALUATION The submitter is correct. -- ###@###.### 2003/3/14 I've consolidated the information in this bug report into 4786884. -- ###@###.### 2003/11/26
03-11-0180