// initialize properties that can be queried
isIPv6Available = !ip6Interfaces().collect(Collectors.toList()).isEmpty();
ip6Interfaces().forEach(nif -> {
ip6Addresses(nif) // On AIX, a configuration with only local or loopback // addresses does not fully enable IPv6 operations. // E.g. IPv6 multicasting does not work. // So, don't set has_testableipv6address if we only find these.
.filter(addr -> Platform.isAix() ?
!(addr.isAnyLocalAddress() || addr.isLoopbackAddress()) : true)
.forEach(ia -> {
has_testableipv6address = true; if (ia.isLinkLocalAddress()) has_linklocaladdress = true; if (ia.isSiteLocalAddress()) has_sitelocaladdress = true;
privatestaticboolean isIPv6LinkLocal(InetAddress a) { return Inet6Address.class.isInstance(a) && a.isLinkLocalAddress();
}
/** *Returnstrueifthetwointerfacespointtothesamenetworkinterface. * *@implNote *Thismethodfirstlooksatwhetherthetwointerfacesare *{@linkplainNetworkInterface#equals(Object)equals},andifsoitreturns *true.Otherwise,itlooksatwhetherthetwointerfaceshavethesame *{@linkplainNetworkInterface#getName()name}and *{@linkplainNetworkInterface#getIndex()index},andifsoreturnstrue. *Otherwise,itreturnsfalse. * *@apiNote *Thismethodignoresdifferencesintheaddressestowhichthenetwork *interfacesarebound,tocaterforpossiblereconfigurationthatmight *havehappenedbetweenthetimeatwhicheachinterfaceconfiguration *waslookedup. * *@paramni1Anetworkinterface,maybe{@codenull} *@paramni2Anothernetworkinterface,maybe{@codenull} *@return{@codetrue}ifthetwonetworkinterfaceshavethesamename *andindex,{@codefalse}otherwise.
*/ publicstaticboolean isSameInterface(NetworkInterface ni1, NetworkInterface ni2) { if (Objects.equals(ni1, ni2)) returntrue; // Objects equals has taken care of the case where // ni1 == ni2 so either they are both non-null or only // one of them is null - in which case they can't be equal. if (ni1 == null || ni2 == null) returnfalse; if (ni1.getIndex() != ni2.getIndex()) returnfalse; return Objects.equals(ni1.getName(), ni2.getName());
}
publicstaticboolean isTestable(NetworkInterface nif) { if (Platform.isOSX()) { if (nif.getName().contains("awdl")) { returnfalse; // exclude awdl
} // filter out interfaces that only have link-local IPv6 addresses // on macOS interfaces like 'en6' fall in this category and // need to be skipped return nif.inetAddresses()
.filter(Predicate.not(NetworkConfiguration::isIPv6LinkLocal))
.findAny()
.isPresent();
}
if (Platform.isWindows()) {
String dName = nif.getDisplayName(); if (dName != null && dName.contains("Teredo")) { returnfalse;
}
} returntrue;
}
// On AIX there is a bug: // When IPv6 is enabled on the system, the JDK opens sockets as AF_INET6. // If there's an interface configured with IPv4 addresses only, it should // be able to become the network interface for a multicast socket (that // could be in both, IPv4 or IPv6 space). But both possible setsockopt // calls for either IPV6_MULTICAST_IF or IP_MULTICAST_IF return // EADDRNOTAVAIL. So we must skip such interfaces here. if (Platform.isAix() && isIPv6Available() && !hasIp6Addresses(nif)) { returnfalse;
}
if (Platform.isOSX()) { // multicasting may not work on interfaces that only // have link local addresses if (!hasNonLinkLocalAddress(nif)) { returnfalse;
}
}
if (Platform.isOSX()) { // multicasting may not work on interfaces that only // have link local addresses if (!hasNonLinkLocalAddress(nif)) { returnfalse;
}
}
List<NetworkInterface> nifs = list(getNetworkInterfaces()); for (NetworkInterface nif : nifs) { // ignore interfaces that are down if (!nif.isUp() || nif.isPointToPoint()) { continue;
}
/** Prints all the system interface information to the give stream. */
@SuppressWarnings("removal") publicstaticvoid printSystemConfiguration(PrintStream out) {
PrivilegedAction<Void> pa = () -> { try {
out.println("*** all system network interface configuration ***"); for (NetworkInterface nif : list(getNetworkInterfaces())) {
out.print(interfaceInformation(nif));
}
out.println("*** end ***"); returnnull;
} catch (IOException e) { thrownew UncheckedIOException(e);
}};
AccessController.doPrivileged(pa);
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.