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

@ -449,7 +449,7 @@ public class Runtime {
*
* @see ProcessBuilder
*/
public Process exec(String cmdarray[]) throws IOException {
public Process exec(String[] cmdarray) throws IOException {
return exec(cmdarray, null, null);
}

View file

@ -272,7 +272,7 @@ public final class String
* @param value
* The initial value of the string
*/
public String(char value[]) {
public String(char[] value) {
this(value, 0, value.length, null);
}
@ -297,7 +297,7 @@ public final class String
* If {@code offset} is negative, {@code count} is negative, or
* {@code offset} is greater than {@code value.length - count}
*/
public String(char value[], int offset, int count) {
public String(char[] value, int offset, int count) {
this(value, offset, count, rangeCheck(value, offset, count));
}
@ -394,7 +394,7 @@ public final class String
* @see #String(byte[])
*/
@Deprecated(since="1.1")
public String(byte ascii[], int hibyte, int offset, int count) {
public String(byte[] ascii, int hibyte, int offset, int count) {
checkBoundsOffCount(offset, count, ascii.length);
if (count == 0) {
this.value = "".value;
@ -446,7 +446,7 @@ public final class String
* @see #String(byte[])
*/
@Deprecated(since="1.1")
public String(byte ascii[], int hibyte) {
public String(byte[] ascii, int hibyte) {
this(ascii, hibyte, 0, ascii.length);
}
@ -1354,7 +1354,7 @@ public final class String
*
* @since 1.1
*/
public String(byte bytes[], String charsetName)
public String(byte[] bytes, String charsetName)
throws UnsupportedEncodingException {
this(bytes, 0, bytes.length, charsetName);
}
@ -1379,7 +1379,7 @@ public final class String
*
* @since 1.6
*/
public String(byte bytes[], Charset charset) {
public String(byte[] bytes, Charset charset) {
this(bytes, 0, bytes.length, charset);
}
@ -1665,7 +1665,7 @@ public final class String
* <li>{@code dstBegin+(srcEnd-srcBegin)} is larger than
* {@code dst.length}</ul>
*/
public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin) {
public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) {
checkBoundsBeginEnd(srcBegin, srcEnd, length());
checkBoundsOffCount(dstBegin, srcEnd - srcBegin, dst.length);
if (isLatin1()) {
@ -1719,7 +1719,7 @@ public final class String
* </ul>
*/
@Deprecated(since="1.1")
public void getBytes(int srcBegin, int srcEnd, byte dst[], int dstBegin) {
public void getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin) {
checkBoundsBeginEnd(srcBegin, srcEnd, length());
Objects.requireNonNull(dst);
checkBoundsOffCount(dstBegin, srcEnd - srcBegin, dst.length);
@ -4221,7 +4221,7 @@ public final class String
* @return a {@code String} that contains the characters of the
* character array.
*/
public static String valueOf(char data[]) {
public static String valueOf(char[] data) {
return new String(data);
}
@ -4245,7 +4245,7 @@ public final class String
* {@code offset+count} is larger than
* {@code data.length}.
*/
public static String valueOf(char data[], int offset, int count) {
public static String valueOf(char[] data, int offset, int count) {
return new String(data, offset, count);
}
@ -4262,7 +4262,7 @@ public final class String
* {@code offset+count} is larger than
* {@code data.length}.
*/
public static String copyValueOf(char data[], int offset, int count) {
public static String copyValueOf(char[] data, int offset, int count) {
return new String(data, offset, count);
}
@ -4273,7 +4273,7 @@ public final class String
* @return a {@code String} that contains the characters of the
* character array.
*/
public static String copyValueOf(char data[]) {
public static String copyValueOf(char[] data) {
return new String(data);
}

View file

@ -773,7 +773,7 @@ import jdk.internal.vm.annotation.IntrinsicCandidate;
count = fields.get("count", 0);
}
synchronized void getBytes(byte dst[], int dstBegin, byte coder) {
synchronized void getBytes(byte[] dst, int dstBegin, byte coder) {
super.getBytes(dst, dstBegin, coder);
}
}

View file

@ -79,11 +79,11 @@ final class StringLatin1 {
return ret;
}
public static void getChars(byte[] value, int srcBegin, int srcEnd, char dst[], int dstBegin) {
public static void getChars(byte[] value, int srcBegin, int srcEnd, char[] dst, int dstBegin) {
inflate(value, srcBegin, dst, dstBegin, srcEnd - srcBegin);
}
public static void getBytes(byte[] value, int srcBegin, int srcEnd, byte dst[], int dstBegin) {
public static void getBytes(byte[] value, int srcBegin, int srcEnd, byte[] dst, int dstBegin) {
System.arraycopy(value, srcBegin, dst, dstBegin, srcEnd - srcBegin);
}

View file

@ -247,7 +247,7 @@ final class StringUTF16 {
}
@IntrinsicCandidate
public static void getChars(byte[] value, int srcBegin, int srcEnd, char dst[], int dstBegin) {
public static void getChars(byte[] value, int srcBegin, int srcEnd, char[] dst, int dstBegin) {
// We need a range check here because 'getChar' has no checks
if (srcBegin < srcEnd) {
checkBoundsOffCount(srcBegin, srcEnd - srcBegin, value);
@ -258,7 +258,7 @@ final class StringUTF16 {
}
/* @see java.lang.String.getBytes(int, int, byte[], int) */
public static void getBytes(byte[] value, int srcBegin, int srcEnd, byte dst[], int dstBegin) {
public static void getBytes(byte[] value, int srcBegin, int srcEnd, byte[] dst, int dstBegin) {
srcBegin <<= 1;
srcEnd <<= 1;
for (int i = srcBegin + (1 >> LO_BYTE_SHIFT); i < srcEnd; i += 2) {

View file

@ -1247,7 +1247,7 @@ public class Thread implements Runnable {
* if {@link java.lang.ThreadGroup#checkAccess} determines that
* the current thread cannot access its thread group
*/
public static int enumerate(Thread tarray[]) {
public static int enumerate(Thread[] tarray) {
return currentThread().getThreadGroup().enumerate(tarray);
}

View file

@ -399,7 +399,7 @@ public class ThreadGroup implements Thread.UncaughtExceptionHandler {
*
* @since 1.0
*/
public int enumerate(Thread list[]) {
public int enumerate(Thread[] list) {
checkAccess();
return enumerate(list, 0, true);
}
@ -437,12 +437,12 @@ public class ThreadGroup implements Thread.UncaughtExceptionHandler {
*
* @since 1.0
*/
public int enumerate(Thread list[], boolean recurse) {
public int enumerate(Thread[] list, boolean recurse) {
checkAccess();
return enumerate(list, 0, recurse);
}
private int enumerate(Thread list[], int n, boolean recurse) {
private int enumerate(Thread[] list, int n, boolean recurse) {
int ngroupsSnapshot = 0;
ThreadGroup[] groupsSnapshot = null;
synchronized (this) {
@ -533,7 +533,7 @@ public class ThreadGroup implements Thread.UncaughtExceptionHandler {
*
* @since 1.0
*/
public int enumerate(ThreadGroup list[]) {
public int enumerate(ThreadGroup[] list) {
checkAccess();
return enumerate(list, 0, true);
}
@ -571,12 +571,12 @@ public class ThreadGroup implements Thread.UncaughtExceptionHandler {
*
* @since 1.0
*/
public int enumerate(ThreadGroup list[], boolean recurse) {
public int enumerate(ThreadGroup[] list, boolean recurse) {
checkAccess();
return enumerate(list, 0, recurse);
}
private int enumerate(ThreadGroup list[], int n, boolean recurse) {
private int enumerate(ThreadGroup[] list, int n, boolean recurse) {
int ngroupsSnapshot = 0;
ThreadGroup[] groupsSnapshot = null;
synchronized (this) {