[jdk21u-dev] RFR: 8338748: [17u, 21u] Test Disconnect.java compile error: cannot find symbol after JDK-8299813
Severin Gehwolf
sgehwolf at openjdk.org
Mon Sep 9 10:00:10 UTC 2024
On Wed, 21 Aug 2024 15:48:49 GMT, SendaoYan <syan at openjdk.org> wrote:
> Hi all,
> Test `java/nio/channels/DatagramChannel/Disconnect.java` compile error: `cannot find symbol InetAddress.ofLiteral` after JDK-8299813. There is no `InetAddress.ofLiteral` API in jdk21u and jdk17u, the `InetAddress.ofLiteral` API was added by [JDK-8272215](https://bugs.openjdk.org/browse/JDK-8272215) in jdk22.
> Change `InetAddress.ofLiteral`to `Inet6Address.getByName`, change has been verified, test fix only, no risk.
The point here is, AFAIK, to do parsing without the reverse look-up. The [javadoc](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/net/InetAddress.html#getByName(java.lang.String)) states for `getByName()`:
The host name can either be a machine name, such as "www.example.com", or a textual representation of its IP address. If a literal IP address is supplied, only the validity of the address format is checked.
So the replacement seems OK in principle. Did you run the test?
test/jdk/java/nio/channels/DatagramChannel/Disconnect.java line 55:
> 53: // test with IPv4 only
> 54: try (DatagramChannel dc = DatagramChannel.open(StandardProtocolFamily.INET)) {
> 55: InetAddress lo4 = Inet4Address.getByName("127.0.0.1");
`Inet4Address` doesn't override `getByName()` we should use `InetAddress` instead.
Suggestion:
InetAddress lo4 = InetAddress.getByName("127.0.0.1");
test/jdk/java/nio/channels/DatagramChannel/Disconnect.java line 65:
> 63: // test with IPv6 only
> 64: try (DatagramChannel dc = DatagramChannel.open(StandardProtocolFamily.INET6)) {
> 65: InetAddress lo6 = Inet6Address.getByName("::1");
Suggestion:
InetAddress lo6 = InetAddress.getByName("::1");
-------------
PR Review: https://git.openjdk.org/jdk21u-dev/pull/939#pullrequestreview-2289433763
PR Review Comment: https://git.openjdk.org/jdk21u-dev/pull/939#discussion_r1749955684
PR Review Comment: https://git.openjdk.org/jdk21u-dev/pull/939#discussion_r1749956255
More information about the jdk-updates-dev
mailing list