JDK-4856364 : Exception in thread "main" java.lang.InternalError: Converter malfunction
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 5.0,6
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000,windows_xp
  • CPU: x86
  • Submitted: 2003-04-30
  • Updated: 2005-07-21
  • Resolved: 2005-07-21
Related Reports
Duplicate :  
Description
Name: rmT116609			Date: 04/30/2003


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)

java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b19)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b19, mixed mode)


FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
java.lang.InternalError instead of Exception

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
import java.io.*;
import java.applet.*;
import java.awt.*;

public class ReadString extends Applet{
	public static void crash() {
		byte[] b = new byte[2];
		b[0]=(byte)0xff;
		b[1]=(byte)0xfe;
		ByteArrayInputStream bais = new ByteArrayInputStream(b);
		String s;
		InputStreamReader isr= null;
		try{
		isr = new InputStreamReader(bais,"Unicode");
		}
		catch (java.io.UnsupportedEncodingException e) { e.printStackTrace(); }
		
		BufferedReader in = new BufferedReader( isr   );
		
		try {
			while ( (s = in.readLine()) != null ) {	   System.out.println( s );}
		}

		catch (java.io.IOException e) {	e.printStackTrace(); }
		


	}
	
	public void paint(Graphics g) {
		crash();
	}
	public static void main(String[] a) {
		crash();
		
	}
}

EXPECTED VERSUS ACTUAL BEHAVIOR :
Exception
Exception in thread "main" java.lang.InternalError: Converter malfunction (Unico
de) -- please submit a bug report via http://java.sun.com/cgi-bin/bugreport.cgi
        at sun.nio.cs.StreamDecoder$ConverterSD.malfunction(StreamDecoder.java:2
33)
        at sun.nio.cs.StreamDecoder$ConverterSD.convertInto(StreamDecoder.java:2
49)
        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 ReadString.crash(ReadString.java:23)
        at ReadString.main(ReadString.java:36)

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.InternalError: Converter malfunction (Unico
de) -- please submit a bug report via http://java.sun.com/cgi-bin/bugreport.cgi
        at sun.nio.cs.StreamDecoder$ConverterSD.malfunction(StreamDecoder.java:2
33)
        at sun.nio.cs.StreamDecoder$ConverterSD.convertInto(StreamDecoder.java:2
49)
        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 ReadString.crash(ReadString.java:23)
        at ReadString.main(ReadString.java:36)

REPRODUCIBILITY :
This bug can be reproduced always.

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

public class ReadString extends Applet{
	public static void crash() {
		byte[] b = new byte[2];
		b[0]=(byte)0xff;
		b[1]=(byte)0xfe;
		ByteArrayInputStream bais = new ByteArrayInputStream(b);
		String s;
		InputStreamReader isr= null;
		try{
		isr = new InputStreamReader(bais,"Unicode");
		}
		catch (java.io.UnsupportedEncodingException e) { e.printStackTrace(); }
		
		BufferedReader in = new BufferedReader( isr   );
		
		try {
			while ( (s = in.readLine()) != null ) {	   System.out.println( s );}
		}

		catch (java.io.IOException e) {	e.printStackTrace(); }
		


	}
	
	public void paint(Graphics g) {
		crash();
	}
	public static void main(String[] a) {
		crash();
		
	}
}
---------- END SOURCE ----------

(Review ID: 185057) 
======================================================================

Comments
EVALUATION Not for 1.4.2. -- ###@###.### 2003/4/30 Will reconsider addressing this for 1.5.1 or 1.6 release. The "Unicode" supported encoding was maintained for compatibility reasons. The preferred 16 bit unicode encodings are provided by the nio Charsets whose canonical names are "UTF-16", "UTF-16BE" and "UTF-16LE". Since "Unicode" (as a named encoding) support needs to be maintained for compatibility purposes in 1.6 (at the latest) when the sun.io legacy converters are removed it will be incumbent upon us to ensure that the charset provided will never throw unchecked exceptions when provided with illegal input. Instead a MalformedInputException ought to be thrown. ###@###.### 2003-09-23 (1)legacy sun.io converters have been removed from 6.0, so it's no longer an issue for it (2)there is an aged bug in sun.io.ByteToCharUnicode.java, see bug#6292315, need that get fixed for previous releases. Use "isr = new InputStreamReader(bais,"UnicodeLittle");" in testcase for 5.0 to reproduce the issue. Close this one as the dup of #6292315 ###@###.### 2005-07-21 23:21:40 GMT
21-07-2005

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang
08-09-2004