Skip to content

8356395: Spec needs to be clarified for InterfaceAddress.getBroadcast() method #25095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/java.base/share/classes/java/net/InterfaceAddress.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public InetAddress getAddress() {
* <p>
* Only IPv4 networks have broadcast address therefore, in the case
* of an IPv6 network, {@code null} will be returned.
* <p>
* Certain IPv4 addresses, such as the loopback address, do not support
* broadcasting and will also result in {@code null} being returned.
Comment on lines +66 to +67
Copy link
Member

@dfuch dfuch May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Certain IPv4 addresses, such as the loopback address, do not support
* broadcasting and will also result in {@code null} being returned.
* Certain network interfaces, such as the loopback interface, do not support
* broadcasting and will also return {@code null}.

Maybe the class level API documentation should also be updated something like:

 * This class represents a Network Interface address. In short it's an
 * IP address, a subnet mask as well as a broadcast address when the address is
 * IPv4 and the interface supports broadcasting.
 * An IP address and a network prefix length in the case
 * of IPv6 address.

It would be good to have @Michael-Mc-Mahon approve the wording.

*
* @return the {@code InetAddress} representing the broadcast
* address or {@code null} if there is no broadcast address.
Expand Down