* - If the signs of the arguments are the same, the results of
* {@code floorDiv} and the {@code /} operator are the same.
* For example, {@code floorDiv(4, 3) == 1} and {@code (4 / 3) == 1}.
- * - If the signs of the arguments are different, the quotient is negative and
- * {@code floorDiv} returns the integer less than or equal to the quotient
- * and the {@code /} operator returns the integer closest to zero.
+ * - If the signs of the arguments are different, {@code floorDiv}
+ * returns the largest integer less than or equal to the quotient
+ * while the {@code /} operator returns the smallest integer greater
+ * than or equal to the quotient.
+ * They differ if and only if the quotient is not an integer.
* For example, {@code floorDiv(-4, 3) == -2},
* whereas {@code (-4 / 3) == -1}.
*
@@ -1290,7 +1292,7 @@ public static int floorDiv(int x, int y) {
/**
* Returns the largest (closest to positive infinity)
* {@code long} value that is less than or equal to the algebraic quotient.
- * There is one special case, if the dividend is the
+ * There is one special case: if the dividend is
* {@linkplain Long#MIN_VALUE Long.MIN_VALUE} and the divisor is {@code -1},
* then integer overflow occurs and
* the result is equal to {@code Long.MIN_VALUE}.
@@ -1299,7 +1301,7 @@ public static int floorDiv(int x, int y) {
* (truncation). This operation instead acts under the round toward
* negative infinity (floor) rounding mode.
* The floor rounding mode gives different results from truncation
- * when the exact result is negative.
+ * when the exact result is not an integer and is negative.
*
* For examples, see {@link #floorDiv(int, int)}.
*
@@ -1319,7 +1321,7 @@ public static long floorDiv(long x, int y) {
/**
* Returns the largest (closest to positive infinity)
* {@code long} value that is less than or equal to the algebraic quotient.
- * There is one special case, if the dividend is the
+ * There is one special case: if the dividend is
* {@linkplain Long#MIN_VALUE Long.MIN_VALUE} and the divisor is {@code -1},
* then integer overflow occurs and
* the result is equal to {@code Long.MIN_VALUE}.
@@ -1328,7 +1330,7 @@ public static long floorDiv(long x, int y) {
* (truncation). This operation instead acts under the round toward
* negative infinity (floor) rounding mode.
* The floor rounding mode gives different results from truncation
- * when the exact result is negative.
+ * when the exact result is not an integer and is negative.
*
* For examples, see {@link #floorDiv(int, int)}.
*
@@ -1353,40 +1355,34 @@ public static long floorDiv(long x, long y) {
/**
* Returns the floor modulus of the {@code int} arguments.
*
- * The floor modulus is {@code x - (floorDiv(x, y) * y)},
- * has the same sign as the divisor {@code y}, and
+ * The floor modulus is {@code r = x - (floorDiv(x, y) * y)},
+ * has the same sign as the divisor {@code y} or is zero, and
* is in the range of {@code -abs(y) < r < +abs(y)}.
*
*
* The relationship between {@code floorDiv} and {@code floorMod} is such that:
*
- * - {@code floorDiv(x, y) * y + floorMod(x, y) == x}
+ *
- {@code floorDiv(x, y) * y + floorMod(x, y) == x}
*
*
- * The difference in values between {@code floorMod} and
- * the {@code %} operator is due to the difference between
- * {@code floorDiv} that returns the integer less than or equal to the quotient
- * and the {@code /} operator that returns the integer closest to zero.
+ * The difference in values between {@code floorMod} and the {@code %} operator
+ * is due to the difference between {@code floorDiv} and the {@code /}
+ * operator, as detailed in {@linkplain #floorDiv(int, int)}.
*
* Examples:
*
- * - If the signs of the arguments are the same, the results
- * of {@code floorMod} and the {@code %} operator are the same.
+ * - Regardless of the signs of the arguments, {@code floorMod}(x, y)
+ * is zero exactly when {@code x % y} is zero as well.
+ * - If neither of {@code floorMod}(x, y) or {@code x % y} is zero,
+ * their results differ exactly when the signs of the arguments differ.
*
* - {@code floorMod(+4, +3) == +1}; and {@code (+4 % +3) == +1}
* - {@code floorMod(-4, -3) == -1}; and {@code (-4 % -3) == -1}
- *
- * - If the signs of the arguments are different, the results
- * differ from the {@code %} operator.
- *
* - {@code floorMod(+4, -3) == -2}; and {@code (+4 % -3) == +1}
* - {@code floorMod(-4, +3) == +2}; and {@code (-4 % +3) == -1}
*
*
*
- *
- * If the signs of arguments are unknown and a positive modulus
- * is needed it can be computed as {@code (floorMod(x, y) + abs(y)) % abs(y)}.
*
* @param x the dividend
* @param y the divisor
@@ -1398,7 +1394,7 @@ public static long floorDiv(long x, long y) {
public static int floorMod(int x, int y) {
int mod = x % y;
// if the signs are different and modulo not zero, adjust result
- if ((mod ^ y) < 0 && mod != 0) {
+ if ((x ^ y) < 0 && mod != 0) {
mod += y;
}
return mod;
@@ -1407,14 +1403,14 @@ public static int floorMod(int x, int y) {
/**
* Returns the floor modulus of the {@code long} and {@code int} arguments.
*
- * The floor modulus is {@code x - (floorDiv(x, y) * y)},
- * has the same sign as the divisor {@code y}, and
+ * The floor modulus is {@code r = x - (floorDiv(x, y) * y)},
+ * has the same sign as the divisor {@code y} or is zero, and
* is in the range of {@code -abs(y) < r < +abs(y)}.
*
*
* The relationship between {@code floorDiv} and {@code floorMod} is such that:
*
- * - {@code floorDiv(x, y) * y + floorMod(x, y) == x}
+ *
- {@code floorDiv(x, y) * y + floorMod(x, y) == x}
*
*
* For examples, see {@link #floorMod(int, int)}.
@@ -1434,14 +1430,14 @@ public static int floorMod(long x, int y) {
/**
* Returns the floor modulus of the {@code long} arguments.
*
- * The floor modulus is {@code x - (floorDiv(x, y) * y)},
- * has the same sign as the divisor {@code y}, and
+ * The floor modulus is {@code r = x - (floorDiv(x, y) * y)},
+ * has the same sign as the divisor {@code y} or is zero, and
* is in the range of {@code -abs(y) < r < +abs(y)}.
*
*
* The relationship between {@code floorDiv} and {@code floorMod} is such that:
*
- * - {@code floorDiv(x, y) * y + floorMod(x, y) == x}
+ *
- {@code floorDiv(x, y) * y + floorMod(x, y) == x}
*
*
* For examples, see {@link #floorMod(int, int)}.
diff --git a/src/java.base/share/classes/java/lang/Runtime.java b/src/java.base/share/classes/java/lang/Runtime.java
index 3705705c92a..7948ebffb63 100644
--- a/src/java.base/share/classes/java/lang/Runtime.java
+++ b/src/java.base/share/classes/java/lang/Runtime.java
@@ -449,7 +449,7 @@ public Process exec(String command, String[] envp, File dir)
*
* @see ProcessBuilder
*/
- public Process exec(String cmdarray[]) throws IOException {
+ public Process exec(String[] cmdarray) throws IOException {
return exec(cmdarray, null, null);
}
diff --git a/src/java.base/share/classes/java/lang/StrictMath.java b/src/java.base/share/classes/java/lang/StrictMath.java
index 427fa7080ba..062e3fd3709 100644
--- a/src/java.base/share/classes/java/lang/StrictMath.java
+++ b/src/java.base/share/classes/java/lang/StrictMath.java
@@ -1051,10 +1051,10 @@ public static long unsignedMultiplyHigh(long x, long y) {
/**
* Returns the largest (closest to positive infinity)
* {@code int} value that is less than or equal to the algebraic quotient.
- * There is one special case, if the dividend is the
+ * There is one special case: if the dividend is
* {@linkplain Integer#MIN_VALUE Integer.MIN_VALUE} and the divisor is {@code -1},
* then integer overflow occurs and
- * the result is equal to the {@code Integer.MIN_VALUE}.
+ * the result is equal to {@code Integer.MIN_VALUE}.
*
* See {@link Math#floorDiv(int, int) Math.floorDiv} for examples and
* a comparison to the integer division {@code /} operator.
@@ -1075,7 +1075,7 @@ public static int floorDiv(int x, int y) {
/**
* Returns the largest (closest to positive infinity)
* {@code long} value that is less than or equal to the algebraic quotient.
- * There is one special case, if the dividend is the
+ * There is one special case: if the dividend is
* {@linkplain Long#MIN_VALUE Long.MIN_VALUE} and the divisor is {@code -1},
* then integer overflow occurs and
* the result is equal to {@code Long.MIN_VALUE}.
@@ -1099,10 +1099,10 @@ public static long floorDiv(long x, int y) {
/**
* Returns the largest (closest to positive infinity)
* {@code long} value that is less than or equal to the algebraic quotient.
- * There is one special case, if the dividend is the
+ * There is one special case: if the dividend is
* {@linkplain Long#MIN_VALUE Long.MIN_VALUE} and the divisor is {@code -1},
* then integer overflow occurs and
- * the result is equal to the {@code Long.MIN_VALUE}.
+ * the result is equal to {@code Long.MIN_VALUE}.
*
* See {@link Math#floorDiv(int, int) Math.floorDiv} for examples and
* a comparison to the integer division {@code /} operator.
@@ -1123,13 +1123,14 @@ public static long floorDiv(long x, long y) {
/**
* Returns the floor modulus of the {@code int} arguments.
*
- * The floor modulus is {@code x - (floorDiv(x, y) * y)},
- * has the same sign as the divisor {@code y}, and
+ * The floor modulus is {@code r = x - (floorDiv(x, y) * y)},
+ * has the same sign as the divisor {@code y} or is zero, and
* is in the range of {@code -abs(y) < r < +abs(y)}.
+ *
*
* The relationship between {@code floorDiv} and {@code floorMod} is such that:
*
- * - {@code floorDiv(x, y) * y + floorMod(x, y) == x}
+ *
- {@code floorDiv(x, y) * y + floorMod(x, y) == x}
*
*
* See {@link Math#floorMod(int, int) Math.floorMod} for examples and
@@ -1150,14 +1151,14 @@ public static int floorMod(int x, int y) {
/**
* Returns the floor modulus of the {@code long} and {@code int} arguments.
*
- * The floor modulus is {@code x - (floorDiv(x, y) * y)},
- * has the same sign as the divisor {@code y}, and
+ * The floor modulus is {@code r = x - (floorDiv(x, y) * y)},
+ * has the same sign as the divisor {@code y} or is zero, and
* is in the range of {@code -abs(y) < r < +abs(y)}.
*
*
* The relationship between {@code floorDiv} and {@code floorMod} is such that:
*
- * - {@code floorDiv(x, y) * y + floorMod(x, y) == x}
+ *
- {@code floorDiv(x, y) * y + floorMod(x, y) == x}
*
*
* See {@link Math#floorMod(int, int) Math.floorMod} for examples and
@@ -1178,13 +1179,14 @@ public static int floorMod(long x, int y) {
/**
* Returns the floor modulus of the {@code long} arguments.
*
- * The floor modulus is {@code x - (floorDiv(x, y) * y)},
- * has the same sign as the divisor {@code y}, and
+ * The floor modulus is {@code r = x - (floorDiv(x, y) * y)},
+ * has the same sign as the divisor {@code y} or is zero, and
* is in the range of {@code -abs(y) < r < +abs(y)}.
+ *
*
* The relationship between {@code floorDiv} and {@code floorMod} is such that:
*
- * - {@code floorDiv(x, y) * y + floorMod(x, y) == x}
+ *
- {@code floorDiv(x, y) * y + floorMod(x, y) == x}
*
*
* See {@link Math#floorMod(int, int) Math.floorMod} for examples and
diff --git a/src/java.base/share/classes/java/lang/String.java b/src/java.base/share/classes/java/lang/String.java
index d404be2e7b8..847d58e819a 100644
--- a/src/java.base/share/classes/java/lang/String.java
+++ b/src/java.base/share/classes/java/lang/String.java
@@ -272,7 +272,7 @@ public String(String original) {
* @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 String(char value[]) {
* 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 String(int[] codePoints, int offset, int count) {
* @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 String(byte ascii[], int hibyte, int offset, int count) {
* @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 @@ private static byte[] encodeUTF8_UTF16(byte[] val, boolean doReplace) {
*
* @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 String(byte bytes[], String charsetName)
*
* @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 int offsetByCodePoints(int index, int codePointOffset) {
*
- {@code dstBegin+(srcEnd-srcBegin)} is larger than
* {@code dst.length}
*/
- 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 void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin) {
*
*/
@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 static String valueOf(Object obj) {
* @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 static String valueOf(char data[]) {
* {@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 static String valueOf(char data[], int offset, int count) {
* {@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 static String copyValueOf(char data[], int offset, int count) {
* @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);
}
diff --git a/src/java.base/share/classes/java/lang/StringBuffer.java b/src/java.base/share/classes/java/lang/StringBuffer.java
index a4299192966..e2ca48fdaf6 100644
--- a/src/java.base/share/classes/java/lang/StringBuffer.java
+++ b/src/java.base/share/classes/java/lang/StringBuffer.java
@@ -773,7 +773,7 @@ private void readObject(java.io.ObjectInputStream s)
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);
}
}
diff --git a/src/java.base/share/classes/java/lang/StringLatin1.java b/src/java.base/share/classes/java/lang/StringLatin1.java
index 63e906c1dc4..875d79b6f64 100644
--- a/src/java.base/share/classes/java/lang/StringLatin1.java
+++ b/src/java.base/share/classes/java/lang/StringLatin1.java
@@ -79,11 +79,11 @@ public static byte[] inflate(byte[] value, int off, int len) {
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);
}
diff --git a/src/java.base/share/classes/java/lang/StringUTF16.java b/src/java.base/share/classes/java/lang/StringUTF16.java
index 6f3aff9e48e..29287aaa22c 100644
--- a/src/java.base/share/classes/java/lang/StringUTF16.java
+++ b/src/java.base/share/classes/java/lang/StringUTF16.java
@@ -247,7 +247,7 @@ static byte[] toBytesSupplementary(int cp) {
}
@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 @@ public static void getChars(byte[] value, int srcBegin, int srcEnd, char dst[],
}
/* @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) {
diff --git a/src/java.base/share/classes/java/lang/Thread.java b/src/java.base/share/classes/java/lang/Thread.java
index 33647db8f6b..17580d2aa84 100644
--- a/src/java.base/share/classes/java/lang/Thread.java
+++ b/src/java.base/share/classes/java/lang/Thread.java
@@ -1247,7 +1247,7 @@ public static int activeCount() {
* 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);
}
diff --git a/src/java.base/share/classes/java/lang/ThreadGroup.java b/src/java.base/share/classes/java/lang/ThreadGroup.java
index d5a97717e9d..c6e532a7444 100644
--- a/src/java.base/share/classes/java/lang/ThreadGroup.java
+++ b/src/java.base/share/classes/java/lang/ThreadGroup.java
@@ -399,7 +399,7 @@ public int activeCount() {
*
* @since 1.0
*/
- public int enumerate(Thread list[]) {
+ public int enumerate(Thread[] list) {
checkAccess();
return enumerate(list, 0, true);
}
@@ -437,12 +437,12 @@ public int enumerate(Thread list[]) {
*
* @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 int activeGroupCount() {
*
* @since 1.0
*/
- public int enumerate(ThreadGroup list[]) {
+ public int enumerate(ThreadGroup[] list) {
checkAccess();
return enumerate(list, 0, true);
}
@@ -571,12 +571,12 @@ public int enumerate(ThreadGroup list[]) {
*
* @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) {
diff --git a/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java b/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java
index 93ac7365624..a412dd753cc 100644
--- a/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java
+++ b/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2021, 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
@@ -2447,7 +2447,7 @@ public static ModuleDescriptor read(InputStream in,
* Reads the binary form of a module declaration from an input stream as a
* module descriptor. This method works exactly as specified by the 2-arg
* {@link #read(InputStream,Supplier) read} method with the exception that
- * a packager finder is not used to find additional packages when the
+ * a package finder is not used to find additional packages when the
* module descriptor read from the stream does not indicate the set of
* packages.
*
@@ -2516,7 +2516,7 @@ public static ModuleDescriptor read(ByteBuffer bb,
* Reads the binary form of a module declaration from a byte buffer as a
* module descriptor. This method works exactly as specified by the 2-arg
* {@link #read(ByteBuffer,Supplier) read} method with the exception that a
- * packager finder is not used to find additional packages when the module
+ * package finder is not used to find additional packages when the module
* descriptor encoded in the buffer does not indicate the set of packages.
*
* @param bb
diff --git a/src/java.base/share/classes/java/lang/ref/PhantomReference.java b/src/java.base/share/classes/java/lang/ref/PhantomReference.java
index 1476f517de3..e64e7aaf3f2 100644
--- a/src/java.base/share/classes/java/lang/ref/PhantomReference.java
+++ b/src/java.base/share/classes/java/lang/ref/PhantomReference.java
@@ -72,8 +72,12 @@ public T get() {
* do reference processing concurrently.
*/
@Override
+ boolean refersToImpl(T obj) {
+ return refersTo0(obj);
+ }
+
@IntrinsicCandidate
- native final boolean refersTo0(Object o);
+ private native boolean refersTo0(Object o);
/**
* Creates a new phantom reference that refers to the given object and
diff --git a/src/java.base/share/classes/java/lang/ref/Reference.java b/src/java.base/share/classes/java/lang/ref/Reference.java
index c8b0307ba37..a5c2836e188 100644
--- a/src/java.base/share/classes/java/lang/ref/Reference.java
+++ b/src/java.base/share/classes/java/lang/ref/Reference.java
@@ -363,13 +363,20 @@ public T get() {
* @since 16
*/
public final boolean refersTo(T obj) {
- return refersTo0(obj);
+ return refersToImpl(obj);
}
/* Implementation of refersTo(), overridden for phantom references.
+ * This method exists only to avoid making refersTo0() virtual. Making
+ * refersTo0() virtual has the undesirable effect of C2 often preferring
+ * to call the native implementation over the intrinsic.
*/
+ boolean refersToImpl(T obj) {
+ return refersTo0(obj);
+ }
+
@IntrinsicCandidate
- native boolean refersTo0(Object o);
+ private native boolean refersTo0(Object o);
/**
* Clears this reference object. Invoking this method will not cause this
diff --git a/src/java.base/share/classes/java/math/BigInteger.java b/src/java.base/share/classes/java/math/BigInteger.java
index 12f65d8a9d2..14f2ae6154c 100644
--- a/src/java.base/share/classes/java/math/BigInteger.java
+++ b/src/java.base/share/classes/java/math/BigInteger.java
@@ -1221,7 +1221,7 @@ private BigInteger(long val) {
* Assumes that the input array will not be modified (the returned
* BigInteger will reference the input array if feasible).
*/
- private static BigInteger valueOf(int val[]) {
+ private static BigInteger valueOf(int[] val) {
return (val[0] > 0 ? new BigInteger(val, 1) : new BigInteger(val));
}
@@ -4412,7 +4412,7 @@ public double doubleValue() {
/**
* Returns a copy of the input array stripped of any leading zero bytes.
*/
- private static int[] stripLeadingZeroInts(int val[]) {
+ private static int[] stripLeadingZeroInts(int[] val) {
int vlen = val.length;
int keep;
@@ -4426,7 +4426,7 @@ private static int[] stripLeadingZeroInts(int val[]) {
* Returns the input array stripped of any leading zero bytes.
* Since the source is trusted the copying may be skipped.
*/
- private static int[] trustedStripLeadingZeroInts(int val[]) {
+ private static int[] trustedStripLeadingZeroInts(int[] val) {
int vlen = val.length;
int keep;
@@ -4439,7 +4439,7 @@ private static int[] trustedStripLeadingZeroInts(int val[]) {
/**
* Returns a copy of the input array stripped of any leading zero bytes.
*/
- private static int[] stripLeadingZeroBytes(byte a[], int off, int len) {
+ private static int[] stripLeadingZeroBytes(byte[] a, int off, int len) {
int indexBound = off + len;
int keep;
@@ -4465,7 +4465,7 @@ private static int[] stripLeadingZeroBytes(byte a[], int off, int len) {
* Takes an array a representing a negative 2's-complement number and
* returns the minimal (no leading zero bytes) unsigned whose value is -a.
*/
- private static int[] makePositive(byte a[], int off, int len) {
+ private static int[] makePositive(byte[] a, int off, int len) {
int keep, k;
int indexBound = off + len;
@@ -4513,7 +4513,7 @@ private static int[] makePositive(byte a[], int off, int len) {
* Takes an array a representing a negative 2's-complement number and
* returns the minimal (no leading zero ints) unsigned whose value is -a.
*/
- private static int[] makePositive(int a[]) {
+ private static int[] makePositive(int[] a) {
int keep, j;
// Find first non-sign (0xffffffff) int of input
diff --git a/src/java.base/share/classes/java/net/DatagramPacket.java b/src/java.base/share/classes/java/net/DatagramPacket.java
index 7210cdb686a..55e0eae0fb6 100644
--- a/src/java.base/share/classes/java/net/DatagramPacket.java
+++ b/src/java.base/share/classes/java/net/DatagramPacket.java
@@ -80,7 +80,7 @@ class DatagramPacket {
*
* @since 1.2
*/
- public DatagramPacket(byte buf[], int offset, int length) {
+ public DatagramPacket(byte[] buf, int offset, int length) {
setData(buf, offset, length);
}
@@ -98,7 +98,7 @@ public DatagramPacket(byte buf[], int offset, int length) {
* or if the length is greater than the length of the
* packet's given buffer.
*/
- public DatagramPacket(byte buf[], int length) {
+ public DatagramPacket(byte[] buf, int length) {
this (buf, 0, length);
}
@@ -124,7 +124,7 @@ public DatagramPacket(byte buf[], int length) {
*
* @since 1.2
*/
- public DatagramPacket(byte buf[], int offset, int length,
+ public DatagramPacket(byte[] buf, int offset, int length,
InetAddress address, int port) {
setData(buf, offset, length);
setAddress(address);
@@ -152,7 +152,7 @@ public DatagramPacket(byte buf[], int offset, int length,
*
* @since 1.4
*/
- public DatagramPacket(byte buf[], int offset, int length, SocketAddress address) {
+ public DatagramPacket(byte[] buf, int offset, int length, SocketAddress address) {
setData(buf, offset, length);
setSocketAddress(address);
}
@@ -174,7 +174,7 @@ public DatagramPacket(byte buf[], int offset, int length, SocketAddress address)
*
* @see java.net.InetAddress
*/
- public DatagramPacket(byte buf[], int length,
+ public DatagramPacket(byte[] buf, int length,
InetAddress address, int port) {
this(buf, 0, length, address, port);
}
@@ -198,7 +198,7 @@ public DatagramPacket(byte buf[], int length,
*
* @since 1.4
*/
- public DatagramPacket(byte buf[], int length, SocketAddress address) {
+ public DatagramPacket(byte[] buf, int length, SocketAddress address) {
this(buf, 0, length, address);
}
diff --git a/src/java.base/share/classes/java/net/Inet4Address.java b/src/java.base/share/classes/java/net/Inet4Address.java
index 8f5b50db8b5..a504f4f398c 100644
--- a/src/java.base/share/classes/java/net/Inet4Address.java
+++ b/src/java.base/share/classes/java/net/Inet4Address.java
@@ -106,7 +106,7 @@ class Inet4Address extends InetAddress {
holder().family = IPv4;
}
- Inet4Address(String hostName, byte addr[]) {
+ Inet4Address(String hostName, byte[] addr) {
holder().hostName = hostName;
holder().family = IPv4;
if (addr != null) {
diff --git a/src/java.base/share/classes/java/net/Inet6Address.java b/src/java.base/share/classes/java/net/Inet6Address.java
index 98f0675dd7a..4943362a5fb 100644
--- a/src/java.base/share/classes/java/net/Inet6Address.java
+++ b/src/java.base/share/classes/java/net/Inet6Address.java
@@ -223,13 +223,13 @@ private Inet6AddressHolder(
*/
boolean scope_ifname_set; // false;
- void setAddr(byte addr[]) {
+ void setAddr(byte[] addr) {
if (addr.length == INADDRSZ) { // normal IPv6 address
System.arraycopy(addr, 0, ipaddress, 0, INADDRSZ);
}
}
- void init(byte addr[], int scope_id) {
+ void init(byte[] addr, int scope_id) {
setAddr(addr);
if (scope_id >= 0) {
@@ -238,7 +238,7 @@ void init(byte addr[], int scope_id) {
}
}
- void init(byte addr[], NetworkInterface nif)
+ void init(byte[] addr, NetworkInterface nif)
throws UnknownHostException
{
setAddr(addr);
@@ -377,27 +377,27 @@ boolean isMCOrgLocal() {
/* checking of value for scope_id should be done by caller
* scope_id must be >= 0, or -1 to indicate not being set
*/
- Inet6Address(String hostName, byte addr[], int scope_id) {
+ Inet6Address(String hostName, byte[] addr, int scope_id) {
holder.init(hostName, IPv6);
holder6 = new Inet6AddressHolder();
holder6.init(addr, scope_id);
}
- Inet6Address(String hostName, byte addr[]) {
+ Inet6Address(String hostName, byte[] addr) {
holder6 = new Inet6AddressHolder();
try {
initif (hostName, addr, null);
} catch (UnknownHostException e) {} /* cant happen if ifname is null */
}
- Inet6Address (String hostName, byte addr[], NetworkInterface nif)
+ Inet6Address (String hostName, byte[] addr, NetworkInterface nif)
throws UnknownHostException
{
holder6 = new Inet6AddressHolder();
initif (hostName, addr, nif);
}
- Inet6Address (String hostName, byte addr[], String ifname)
+ Inet6Address (String hostName, byte[] addr, String ifname)
throws UnknownHostException
{
holder6 = new Inet6AddressHolder();
@@ -474,7 +474,7 @@ public static Inet6Address getByAddress(String host, byte[] addr,
throw new UnknownHostException("addr is of illegal length");
}
- private void initstr(String hostName, byte addr[], String ifname)
+ private void initstr(String hostName, byte[] addr, String ifname)
throws UnknownHostException
{
try {
@@ -488,7 +488,7 @@ private void initstr(String hostName, byte addr[], String ifname)
}
}
- private void initif(String hostName, byte addr[], NetworkInterface nif)
+ private void initif(String hostName, byte[] addr, NetworkInterface nif)
throws UnknownHostException
{
int family = -1;
diff --git a/src/java.base/share/classes/java/net/Socket.java b/src/java.base/share/classes/java/net/Socket.java
index 967d64ef63b..8788ea4fe86 100644
--- a/src/java.base/share/classes/java/net/Socket.java
+++ b/src/java.base/share/classes/java/net/Socket.java
@@ -962,7 +962,7 @@ public int read() throws IOException {
return (n > 0) ? (a[0] & 0xff) : -1;
}
@Override
- 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);
}
@Override
@@ -1031,7 +1031,7 @@ public void write(int b) throws IOException {
write(a, 0, 1);
}
@Override
- public void write(byte b[], int off, int len) throws IOException {
+ public void write(byte[] b, int off, int len) throws IOException {
out.write(b, off, len);
}
diff --git a/src/java.base/share/classes/java/net/URLConnection.java b/src/java.base/share/classes/java/net/URLConnection.java
index c00fe946978..d2d74f155a9 100644
--- a/src/java.base/share/classes/java/net/URLConnection.java
+++ b/src/java.base/share/classes/java/net/URLConnection.java
@@ -1818,7 +1818,7 @@ else if (c[3] == 0x00 && c[1] == 0x61 && c[0] == 0x56 &&
* Returns -1, If EOF is reached before len bytes are read, returns 0
* otherwise
*/
- private static int readBytes(int c[], int len, InputStream is)
+ private static int readBytes(int[] c, int len, InputStream is)
throws IOException {
byte buf[] = new byte[len];
diff --git a/src/java.base/share/classes/java/net/URLStreamHandler.java b/src/java.base/share/classes/java/net/URLStreamHandler.java
index 6b30d3cb43a..ba7627401a2 100644
--- a/src/java.base/share/classes/java/net/URLStreamHandler.java
+++ b/src/java.base/share/classes/java/net/URLStreamHandler.java
@@ -26,13 +26,8 @@
package java.net;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.File;
-import java.io.OutputStream;
-import java.util.Hashtable;
import java.util.Objects;
import sun.net.util.IPAddressUtil;
-import sun.net.www.ParseUtil;
/**
* The abstract class {@code URLStreamHandler} is the common
@@ -158,13 +153,12 @@ protected void parseURL(URL u, String spec, int start, int limit) {
queryOnly = queryStart == start;
if ((queryStart != -1) && (queryStart < limit)) {
query = spec.substring(queryStart+1, limit);
- if (limit > queryStart)
- limit = queryStart;
+ limit = queryStart;
spec = spec.substring(0, queryStart);
}
}
- int i = 0;
+ int i;
// Parse the authority part if any
boolean isUNCName = (start <= limit - 4) &&
(spec.charAt(start) == '/') &&
@@ -249,7 +243,7 @@ protected void parseURL(URL u, String spec, int start, int limit) {
start = i;
// If the authority is defined then the path is defined by the
// spec only; See RFC 2396 Section 5.2.4.
- if (authority != null && !authority.isEmpty())
+ if (!authority.isEmpty())
path = "";
}
@@ -259,26 +253,27 @@ protected void parseURL(URL u, String spec, int start, int limit) {
// Parse the file path if any
if (start < limit) {
+ String specStr = spec.substring(start, limit);
if (spec.charAt(start) == '/') {
- path = spec.substring(start, limit);
+ path = specStr;
} else if (path != null && !path.isEmpty()) {
isRelPath = true;
int ind = path.lastIndexOf('/');
- String separator = "";
- if (ind == -1 && authority != null)
- separator = "/";
- path = path.substring(0, ind + 1) + separator +
- spec.substring(start, limit);
-
+ if (ind == -1 && authority != null) {
+ path = "/".concat(specStr);
+ } else {
+ path = path.substring(0, ind + 1).concat(specStr);
+ }
} else {
- path = spec.substring(start, limit);
- path = (authority != null) ? "/" + path : path;
+ path = (authority != null) ? "/".concat(specStr) : specStr;
}
} else if (queryOnly && path != null) {
int ind = path.lastIndexOf('/');
- if (ind < 0)
- ind = 0;
- path = path.substring(0, ind) + "/";
+ if (ind < 0) {
+ path = "/";
+ } else {
+ path = path.substring(0, ind + 1);
+ }
}
if (path == null)
path = "";
@@ -299,7 +294,7 @@ protected void parseURL(URL u, String spec, int start, int limit) {
*/
if (i > 0 && (limit = path.lastIndexOf('/', i - 1)) >= 0 &&
(path.indexOf("/../", limit) != 0)) {
- path = path.substring(0, limit) + path.substring(i + 3);
+ path = path.substring(0, limit).concat(path.substring(i + 3));
i = 0;
} else {
i = i + 3;
diff --git a/src/java.base/share/classes/java/security/Security.java b/src/java.base/share/classes/java/security/Security.java
index ff2bc942c03..e93c5e6af93 100644
--- a/src/java.base/share/classes/java/security/Security.java
+++ b/src/java.base/share/classes/java/security/Security.java
@@ -653,14 +653,7 @@ public static Provider[] getProviders(Map