Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4786886

Charset.isSupported() doesn't throw IllegalCharsetNameException

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 1.4.2
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.6

      Description



      Name: auR10023 Date: 12/02/2002



      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-b07)
      Java HotSpot(TM) Client VM (build 1.4.2-beta-b07, mixed mode)

      #java test

      IllegalCharsetNameException expected

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mr Mark Reinhold
              Reporter:
              avusunw Avu Avu (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: