-
Enhancement
-
Resolution: Fixed
-
P5
-
None
-
b07
ByteArrayInputStream inherits methods readAllBytes(), readNBytes() and transferTo() from InputStream. These were added in Java 9.
Benefits of overriding:
1) The overridden readAllBytes() and readNBytes() methods should NOT declare "throws IOException" because it cannot occur with these methods. This makes BAIS easier to use.
2) The overridden methods can be optimized to copy bytes from the internal buffer in a single bulk operation instead of in a copy loop.
There is a potential compatibility problem with adding these overrides, as a subclass of BAIS might override these methods and declare "throws IOException". This seems fairly unlikely, though. (Ideally, these overrides would have been added in Java 9.)
It would also be nice if BAIS were able to override read(byte[]) and not declare "throws IOException". This has a worse compatibility problem, though, since this method has been around since 1.0, so there has been a much longer period of time for subclasses to have overridden this method.
SeeJDK-8180410 for similar issues with ByteArrayOutputStream.
Benefits of overriding:
1) The overridden readAllBytes() and readNBytes() methods should NOT declare "throws IOException" because it cannot occur with these methods. This makes BAIS easier to use.
2) The overridden methods can be optimized to copy bytes from the internal buffer in a single bulk operation instead of in a copy loop.
There is a potential compatibility problem with adding these overrides, as a subclass of BAIS might override these methods and declare "throws IOException". This seems fairly unlikely, though. (Ideally, these overrides would have been added in Java 9.)
It would also be nice if BAIS were able to override read(byte[]) and not declare "throws IOException". This has a worse compatibility problem, though, since this method has been around since 1.0, so there has been a much longer period of time for subclasses to have overridden this method.
See
- csr for
-
JDK-8193148 ByteArrayInputStream should override readAllBytes, readNBytes, and transferTo
- Closed
- duplicates
-
JDK-8067661 Add more efficient transferTo implementations to various input streams
- Closed
- relates to
-
JDK-8321053 Use ByteArrayInputStream.buf directly when parameter of transferTo() is trusted
- Closed
-
JDK-8180410 ByteArrayOutputStream should not throw IOExceptions
- Resolved
- links to
(1 links to)