--- old/src/java.base/share/classes/java/io/ByteArrayInputStream.java 2018-03-14 11:34:52.000000000 -0700 +++ new/src/java.base/share/classes/java/io/ByteArrayInputStream.java 2018-03-14 11:34:51.000000000 -0700 @@ -142,6 +142,7 @@ * @return the next byte of data, or {@code -1} if the end of the * stream has been reached. */ + @Override public synchronized int read() { return (pos < count) ? (buf[pos++] & 0xff) : -1; } @@ -175,6 +176,7 @@ * {@code len} is negative, or {@code len} is greater than * {@code b.length - off} */ + @Override public synchronized int read(byte b[], int off, int len) { Objects.checkFromIndexSize(off, len, b.length); @@ -194,22 +196,25 @@ return len; } + @Override public synchronized byte[] readAllBytes() { byte[] result = Arrays.copyOfRange(buf, pos, count); pos = count; return result; } - public synchronized int readNBytes(byte[] b, int off, int len) { + @Override + public int readNBytes(byte[] b, int off, int len) { int n = read(b, off, len); return n == -1 ? 0 : n; } + @Override public synchronized long transferTo(OutputStream out) throws IOException { - int pos0 = pos; - out.write(buf, pos, count - pos); + int len = count - pos; + out.write(buf, pos, len); pos = count; - return count - pos0; + return len; } /** @@ -224,6 +229,7 @@ * @param n the number of bytes to be skipped. * @return the actual number of bytes skipped. */ + @Override public synchronized long skip(long n) { long k = count - pos; if (n < k) { @@ -244,6 +250,7 @@ * @return the number of remaining bytes that can be read (or skipped * over) from this input stream without blocking. */ + @Override public synchronized int available() { return count - pos; } @@ -255,6 +262,7 @@ * * @since 1.1 */ + @Override public boolean markSupported() { return true; } @@ -274,6 +282,7 @@ * * @since 1.1 */ + @Override public void mark(int readAheadLimit) { mark = pos; } @@ -283,6 +292,7 @@ * is 0 unless another position was marked or an offset was specified * in the constructor. */ + @Override public synchronized void reset() { pos = mark; } @@ -292,6 +302,7 @@ * this class can be called after the stream has been closed without * generating an {@code IOException}. */ + @Override public void close() throws IOException { } --- old/test/jdk/java/io/ByteArrayInputStream/ReadAllReadNTransferTo.java 2018-03-14 11:34:52.000000000 -0700 +++ new/test/jdk/java/io/ByteArrayInputStream/ReadAllReadNTransferTo.java 2018-03-14 11:34:52.000000000 -0700 @@ -45,30 +45,30 @@ public static void main(String... args) throws IOException { byte[] buf = new byte[SIZE]; random.nextBytes(buf); - int offset = random.nextInt(SIZE/2); - int length = random.nextInt(SIZE - offset); + int position = random.nextInt(SIZE/2); + int size = random.nextInt(SIZE - position); ByteArrayInputStream bais = - new ByteArrayInputStream(buf, offset, length); - int off = random.nextInt(length/2); - int len = random.nextInt(length - off); + new ByteArrayInputStream(buf, position, size); + int off = random.nextInt(size/2); + int len = random.nextInt(size- off); byte[] bN = new byte[off + len]; if (bais.readNBytes(bN, off, len) != len) { throw new RuntimeException("readNBytes return value"); } if (!Arrays.equals(bN, off, off + len, - buf, offset, offset + len)) { + buf, position, position + len)) { throw new RuntimeException("readNBytes content"); } byte[] bAll = bais.readAllBytes(); Objects.requireNonNull(bAll, "readAllBytes return value"); - if (bAll.length != length - len) { + if (bAll.length != size - len) { throw new RuntimeException("readAllBytes return value length"); } if (!Arrays.equals(bAll, 0, bAll.length, - buf, offset + len, offset + len + bAll.length)) { + buf, position + len, position + len + bAll.length)) { throw new RuntimeException("readAllBytes content"); }