Skip to content

Commit 57f2d48

Browse files
committed
8300863: Remove C-style array declarations in java.io
Reviewed-by: alanb, rriggs, darcy, iris
1 parent 2292ce1 commit 57f2d48

8 files changed

+19
-19
lines changed

src/java.base/share/classes/java/io/BufferedOutputStream.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -48,7 +48,7 @@ public class BufferedOutputStream extends FilterOutputStream {
4848
/**
4949
* The internal buffer where data is stored.
5050
*/
51-
protected byte buf[];
51+
protected byte[] buf;
5252

5353
/**
5454
* The number of valid bytes in the buffer. This value is always

src/java.base/share/classes/java/io/BufferedWriter.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -73,8 +73,9 @@ public class BufferedWriter extends Writer {
7373

7474
private Writer out;
7575

76-
private char cb[];
77-
private int nChars, nextChar;
76+
private char[] cb;
77+
private int nChars;
78+
private int nextChar;
7879
private final int maxChars; // maximum number of buffers chars
7980

8081
/**

src/java.base/share/classes/java/io/ByteArrayInputStream.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -53,7 +53,7 @@ public class ByteArrayInputStream extends InputStream {
5353
* stream; element {@code buf[pos]} is
5454
* the next byte to be read.
5555
*/
56-
protected byte buf[];
56+
protected byte[] buf;
5757

5858
/**
5959
* The index of the next character to read from the input stream buffer.

src/java.base/share/classes/java/io/ByteArrayOutputStream.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -51,7 +51,7 @@ public class ByteArrayOutputStream extends OutputStream {
5151
/**
5252
* The buffer where data is stored.
5353
*/
54-
protected byte buf[];
54+
protected byte[] buf;
5555

5656
/**
5757
* The number of valid bytes in the buffer.

src/java.base/share/classes/java/io/CharArrayWriter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class CharArrayWriter extends Writer {
4444
/**
4545
* The buffer where data is stored.
4646
*/
47-
protected char buf[];
47+
protected char[] buf;
4848

4949
/**
5050
* The number of chars in the buffer.

src/java.base/share/classes/java/io/File.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@ private final String[] normalizedList() {
12161216
* @see java.nio.file.Files#newDirectoryStream(Path,String)
12171217
*/
12181218
public String[] list(FilenameFilter filter) {
1219-
String names[] = normalizedList();
1219+
String[] names = normalizedList();
12201220
if ((names == null) || (filter == null)) {
12211221
return names;
12221222
}
@@ -1309,7 +1309,7 @@ public File[] listFiles() {
13091309
* @see java.nio.file.Files#newDirectoryStream(Path,String)
13101310
*/
13111311
public File[] listFiles(FilenameFilter filter) {
1312-
String ss[] = normalizedList();
1312+
String[] ss = normalizedList();
13131313
if (ss == null) return null;
13141314
ArrayList<File> files = new ArrayList<>();
13151315
for (String s : ss)
@@ -1347,7 +1347,7 @@ public File[] listFiles(FilenameFilter filter) {
13471347
* @see java.nio.file.Files#newDirectoryStream(Path,java.nio.file.DirectoryStream.Filter)
13481348
*/
13491349
public File[] listFiles(FileFilter filter) {
1350-
String ss[] = normalizedList();
1350+
String[] ss = normalizedList();
13511351
if (ss == null) return null;
13521352
ArrayList<File> files = new ArrayList<>();
13531353
for (String s : ss) {

src/java.base/share/classes/java/io/PipedReader.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -54,7 +54,7 @@ more sophisticated. Either using thread groups (but what about
5454
/**
5555
* The circular buffer into which incoming data is placed.
5656
*/
57-
char buffer[];
57+
char[] buffer;
5858

5959
/**
6060
* The index of the position in the circular buffer at which the
@@ -100,7 +100,6 @@ public PipedReader(PipedWriter src, int pipeSize) throws IOException {
100100
connect(src);
101101
}
102102

103-
104103
/**
105104
* Creates a {@code PipedReader} so
106105
* that it is not yet {@linkplain #connect(java.io.PipedWriter)

src/java.base/share/classes/java/io/StreamTokenizer.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1995, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -68,7 +68,7 @@ public class StreamTokenizer {
6868
private Reader reader = null;
6969
private InputStream input = null;
7070

71-
private char buf[] = new char[20];
71+
private char[] buf = new char[20];
7272

7373
/**
7474
* The next character to be considered by the nextToken method. May also
@@ -91,7 +91,7 @@ public class StreamTokenizer {
9191
private boolean slashSlashCommentsP = false;
9292
private boolean slashStarCommentsP = false;
9393

94-
private byte ctype[] = new byte[256];
94+
private final byte[] ctype = new byte[256];
9595
private static final byte CT_WHITESPACE = 1;
9696
private static final byte CT_DIGIT = 2;
9797
private static final byte CT_ALPHA = 4;

0 commit comments

Comments
 (0)