RFR 8203768 : Avoid reallocation in java.base/unix/classes/java/lang/ProcessImpl.java

Ivan Gerasimov ivan.gerasimov at oracle.com
Tue Jun 5 04:26:48 UTC 2018


Hello!

When closing a Process, its stdout and stderr are drained:  The 
remaining bytes are copied into an array, and then the out/err stream is 
replaced with ByteArrayInputStream().

In a case when a fewer number of bytes were read then the 
Stream.available() suggested, the array is reallocated with 
Arrays.copyOf().

It is possible to avoid reallocation, and use three-args 
ByteArrayInputStream() constructor to specify a portion of the array used.

Would you please help review this trivial fix?

BUGURL: https://bugs.openjdk.java.net/browse/JDK-8203768
WEBREV: http://cr.openjdk.java.net/~igerasim/8203768/00/webrev/

All existing tests pass on all supported platforms.

Thanks in advance!

-- 
With kind regards,
Ivan Gerasimov



More information about the core-libs-dev mailing list