Skip to content

Commit

Permalink
Update some comments / docs about JDK 7.
Browse files Browse the repository at this point in the history
RELNOTES=n/a
PiperOrigin-RevId: 654907100
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Jul 22, 2024
1 parent 3dce9a2 commit e74da92
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -400,19 +400,13 @@ private <T extends Iterator<E>> void internalExecuteAndCompare(
@SuppressWarnings("unchecked")
E targetReturnValueFromNext = (E) targetReturnValue;
/*
* We have an Iterator<E> and want to cast it to
* MultiExceptionListIterator. Because we're inside an
* AbstractIteratorTester<E>, that's implicitly a cast to
* AbstractIteratorTester<E>.MultiExceptionListIterator. The runtime
* won't be able to verify the AbstractIteratorTester<E> part, so it's
* an unchecked cast. We know, however, that the only possible value for
* the type parameter is <E>, since otherwise the
* MultiExceptionListIterator wouldn't be an Iterator<E>. The cast is
* safe, even though javac can't tell.
*
* Sun bug 6665356 is an additional complication. Until OpenJDK 7, javac
* doesn't recognize this kind of cast as unchecked cast. Neither does
* Eclipse 3.4. Right now, this suppression is mostly unnecessary.
* We have an Iterator<E> and want to cast it to MultiExceptionListIterator. Because we're
* inside an AbstractIteratorTester<E>, that's implicitly a cast to
* AbstractIteratorTester<E>.MultiExceptionListIterator. The runtime won't be able to verify
* the AbstractIteratorTester<E> part, so it's an unchecked cast. We know, however, that the
* only possible value for the type parameter is <E>, since otherwise the
* MultiExceptionListIterator wouldn't be an Iterator<E>. The cast is safe, even though
* javac can't tell.
*/
@SuppressWarnings("unchecked")
MultiExceptionListIterator multiExceptionListIterator =
Expand Down
2 changes: 1 addition & 1 deletion android/guava/src/com/google/common/net/HostAndPort.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public static HostAndPort fromString(String hostPortString) {
int port = NO_PORT;
if (!Strings.isNullOrEmpty(portString)) {
// Try to parse the whole port string as a number.
// JDK7 accepts leading plus signs. We don't want to.
// Java accepts leading plus signs. We don't want to.
checkArgument(
!portString.startsWith("+") && CharMatcher.ascii().matchesAllOf(portString),
"Unparseable port number: %s",
Expand Down
8 changes: 4 additions & 4 deletions android/guava/src/com/google/common/primitives/Ints.java
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,8 @@ int[] toIntArray() {
* throwing an exception if parsing fails. Additionally, this method only accepts ASCII digits,
* and returns {@code null} if non-ASCII digits are present in the string.
*
* <p>Note that strings prefixed with ASCII {@code '+'} are rejected, even under JDK 7, despite
* the change to {@link Integer#parseInt(String)} for that version.
* <p>Note that strings prefixed with ASCII {@code '+'} are rejected, even though {@link
* Integer#parseInt(String)} accepts them.
*
* @param string the string representation of an integer value
* @return the integer value represented by {@code string}, or {@code null} if {@code string} has
Expand All @@ -794,8 +794,8 @@ public static Integer tryParse(String string) {
* throwing an exception if parsing fails. Additionally, this method only accepts ASCII digits,
* and returns {@code null} if non-ASCII digits are present in the string.
*
* <p>Note that strings prefixed with ASCII {@code '+'} are rejected, even under JDK 7, despite
* the change to {@link Integer#parseInt(String, int)} for that version.
* <p>Note that strings prefixed with ASCII {@code '+'} are rejected, even though {@link
* Integer#parseInt(String)} accepts them.
*
* @param string the string representation of an integer value
* @param radix the radix to use when parsing
Expand Down
8 changes: 4 additions & 4 deletions android/guava/src/com/google/common/primitives/Longs.java
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ static int digit(char c) {
* an exception if parsing fails. Additionally, this method only accepts ASCII digits, and returns
* {@code null} if non-ASCII digits are present in the string.
*
* <p>Note that strings prefixed with ASCII {@code '+'} are rejected, even under JDK 7, despite
* the change to {@link Long#parseLong(String)} for that version.
* <p>Note that strings prefixed with ASCII {@code '+'} are rejected, even though {@link
* Integer#parseInt(String)} accepts them.
*
* @param string the string representation of a long value
* @return the long value represented by {@code string}, or {@code null} if {@code string} has a
Expand All @@ -382,8 +382,8 @@ public static Long tryParse(String string) {
* throwing an exception if parsing fails. Additionally, this method only accepts ASCII digits,
* and returns {@code null} if non-ASCII digits are present in the string.
*
* <p>Note that strings prefixed with ASCII {@code '+'} are rejected, even under JDK 7, despite
* the change to {@link Long#parseLong(String, int)} for that version.
* <p>Note that strings prefixed with ASCII {@code '+'} are rejected, even though {@link
* Integer#parseInt(String)} accepts them.
*
* @param string the string representation of a long value
* @param radix the radix to use when parsing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,19 +416,13 @@ private <T extends Iterator<E>> void internalExecuteAndCompare(
@SuppressWarnings("unchecked")
E targetReturnValueFromNext = (E) targetReturnValue;
/*
* We have an Iterator<E> and want to cast it to
* MultiExceptionListIterator. Because we're inside an
* AbstractIteratorTester<E>, that's implicitly a cast to
* AbstractIteratorTester<E>.MultiExceptionListIterator. The runtime
* won't be able to verify the AbstractIteratorTester<E> part, so it's
* an unchecked cast. We know, however, that the only possible value for
* the type parameter is <E>, since otherwise the
* MultiExceptionListIterator wouldn't be an Iterator<E>. The cast is
* safe, even though javac can't tell.
*
* Sun bug 6665356 is an additional complication. Until OpenJDK 7, javac
* doesn't recognize this kind of cast as unchecked cast. Neither does
* Eclipse 3.4. Right now, this suppression is mostly unnecessary.
* We have an Iterator<E> and want to cast it to MultiExceptionListIterator. Because we're
* inside an AbstractIteratorTester<E>, that's implicitly a cast to
* AbstractIteratorTester<E>.MultiExceptionListIterator. The runtime won't be able to verify
* the AbstractIteratorTester<E> part, so it's an unchecked cast. We know, however, that the
* only possible value for the type parameter is <E>, since otherwise the
* MultiExceptionListIterator wouldn't be an Iterator<E>. The cast is safe, even though
* javac can't tell.
*/
@SuppressWarnings("unchecked")
MultiExceptionListIterator multiExceptionListIterator =
Expand Down
2 changes: 1 addition & 1 deletion guava/src/com/google/common/net/HostAndPort.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public static HostAndPort fromString(String hostPortString) {
int port = NO_PORT;
if (!Strings.isNullOrEmpty(portString)) {
// Try to parse the whole port string as a number.
// JDK7 accepts leading plus signs. We don't want to.
// Java accepts leading plus signs. We don't want to.
checkArgument(
!portString.startsWith("+") && CharMatcher.ascii().matchesAllOf(portString),
"Unparseable port number: %s",
Expand Down
8 changes: 4 additions & 4 deletions guava/src/com/google/common/primitives/Ints.java
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,8 @@ int[] toIntArray() {
* throwing an exception if parsing fails. Additionally, this method only accepts ASCII digits,
* and returns {@code null} if non-ASCII digits are present in the string.
*
* <p>Note that strings prefixed with ASCII {@code '+'} are rejected, even under JDK 7, despite
* the change to {@link Integer#parseInt(String)} for that version.
* <p>Note that strings prefixed with ASCII {@code '+'} are rejected, even though {@link
* Integer#parseInt(String)} accepts them.
*
* @param string the string representation of an integer value
* @return the integer value represented by {@code string}, or {@code null} if {@code string} has
Expand All @@ -801,8 +801,8 @@ public static Integer tryParse(String string) {
* throwing an exception if parsing fails. Additionally, this method only accepts ASCII digits,
* and returns {@code null} if non-ASCII digits are present in the string.
*
* <p>Note that strings prefixed with ASCII {@code '+'} are rejected, even under JDK 7, despite
* the change to {@link Integer#parseInt(String, int)} for that version.
* <p>Note that strings prefixed with ASCII {@code '+'} are rejected, even though {@link
* Integer#parseInt(String)} accepts them.
*
* @param string the string representation of an integer value
* @param radix the radix to use when parsing
Expand Down
8 changes: 4 additions & 4 deletions guava/src/com/google/common/primitives/Longs.java
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ static int digit(char c) {
* an exception if parsing fails. Additionally, this method only accepts ASCII digits, and returns
* {@code null} if non-ASCII digits are present in the string.
*
* <p>Note that strings prefixed with ASCII {@code '+'} are rejected, even under JDK 7, despite
* the change to {@link Long#parseLong(String)} for that version.
* <p>Note that strings prefixed with ASCII {@code '+'} are rejected, even though {@link
* Integer#parseInt(String)} accepts them.
*
* @param string the string representation of a long value
* @return the long value represented by {@code string}, or {@code null} if {@code string} has a
Expand All @@ -384,8 +384,8 @@ public static Long tryParse(String string) {
* throwing an exception if parsing fails. Additionally, this method only accepts ASCII digits,
* and returns {@code null} if non-ASCII digits are present in the string.
*
* <p>Note that strings prefixed with ASCII {@code '+'} are rejected, even under JDK 7, despite
* the change to {@link Long#parseLong(String, int)} for that version.
* <p>Note that strings prefixed with ASCII {@code '+'} are rejected, even though {@link
* Integer#parseInt(String)} accepts them.
*
* @param string the string representation of a long value
* @param radix the radix to use when parsing
Expand Down

0 comments on commit e74da92

Please sign in to comment.