In the case where an offset is provided to a ByteArrayInputStream constructor, and a reset is performed, where does the read begin from? There are two, mutually exclusive assertions in the spec:
The spec for the ByteArrayInputStream constructor that takes an offset says:
"Note that if bytes are simply read from the resulting input stream, elements buf[pos] through buf[pos+len-1] will be read; however, if a reset
operation is performed, then bytes buf[0] through buf[pos-1] will then
become available for input."
Under ByteArrayInputStream.mark() spec it says:
"If no mark has been set, then the value of the mark is the offset passed to the constructor (or 0 if the offset was not supplied)."
These two statements directly contradict one another. In the second case the appears to be no way to recover the data in the buffer in front of the offset position, whereas in the first case this seems to be a major thrust of the intended functionality. The first case provides more functionality and is what it looks like the developers really intended.
The spec. must provide one, clear direction so that the JCK tests can be developed, implementers know what to implement, and Application developers know which behavior to expect.
marcus.johnson@eng 2001-03-28
The spec for the ByteArrayInputStream constructor that takes an offset says:
"Note that if bytes are simply read from the resulting input stream, elements buf[pos] through buf[pos+len-1] will be read; however, if a reset
operation is performed, then bytes buf[0] through buf[pos-1] will then
become available for input."
Under ByteArrayInputStream.mark() spec it says:
"If no mark has been set, then the value of the mark is the offset passed to the constructor (or 0 if the offset was not supplied)."
These two statements directly contradict one another. In the second case the appears to be no way to recover the data in the buffer in front of the offset position, whereas in the first case this seems to be a major thrust of the intended functionality. The first case provides more functionality and is what it looks like the developers really intended.
The spec. must provide one, clear direction so that the JCK tests can be developed, implementers know what to implement, and Application developers know which behavior to expect.
marcus.johnson@eng 2001-03-28
- duplicates
-
JDK-4434186 ByteArrayInputStream.reset() behavior and spec. don't match re: pos field value
-
- Closed
-