8272626: Avoid C-style array declarations in java.*

Reviewed-by: dfuchs, alanb
This commit is contained in:
Claes Redestad 2021-08-18 10:47:03 +00:00
parent e8f1219d6f
commit 30b0f820ce
54 changed files with 140 additions and 140 deletions

View file

@ -328,7 +328,7 @@ public class BufferedInputStream extends FilterInputStream {
* invoking its {@link #close()} method,
* or an I/O error occurs.
*/
public synchronized int read(byte b[], int off, int len)
public synchronized int read(byte[] b, int off, int len)
throws IOException
{
getBufIfOpen(); // Check for closed stream

View file

@ -114,7 +114,7 @@ public class BufferedOutputStream extends FilterOutputStream {
* @throws IOException if an I/O error occurs.
*/
@Override
public synchronized void write(byte b[], int off, int len) throws IOException {
public synchronized void write(byte[] b, int off, int len) throws IOException {
if (len >= buf.length) {
/* If the request length exceeds the size of the output buffer,
flush the output buffer and then write the data directly.

View file

@ -166,7 +166,7 @@ public class BufferedWriter extends Writer {
*
* @throws IOException If an I/O error occurs
*/
public void write(char cbuf[], int off, int len) throws IOException {
public void write(char[] cbuf, int off, int len) throws IOException {
synchronized (lock) {
ensureOpen();
if ((off < 0) || (off > cbuf.length) || (len < 0) ||

View file

@ -102,7 +102,7 @@ public class ByteArrayInputStream extends InputStream {
*
* @param buf the input buffer.
*/
public ByteArrayInputStream(byte buf[]) {
public ByteArrayInputStream(byte[] buf) {
this.buf = buf;
this.pos = 0;
this.count = buf.length;
@ -122,7 +122,7 @@ public class ByteArrayInputStream extends InputStream {
* @param offset the offset in the buffer of the first byte to read.
* @param length the maximum number of bytes to read from the buffer.
*/
public ByteArrayInputStream(byte buf[], int offset, int length) {
public ByteArrayInputStream(byte[] buf, int offset, int length) {
this.buf = buf;
this.pos = offset;
this.count = Math.min(offset + length, buf.length);
@ -173,7 +173,7 @@ public class ByteArrayInputStream extends InputStream {
* {@code len} is negative, or {@code len} is greater than
* {@code b.length - off}
*/
public synchronized int read(byte b[], int off, int len) {
public synchronized int read(byte[] b, int off, int len) {
Objects.checkFromIndexSize(off, len, b.length);
if (pos >= count) {

View file

@ -125,7 +125,7 @@ public class ByteArrayOutputStream extends OutputStream {
* {@code len} is negative, or {@code len} is greater than
* {@code b.length - off}
*/
public synchronized void write(byte b[], int off, int len) {
public synchronized void write(byte[] b, int off, int len) {
Objects.checkFromIndexSize(off, len, b.length);
ensureCapacity(count + len);
System.arraycopy(b, off, buf, count, len);
@ -144,7 +144,7 @@ public class ByteArrayOutputStream extends OutputStream {
* @throws NullPointerException if {@code b} is {@code null}.
* @since 11
*/
public void writeBytes(byte b[]) {
public void writeBytes(byte[] b) {
write(b, 0, b.length);
}

View file

@ -96,7 +96,7 @@ public class CharArrayWriter extends Writer {
* or {@code off + len} is negative or greater than the length
* of the given array
*/
public void write(char c[], int off, int len) {
public void write(char[] c, int off, int len) {
if ((off < 0) || (off > c.length) || (len < 0) ||
((off + len) > c.length) || ((off + len) < 0)) {
throw new IndexOutOfBoundsException();

View file

@ -475,7 +475,7 @@ public final class Console implements Flushable
return in.ready();
}
public int read(char cbuf[], int offset, int length)
public int read(char[] cbuf, int offset, int length)
throws IOException
{
int off = offset;

View file

@ -196,7 +196,7 @@ public interface DataInput {
* all the bytes.
* @throws IOException if an I/O error occurs.
*/
void readFully(byte b[]) throws IOException;
void readFully(byte[] b) throws IOException;
/**
*
@ -246,7 +246,7 @@ public interface DataInput {
* all the bytes.
* @throws IOException if an I/O error occurs.
*/
void readFully(byte b[], int off, int len) throws IOException;
void readFully(byte[] b, int off, int len) throws IOException;
/**
* Makes an attempt to skip over

View file

@ -98,7 +98,7 @@ public class DataInputStream extends FilterInputStream implements DataInput {
* @see java.io.FilterInputStream#in
* @see java.io.InputStream#read(byte[], int, int)
*/
public final int read(byte b[]) throws IOException {
public final int read(byte[] b) throws IOException {
return in.read(b, 0, b.length);
}
@ -147,7 +147,7 @@ public class DataInputStream extends FilterInputStream implements DataInput {
* @see java.io.FilterInputStream#in
* @see java.io.InputStream#read(byte[], int, int)
*/
public final int read(byte b[], int off, int len) throws IOException {
public final int read(byte[] b, int off, int len) throws IOException {
return in.read(b, off, len);
}
@ -168,7 +168,7 @@ public class DataInputStream extends FilterInputStream implements DataInput {
* another I/O error occurs.
* @see java.io.FilterInputStream#in
*/
public final void readFully(byte b[]) throws IOException {
public final void readFully(byte[] b) throws IOException {
readFully(b, 0, b.length);
}
@ -194,7 +194,7 @@ public class DataInputStream extends FilterInputStream implements DataInput {
* another I/O error occurs.
* @see java.io.FilterInputStream#in
*/
public final void readFully(byte b[], int off, int len) throws IOException {
public final void readFully(byte[] b, int off, int len) throws IOException {
Objects.checkFromIndexSize(off, len, b.length);
int n = 0;
while (n < len) {

View file

@ -71,7 +71,7 @@ public interface DataOutput {
* @param b the data.
* @throws IOException if an I/O error occurs.
*/
void write(byte b[]) throws IOException;
void write(byte[] b) throws IOException;
/**
* Writes {@code len} bytes from array
@ -93,7 +93,7 @@ public interface DataOutput {
* @param len the number of bytes to write.
* @throws IOException if an I/O error occurs.
*/
void write(byte b[], int off, int len) throws IOException;
void write(byte[] b, int off, int len) throws IOException;
/**
* Writes a {@code boolean} value to this output stream.

View file

@ -106,7 +106,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
* @throws IOException if an I/O error occurs.
* @see java.io.FilterOutputStream#out
*/
public synchronized void write(byte b[], int off, int len)
public synchronized void write(byte[] b, int off, int len)
throws IOException
{
out.write(b, off, len);

View file

@ -237,7 +237,7 @@ public class FileInputStream extends InputStream
* @param len the number of bytes that are written
* @throws IOException If an I/O error has occurred.
*/
private native int readBytes(byte b[], int off, int len) throws IOException;
private native int readBytes(byte[] b, int off, int len) throws IOException;
/**
* Reads up to {@code b.length} bytes of data from this input
@ -250,7 +250,7 @@ public class FileInputStream extends InputStream
* the file has been reached.
* @throws IOException if an I/O error occurs.
*/
public int read(byte b[]) throws IOException {
public int read(byte[] b) throws IOException {
return readBytes(b, 0, b.length);
}
@ -272,7 +272,7 @@ public class FileInputStream extends InputStream
* {@code b.length - off}
* @throws IOException if an I/O error occurs.
*/
public int read(byte b[], int off, int len) throws IOException {
public int read(byte[] b, int off, int len) throws IOException {
return readBytes(b, off, len);
}

View file

@ -322,7 +322,7 @@ public class FileOutputStream extends OutputStream
* end of file
* @throws IOException If an I/O error has occurred.
*/
private native void writeBytes(byte b[], int off, int len, boolean append)
private native void writeBytes(byte[] b, int off, int len, boolean append)
throws IOException;
/**
@ -332,7 +332,7 @@ public class FileOutputStream extends OutputStream
* @param b the data.
* @throws IOException if an I/O error occurs.
*/
public void write(byte b[]) throws IOException {
public void write(byte[] b) throws IOException {
writeBytes(b, 0, b.length, fdAccess.getAppend(fd));
}
@ -345,7 +345,7 @@ public class FileOutputStream extends OutputStream
* @param len the number of bytes to write.
* @throws IOException if an I/O error occurs.
*/
public void write(byte b[], int off, int len) throws IOException {
public void write(byte[] b, int off, int len) throws IOException {
writeBytes(b, off, len, fdAccess.getAppend(fd));
}

View file

@ -102,7 +102,7 @@ public class FilterInputStream extends InputStream {
* @throws IOException if an I/O error occurs.
* @see java.io.FilterInputStream#read(byte[], int, int)
*/
public int read(byte b[]) throws IOException {
public int read(byte[] b) throws IOException {
return read(b, 0, b.length);
}
@ -128,7 +128,7 @@ public class FilterInputStream extends InputStream {
* @throws IOException if an I/O error occurs.
* @see java.io.FilterInputStream#in
*/
public int read(byte b[], int off, int len) throws IOException {
public int read(byte[] b, int off, int len) throws IOException {
return in.read(b, off, len);
}

View file

@ -104,7 +104,7 @@ public class FilterOutputStream extends OutputStream {
* @see java.io.FilterOutputStream#write(byte[], int, int)
*/
@Override
public void write(byte b[]) throws IOException {
public void write(byte[] b) throws IOException {
write(b, 0, b.length);
}
@ -129,7 +129,7 @@ public class FilterOutputStream extends OutputStream {
* @see java.io.FilterOutputStream#write(int)
*/
@Override
public void write(byte b[], int off, int len) throws IOException {
public void write(byte[] b, int off, int len) throws IOException {
if ((off | len | (b.length - (len + off)) | (off + len)) < 0)
throw new IndexOutOfBoundsException();

View file

@ -79,7 +79,7 @@ public abstract class FilterWriter extends Writer {
*
* @throws IOException If an I/O error occurs
*/
public void write(char cbuf[], int off, int len) throws IOException {
public void write(char[] cbuf, int off, int len) throws IOException {
out.write(cbuf, off, len);
}

View file

@ -214,7 +214,7 @@ public abstract class InputStream implements Closeable {
* @throws NullPointerException if {@code b} is {@code null}.
* @see java.io.InputStream#read(byte[], int, int)
*/
public int read(byte b[]) throws IOException {
public int read(byte[] b) throws IOException {
return read(b, 0, b.length);
}
@ -275,7 +275,7 @@ public abstract class InputStream implements Closeable {
* {@code b.length - off}
* @see java.io.InputStream#read()
*/
public int read(byte b[], int off, int len) throws IOException {
public int read(byte[] b, int off, int len) throws IOException {
Objects.checkFromIndexSize(off, len, b.length);
if (len == 0) {
return 0;

View file

@ -126,7 +126,7 @@ public class LineNumberInputStream extends FilterInputStream {
* @throws IOException if an I/O error occurs.
* @see java.io.LineNumberInputStream#read()
*/
public int read(byte b[], int off, int len) throws IOException {
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) ||

View file

@ -187,7 +187,7 @@ public class LineNumberReader extends BufferedReader {
* @throws IOException {@inheritDoc}
*/
@SuppressWarnings("fallthrough")
public int read(char cbuf[], int off, int len) throws IOException {
public int read(char[] cbuf, int off, int len) throws IOException {
synchronized (lock) {
int n = super.read(cbuf, off, len);

View file

@ -66,7 +66,7 @@ public interface ObjectInput extends DataInput, AutoCloseable {
* returned when the end of the stream is reached.
* @throws IOException If an I/O error has occurred.
*/
public int read(byte b[]) throws IOException;
public int read(byte[] b) throws IOException;
/**
* Reads into an array of bytes. This method will
@ -78,7 +78,7 @@ public interface ObjectInput extends DataInput, AutoCloseable {
* returned when the end of the stream is reached.
* @throws IOException If an I/O error has occurred.
*/
public int read(byte b[], int off, int len) throws IOException;
public int read(byte[] b, int off, int len) throws IOException;
/**
* Skips n bytes of input.

View file

@ -61,7 +61,7 @@ public interface ObjectOutput extends DataOutput, AutoCloseable {
* @param b the data to be written
* @throws IOException If an I/O error has occurred.
*/
public void write(byte b[]) throws IOException;
public void write(byte[] b) throws IOException;
/**
* Writes a sub array of bytes.
@ -70,7 +70,7 @@ public interface ObjectOutput extends DataOutput, AutoCloseable {
* @param len the number of bytes that are written
* @throws IOException If an I/O error has occurred.
*/
public void write(byte b[], int off, int len) throws IOException;
public void write(byte[] b, int off, int len) throws IOException;
/**
* Flushes the stream. This will write any buffered

View file

@ -84,7 +84,7 @@ public abstract class OutputStream implements Closeable, Flushable {
}
@Override
public void write(byte b[], int off, int len) throws IOException {
public void write(byte[] b, int off, int len) throws IOException {
Objects.checkFromIndexSize(off, len, b.length);
ensureOpen();
}
@ -123,7 +123,7 @@ public abstract class OutputStream implements Closeable, Flushable {
* @throws IOException if an I/O error occurs.
* @see java.io.OutputStream#write(byte[], int, int)
*/
public void write(byte b[]) throws IOException {
public void write(byte[] b) throws IOException {
write(b, 0, b.length);
}
@ -155,7 +155,7 @@ public abstract class OutputStream implements Closeable, Flushable {
* an {@code IOException} is thrown if the output
* stream is closed.
*/
public void write(byte b[], int off, int len) throws IOException {
public void write(byte[] b, int off, int len) throws IOException {
Objects.checkFromIndexSize(off, len, b.length);
// len == 0 condition implicitly handled by loop bounds
for (int i = 0 ; i < len ; i++) {

View file

@ -201,7 +201,7 @@ public class OutputStreamWriter extends Writer {
*
* @throws IOException If an I/O error occurs
*/
public void write(char cbuf[], int off, int len) throws IOException {
public void write(char[] cbuf, int off, int len) throws IOException {
se.write(cbuf, off, len);
}

View file

@ -222,7 +222,7 @@ public class PipedInputStream extends InputStream {
* {@link #connect(java.io.PipedOutputStream) unconnected},
* closed,or if an I/O error occurs.
*/
synchronized void receive(byte b[], int off, int len) throws IOException {
synchronized void receive(byte[] b, int off, int len) throws IOException {
checkStateForReceive();
writeSide = Thread.currentThread();
int bytesToTransfer = len;
@ -364,7 +364,7 @@ public class PipedInputStream extends InputStream {
* {@link #connect(java.io.PipedOutputStream) unconnected},
* closed, or if an I/O error occurs.
*/
public synchronized int read(byte b[], int off, int len) throws IOException {
public synchronized int read(byte[] b, int off, int len) throws IOException {
if (b == null) {
throw new NullPointerException();
} else if (off < 0 || len < 0 || len > b.length - off) {

View file

@ -135,7 +135,7 @@ public class PipedOutputStream extends OutputStream {
* {@link #connect(java.io.PipedInputStream) unconnected},
* closed, or if an I/O error occurs.
*/
public void write(byte b[], int off, int len) throws IOException {
public void write(byte[] b, int off, int len) throws IOException {
var sink = this.sink;
if (sink == null) {
throw new IOException("Pipe not connected");

View file

@ -202,7 +202,7 @@ public class PipedReader extends Reader {
* Receives data into an array of characters. This method will
* block until some input is available.
*/
synchronized void receive(char c[], int off, int len) throws IOException {
synchronized void receive(char[] c, int off, int len) throws IOException {
while (--len >= 0) {
receive(c[off++]);
}
@ -288,7 +288,7 @@ public class PipedReader extends Reader {
* {@link #connect(java.io.PipedWriter) unconnected}, closed,
* or an I/O error occurs.
*/
public synchronized int read(char cbuf[], int off, int len) throws IOException {
public synchronized int read(char[] cbuf, int off, int len) throws IOException {
if (!connected) {
throw new IOException("Pipe not connected");
} else if (closedByReader) {

View file

@ -147,7 +147,7 @@ public class PipedWriter extends Writer {
* {@link #connect(java.io.PipedReader) unconnected}, closed
* or an I/O error occurs.
*/
public void write(char cbuf[], int off, int len) throws IOException {
public void write(char[] cbuf, int off, int len) throws IOException {
if (sink == null) {
throw new IOException("Pipe not connected");
} else if ((off | len | (off + len) | (cbuf.length - (off + len))) < 0) {

View file

@ -561,7 +561,7 @@ public class PrintStream extends FilterOutputStream
* @param len Number of bytes to write
*/
@Override
public void write(byte buf[], int off, int len) {
public void write(byte[] buf, int off, int len) {
try {
synchronized (this) {
ensureOpen();
@ -612,7 +612,7 @@ public class PrintStream extends FilterOutputStream
* @since 14
*/
@Override
public void write(byte buf[]) throws IOException {
public void write(byte[] buf) throws IOException {
this.write(buf, 0, buf.length);
}
@ -634,7 +634,7 @@ public class PrintStream extends FilterOutputStream
*
* @since 14
*/
public void writeBytes(byte buf[]) {
public void writeBytes(byte[] buf) {
this.write(buf, 0, buf.length);
}
@ -845,7 +845,7 @@ public class PrintStream extends FilterOutputStream
*
* @throws NullPointerException If {@code s} is {@code null}
*/
public void print(char s[]) {
public void print(char[] s) {
write(s);
}

View file

@ -499,7 +499,7 @@ public class PrintWriter extends Writer {
* cause the corresponding method of the underlying {@code Writer}
* to throw an {@code IndexOutOfBoundsException}
*/
public void write(char buf[], int off, int len) {
public void write(char[] buf, int off, int len) {
try {
synchronized (lock) {
ensureOpen();
@ -519,7 +519,7 @@ public class PrintWriter extends Writer {
* Writer class because it must suppress I/O exceptions.
* @param buf Array of characters to be written
*/
public void write(char buf[]) {
public void write(char[] buf) {
write(buf, 0, buf.length);
}
@ -668,7 +668,7 @@ public class PrintWriter extends Writer {
*
* @throws NullPointerException If {@code s} is {@code null}
*/
public void print(char s[]) {
public void print(char[] s) {
write(s);
}
@ -801,7 +801,7 @@ public class PrintWriter extends Writer {
*
* @param x the array of {@code char} values to be printed
*/
public void println(char x[]) {
public void println(char[] x) {
synchronized (lock) {
print(x);
println();

View file

@ -374,7 +374,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* @param len the number of bytes to read.
* @throws IOException If an I/O error has occurred.
*/
private native int readBytes(byte b[], int off, int len) throws IOException;
private native int readBytes(byte[] b, int off, int len) throws IOException;
/**
* Reads up to {@code len} bytes of data from this file into an
@ -401,7 +401,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* {@code len} is negative, or {@code len} is greater than
* {@code b.length - off}
*/
public int read(byte b[], int off, int len) throws IOException {
public int read(byte[] b, int off, int len) throws IOException {
return readBytes(b, off, len);
}
@ -424,7 +424,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* or if some other I/O error occurs.
* @throws NullPointerException If {@code b} is {@code null}.
*/
public int read(byte b[]) throws IOException {
public int read(byte[] b) throws IOException {
return readBytes(b, 0, b.length);
}
@ -441,7 +441,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* all the bytes.
* @throws IOException if an I/O error occurs.
*/
public final void readFully(byte b[]) throws IOException {
public final void readFully(byte[] b) throws IOException {
readFully(b, 0, b.length);
}
@ -463,7 +463,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* all the bytes.
* @throws IOException if an I/O error occurs.
*/
public final void readFully(byte b[], int off, int len) throws IOException {
public final void readFully(byte[] b, int off, int len) throws IOException {
int n = 0;
do {
int count = this.read(b, off + n, len - n);
@ -532,7 +532,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* @param len the number of bytes that are written
* @throws IOException If an I/O error has occurred.
*/
private native void writeBytes(byte b[], int off, int len) throws IOException;
private native void writeBytes(byte[] b, int off, int len) throws IOException;
/**
* Writes {@code b.length} bytes from the specified byte array
@ -541,7 +541,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* @param b the data.
* @throws IOException if an I/O error occurs.
*/
public void write(byte b[]) throws IOException {
public void write(byte[] b) throws IOException {
writeBytes(b, 0, b.length);
}
@ -554,7 +554,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* @param len the number of bytes to write.
* @throws IOException if an I/O error occurs.
*/
public void write(byte b[], int off, int len) throws IOException {
public void write(byte[] b, int off, int len) throws IOException {
writeBytes(b, off, len);
}

View file

@ -184,7 +184,7 @@ public class SequenceInputStream extends InputStream {
* greater than {@code b.length - off}
* @throws IOException if an I/O error occurs.
*/
public int read(byte b[], int off, int len) throws IOException {
public int read(byte[] b, int off, int len) throws IOException {
if (in == null) {
return -1;
} else if (b == null) {

View file

@ -108,7 +108,7 @@ public class StringBufferInputStream extends InputStream {
* the stream has been reached.
*/
@SuppressWarnings("deprecation")
public synchronized int read(byte b[], int off, int len) {
public synchronized int read(byte[] b, int off, int len) {
if (b == null) {
throw new NullPointerException();
} else if ((off < 0) || (off > b.length) || (len < 0) ||

View file

@ -89,7 +89,7 @@ public class StringWriter extends Writer {
* or {@code off + len} is negative or greater than the length
* of the given array
*/
public void write(char cbuf[], int off, int len) {
public void write(char[] cbuf, int off, int len) {
if ((off < 0) || (off > cbuf.length) || (len < 0) ||
((off + len) > cbuf.length) || ((off + len) < 0)) {
throw new IndexOutOfBoundsException();

View file

@ -209,7 +209,7 @@ public abstract class Writer implements Appendable, Closeable, Flushable {
* @throws IOException
* If an I/O error occurs
*/
public void write(char cbuf[]) throws IOException {
public void write(char[] cbuf) throws IOException {
write(cbuf, 0, cbuf.length);
}
@ -234,7 +234,7 @@ public abstract class Writer implements Appendable, Closeable, Flushable {
* @throws IOException
* If an I/O error occurs
*/
public abstract void write(char cbuf[], int off, int len) throws IOException;
public abstract void write(char[] cbuf, int off, int len) throws IOException;
/**
* Writes a string.