From b0ee7a8624c42ca34d21e28bc23f208199a8eb4b Mon Sep 17 00:00:00 2001 From: Julia Boes Date: Wed, 3 Feb 2021 14:15:00 +0000 Subject: [PATCH] 8241995: Clarify InetSocketAddress::toString specification Reviewed-by: michaelm, chegar --- .../classes/java/net/InetSocketAddress.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/java.base/share/classes/java/net/InetSocketAddress.java b/src/java.base/share/classes/java/net/InetSocketAddress.java index 7eb0273448a..56635cbe929 100644 --- a/src/java.base/share/classes/java/net/InetSocketAddress.java +++ b/src/java.base/share/classes/java/net/InetSocketAddress.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -373,11 +373,18 @@ public final boolean isUnresolved() { /** * Constructs a string representation of this InetSocketAddress. - * This String is constructed by calling toString() on the InetAddress - * and concatenating the port number (with a colon). If the address - * is an IPv6 address, the IPv6 literal is enclosed in square brackets. + * This string is constructed by calling {@link InetAddress#toString()} + * on the InetAddress and concatenating the port number (with a colon). + *

+ * If the address is an IPv6 address, the IPv6 literal is enclosed in + * square brackets, for example: {@code "localhost/[0:0:0:0:0:0:0:1]:80"}. * If the address is {@linkplain #isUnresolved() unresolved}, - * {@code } is displayed in place of the address literal. + * {@code } is displayed in place of the address literal, for + * example {@code "foo/:80"}. + *

+ * To retrieve a string representation of the hostname or the address, use + * {@link #getHostString()}, rather than parsing the string returned by this + * {@link #toString()} method. * * @return a string representation of this object. */