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

(cs) StreamEncoder throws uninformative Error when encoding unpaired surrogates

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 1.4.2, 5.0
    • core-libs
    • b43
    • x86
    • linux, windows_2000, windows_xp

      FULL PRODUCT VERSION :
      java version "1.5.0_03"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
      Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Printing of two or more "special" chars using System.out.print() one char at a time produces java.lang.Error. For example, print '\uda00' twice. Error doesn't occure with println() method.



      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" java.lang.Error
      at sun.nio.cs.StreamEncoder$CharsetSE.flushLeftoverChar(StreamEncoder.java:361)
      at sun.nio.cs.StreamEncoder$CharsetSE.implWrite(StreamEncoder.java:381)
      at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:136)
      at java.io.OutputStreamWriter.write(OutputStreamWriter.java:191)
      at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:111)
      at java.io.PrintStream.write(PrintStream.java:458)
      at java.io.PrintStream.print(PrintStream.java:602)
      at PrintCharsBug.main(PrintCharsBug.java:4)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class PrintCharsBug {
          public static void main(String[] args) {
              System.out.print("\uda00");
              System.out.print("\uda01");
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use StringBuffer to append chars and than print it.
      Or print all chars at once: System.out.print("\uda00\uda00");
      ###@###.### 2005-05-24 06:23:18 GMT

            sherman Xueming Shen
            jssunw Jitender S (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: