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

java.io.OutputStreamWriter incorrectly throw CharConversionException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.1.3
    • core-libs
    • None
    • sparc
    • solaris_2.5.1



      Name: el35337 Date: 07/23/97


      /*
      C:>java BugChecker4
      java.vendor: Sun Microsystems Inc.
      java.version: 1.1.3
      os.name: Solaris
      os.arch: sparc

      OutputStreamWriter bug: CharConversionException should not occur.
      OutputStreamWriter bug: number of KSC5601 bytes written should be 20001, not be 19999

      <<< Solution >>>
      % diff jdk1.1.3/src/java/io/OutputStreamWriter.java bugpatch113/java/io/OutputStreamWriter.java
      164c164
      < if (nci == ci) {
      ---
      > if (nci == ci && nextByte == 0) {

      */

      import java.util.*;
      import java.io.*;

      class BugChecker4
      {
          public static void main(String[] args)
              throws IOException
          {
              System.out.println( "java.vendor: " + System.getProperty("java.vendor") );
              System.out.println( "java.version: " + System.getProperty("java.version") );
              System.out.println( "os.name: " + System.getProperty("os.name") );
              System.out.println( "os.arch: " + System.getProperty("os.arch") );
              System.out.println();

              ByteArrayOutputStream bos;
              OutputStreamWriter osw;
              byte[] array;

              bos = new ByteArrayOutputStream();
              osw = new OutputStreamWriter(bos, "EUCJIS");
              osw.write('a');
              try
              {
                  for(int count = 0; count < 10000; ++count)
                      osw.write('\u3042'); // Hiragana
                  osw.close();
                  array = bos.toByteArray();
                  if ( array.length != 20001 )
                      System.out.println( "OutputStreamWriter bug: number of EUCJIS bytes written should be 20001, "
                                 + "not be " + array.length );
              } catch( CharConversionException ex)
              { System.out.println( "OutputStreamWriter bug: CharConversionException should not occur." );
              }

              bos = new ByteArrayOutputStream();
              osw = new OutputStreamWriter(bos, "KSC5601");
              osw.write('a');
              try
              {
                  for(int count = 0; count < 10000; ++count)
                      osw.write('\uac00'); // Hangul syllable
                  osw.close();
                  array = bos.toByteArray();
              if ( array.length != 20001 )
                  System.out.println( "OutputStreamWriter bug: number of KSC5601 bytes written should be 20001, "
                             + "not be " + array.length );
              } catch( CharConversionException ex )
              { System.out.println( "OutputStreamWriter bug: CharConversionException should not occur." );
              }
          }
      }


      company - KAIST , email - ###@###.###
      ======================================================================

            bgomessunw Benedict Gomes (Inactive)
            elarsen Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: