The following test case terminates with an assertion failure in Merlin build 46 (and it completes successfully in build 45):
import java.io.*;
public class TestStream {
public static void main(String args[]) {
try {
InputStreamReader r = new InputStreamReader(
new ByteArrayInputStream(new byte[] { 'X' }));
char[] c = new char[1];
r.read(c);
System.out.println(c[0]);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Here is the failure in build 46:
Exception in thread "main" java.lang.Error
at java.io.InputStreamReader$CharsetFiller.fill(InputStreamReader.java:353)
at java.io.InputStreamReader.read(InputStreamReader.java:478)
at java.io.Reader.read(Reader.java:103)
at TestStream.main(TestStream.java:9)
The problem seems to be this assertion in line 353 of InputStreamReader:
int fill(char[] cbuf, int off, int end ) throws IOException {
if (!(end - off > 1)) throw new Error(); // ## assert
which fails if (end - off) == 1, which seems to be a legitimate input as far as I can tell. Shouldn't the assertion be just
if (!(end > off))
?
import java.io.*;
public class TestStream {
public static void main(String args[]) {
try {
InputStreamReader r = new InputStreamReader(
new ByteArrayInputStream(new byte[] { 'X' }));
char[] c = new char[1];
r.read(c);
System.out.println(c[0]);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Here is the failure in build 46:
Exception in thread "main" java.lang.Error
at java.io.InputStreamReader$CharsetFiller.fill(InputStreamReader.java:353)
at java.io.InputStreamReader.read(InputStreamReader.java:478)
at java.io.Reader.read(Reader.java:103)
at TestStream.main(TestStream.java:9)
The problem seems to be this assertion in line 353 of InputStreamReader:
int fill(char[] cbuf, int off, int end ) throws IOException {
if (!(end - off > 1)) throw new Error(); // ## assert
which fails if (end - off) == 1, which seems to be a legitimate input as far as I can tell. Shouldn't the assertion be just
if (!(end > off))
?
- duplicates
-
JDK-4401765 BufferedReader on stdin causes java.lang.Error
-
- Closed
-