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

REGRESSION: ClassCastException in JISAutoDetect.java on 1.4.2_10

    XMLWordPrintable

    Details

      Description

      FULL PRODUCT VERSION :
      java version "1.4.2_10"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
      Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)

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

      A DESCRIPTION OF THE PROBLEM :
      When reading from a file contains Japanese character in SJIS or EUC_JP via FileInputStream with JISAutoDetect convertor, ClassCastException occurs in sun.nio.cs.ext.JISAutoDetect$Decoder.decodeLoop.

      Here is a full stacktrace.
      D:\SampleCode>java -showversion JISAutoDetectTest sjis.txt
      java version "1.4.2_10"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
      Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)

      Exception in thread "main" java.lang.ClassCastException
              at sun.nio.cs.ext.JISAutoDetect$Decoder.decodeLoop(JISAutoDetect.java:12
      6)
              at sun.nio.cs.ext.JISAutoDetect$Decoder.decodeLoop(JISAutoDetect.java:16
      6)
              at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:538)
              at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:442)
              at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:182)
              at java.io.InputStreamReader.read(InputStreamReader.java:167)
              at java.io.BufferedReader.fill(BufferedReader.java:136)
              at java.io.BufferedReader.readLine(BufferedReader.java:299)
              at java.io.BufferedReader.readLine(BufferedReader.java:362)
              at JISAutoDetectTest.main(JISAutoDetectTest.java:16)

      This is not occurs on JDK 1.4.2_09 and the prior update release.
      When reading from ascii file, It is not occurs.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create data file named "sjis.txt", which is written in Japanese character encoded SJIS
      2. Compile the source code.
         javac JISAutoDetectTest.java
      3. Run it
         java JISAutoDetectTest sjis.txt


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Don't occur the any exceptions, and just print the content of the file.
      ACTUAL -
      ClassCastException occurs.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" java.lang.ClassCastException
              at sun.nio.cs.ext.JISAutoDetect$Decoder.decodeLoop(JISAutoDetect.java:12
      6)
              at sun.nio.cs.ext.JISAutoDetect$Decoder.decodeLoop(JISAutoDetect.java:16
      6)
              at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:538)
              at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:442)
              at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:182)
              at java.io.InputStreamReader.read(InputStreamReader.java:167)
              at java.io.BufferedReader.fill(BufferedReader.java:136)
              at java.io.BufferedReader.readLine(BufferedReader.java:299)
              at java.io.BufferedReader.readLine(BufferedReader.java:362)
              at JISAutoDetectTest.main(JISAutoDetectTest.java:16)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      ----- JISAutoDetecTest.java ----
      import java.io.*;

      public class JISAutoDetectTest {
        public static void main(String[] args) {
          if(args.length != 1) {
             System.out.println("usage : java JISAutoDetectTest <filename>");
             System.exit(0);
          }

          BufferedReader reader = null;

          try {
            File file = new File(args[0]);
            String line = null;
            reader = new BufferedReader(new InputStreamReader(new FileInputStream(file),"JISAutoDetect"));
            while ((line = reader.readLine()) != null ) {
              System.out.println(line);
            }
            reader.close();
          } catch (IOException e) {
            System.out.println(e);
          }
        }
      }


      ---------- END SOURCE ----------

      Release Regression From : 1.4.2_09
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sthilagasunw Sathianantha Thilagar (Inactive)
              Reporter:
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: