8299600: Use Objects.check*() where appropriate in java.io

Reviewed-by: alanb, bpb
This commit is contained in:
Sergey Tsypanov 2023-01-06 21:01:21 +00:00 committed by Brian Burkhalter
parent 4a95c74b76
commit d086e82b3c
6 changed files with 28 additions and 27 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2023, 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
@ -25,6 +25,8 @@
package java.io;
import java.util.Objects;
/**
* This class is an input stream filter that provides the added
* functionality of keeping track of the current line number.
@ -129,10 +131,9 @@ public class LineNumberInputStream extends FilterInputStream {
public int read(byte[] b, int off, int len) throws IOException {
if (b == null) {
throw new NullPointerException();
} else if ((off < 0) || (off > b.length) || (len < 0) ||
((off + len) > b.length) || ((off + len) < 0)) {
throw new IndexOutOfBoundsException();
} else if (len == 0) {
}
Objects.checkFromIndexSize(off, len, b.length);
if (len == 0) {
return 0;
}