mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8276806: Use Objects.checkFromIndexSize where possible in java.base
Reviewed-by: rriggs, lancea
This commit is contained in:
parent
30087cc1b8
commit
73a9654c26
11 changed files with 40 additions and 43 deletions
|
@ -1035,10 +1035,7 @@ public class ObjectInputStream
|
|||
if (buf == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
int endoff = off + len;
|
||||
if (off < 0 || len < 0 || endoff > buf.length || endoff < 0) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
Objects.checkFromIndexSize(off, len, buf.length);
|
||||
return bin.read(buf, off, len, false);
|
||||
}
|
||||
|
||||
|
@ -1207,10 +1204,7 @@ public class ObjectInputStream
|
|||
* @throws IOException If other I/O error has occurred.
|
||||
*/
|
||||
public void readFully(byte[] buf, int off, int len) throws IOException {
|
||||
int endoff = off + len;
|
||||
if (off < 0 || len < 0 || endoff > buf.length || endoff < 0) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
Objects.checkFromToIndex(off, len, buf.length);
|
||||
bin.readFully(buf, off, len, false);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue