8276164: RandomAccessFile#write method could throw IndexOutOfBoundsException that is not described in javadoc

Reviewed-by: alanb
This commit is contained in:
Masanori Yano 2021-11-02 06:44:48 +00:00 committed by Alan Bateman
parent 0488ebdf14
commit 9bf31652cb
2 changed files with 5 additions and 1 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -92,6 +92,9 @@ public interface DataOutput {
* @param off the start offset in the data.
* @param len the number of bytes to write.
* @throws IOException if an I/O error occurs.
* @throws IndexOutOfBoundsException If {@code off} is negative,
* {@code len} is negative, or {@code len} is greater than
* {@code b.length - off}
*/
void write(byte[] b, int off, int len) throws IOException;

View File

@ -553,6 +553,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* @param off the start offset in the data.
* @param len the number of bytes to write.
* @throws IOException if an I/O error occurs.
* @throws IndexOutOfBoundsException {@inheritDoc}
*/
public void write(byte[] b, int off, int len) throws IOException {
writeBytes(b, off, len);