Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4858721
Votes 0
Synopsis BufferedReader throws internal sun.io.MalformedInputException
Category java:classes_io
Reported Against 1.4.1
Release Fixed
State 11-Closed, Not a Defect, bug
Priority: 3-Medium
Related Bugs
Submit Date 05-MAY-2003
Description


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

FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
c:\install>java ReadFile test.htm
sun.io.MalformedInputException: Reversed byte-order mark
        at sun.io.ByteToCharUnicode.convert(ByteToCharUnicode.java:161)

Cannot catch sun.io.__Exception in spec conform java, because
use of sun.io. classes is not supported by most classloader
and security policies.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) created test file with batch file : c:\>iecrash.cmd >test.htm
   (or in Unix : % iecrash.sh > test.htm)
2) Ran ReadFile with ReadFile test.htm


------------------iecrash.cmd--------------------
@perl -e "print qq'\xFF\xFE'; print qq'\r\n' x 30000"
-------------------------------------------------

------------------iecrash.sh---------------------
#!/bin/sh
perl -e "print qq'\xFF\xFE'; print qq'\r\n' x 30000"
-------------------------------------------------

------------------ReadFile.java--------------------

import java.io.*;

public class ReadFile {
	public static void main(String[] a) {
		try {
			FileInputStream f = new FileInputStream(a[0]);
			BufferedReader in = new BufferedReader(   new InputStreamReader(f,"UnicodeBigUnmarked") );
    			String s;
	    
			while ( (s = in.readLine()) != null ) {
      			   System.out.println( s );
    			}

		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
-------------------------------------------------


EXPECTED VERSUS ACTUAL BEHAVIOR :
Some nice exception java.io.***
c:\install>java ReadFile test.htm
sun.io.MalformedInputException: Reversed byte-order mark
        at sun.io.ByteToCharUnicode.convert(ByteToCharUnicode.java:161)
        at sun.nio.cs.StreamDecoder$ConverterSD.convertInto(StreamDecoder.java:2
45)
        at sun.nio.cs.StreamDecoder$ConverterSD.implRead(StreamDecoder.java:295)

        at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:180)
        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 ReadFile.main(ReadFile.java:10)

ERROR MESSAGES/STACK TRACES THAT OCCUR :
c:\install>java ReadFile test.htm
sun.io.MalformedInputException: Reversed byte-order mark
        at sun.io.ByteToCharUnicode.convert(ByteToCharUnicode.java:161)
        at sun.nio.cs.StreamDecoder$ConverterSD.convertInto(StreamDecoder.java:2
45)
        at sun.nio.cs.StreamDecoder$ConverterSD.implRead(StreamDecoder.java:295)

        at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:180)
        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 ReadFile.main(ReadFile.java:10)

REPRODUCIBILITY :
This bug can be reproduced always.

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

public class ReadFile {
	public static void main(String[] a) {
		try {
			FileInputStream f = new FileInputStream(a[0]);
			BufferedReader in = new BufferedReader(   new InputStreamReader(f,"UnicodeBigUnmarked") );
    			String s;
	    
			while ( (s = in.readLine()) != null ) {
      			   System.out.println( s );
    			}

		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
---------- END SOURCE ----------
(Review ID: 185048) 
======================================================================
Work Around
N/A
Evaluation
sun.io.MalformedInputException,
sun.io.UnknownCharacterException and
sun.io.ConversionBufferFullException

are all subclasses of  java.io.CharConversionException.
The parent class is part of the public API so the test
case provided should be rewritten to catch 
java.io.CharConversionException. 

Converters such as UnicodeBigUnmarked, Unicode and
UnicodeLittleUnmarked are mostly retained for historical
compatibility purposes. Increasingly the common supported
encodings are supported by the java.nio charset API and
those NIO supported coders throw exceptions descended from
java.nio.charset.CharacterCodingException

Closing out as not a bug.
 xxxxx@xxxxx  2003-05-06
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang