-
Bug
-
Resolution: Fixed
-
P2
-
6u2, 7, 8
-
b89
-
generic, x86
-
windows, windows_xp
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2226216 | 7u6 | Michael McMahon | P2 | Closed | Won't Fix |
OPERATING SYSTEM(S):
--------------------
Microsoft Windows XP Professional SP2
FULL JDK VERSION(S):
-------------------
java version "1.6.0_02"
Java(TM) SE Runtime Environment (build 1.6.0_02-b06)
Java HotSpot(TM) Client VM (build 1.6.0_02-b06, mixed mode)
DESCRIPTION:
------------
Steps to reproduce
------------------
Compile and run the testcase using the following command
>> javac LIR412.java
>> java LIR412
Testcase
--------
import java.io.*;
import java.net.*;
import java.util.*;
import static java.lang.System.out;
public class LIR412 {
public static void main(String args[]) throws SocketException {
Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface netint : Collections.list(nets)) {
if (netint.getName().compareTo("lo")==0) { //considering only loopback addresses
out.printf("Hardware address: %s\n", Arrays.toString(netint.getHardwareAddress()));
}
}
}
}
- Expected Result:
Hardware address: null //should be displayed
- Additional Information
Desired output is seen in Linux platform.
Test Case (with enhanced output):
---------------------------------
import java.io.*;
import java.net.*;
import java.util.*;
import static java.lang.System.out;
public class LIR412 {
public static void main(String args[]) throws SocketException {
Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface netint : Collections.list(nets)) {
displayInterfaceInformation(netint);
}
}
static void displayInterfaceInformation(NetworkInterface netint) throws
SocketException {
out.printf("Parent Info:%s\n", netint.getParent());
out.printf("Display name: %s\n", netint.getDisplayName());
out.printf("Name: %s\n", netint.getName());
Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
for (InetAddress inetAddress : Collections.list(inetAddresses)) {
out.printf("InetAddress: %s\n", inetAddress);
}
List<InterfaceAddress> ias = netint.getInterfaceAddresses();
Iterator<InterfaceAddress> iias = ias.iterator();
while (iias.hasNext()) {
InterfaceAddress ia = iias.next();
out.println(" Interface Address");
out.println(" Address: " + ia.getAddress());
out.println(" Broadcast: " + ia.getBroadcast());
System.out.println(" Prefix length: "
+ ia.getNetworkPrefixLength());
}
Enumeration<NetworkInterface> subIfs = netint.getSubInterfaces();
for (NetworkInterface subIf : Collections.list(subIfs)) {
out.printf("\tSub Interface Display name: %s\n", subIf
.getDisplayName());
out.printf("\tSub Interface Name: %s\n", subIf.getName());
}
out.printf("Up? %s\n", netint.isUp());
out.printf("Loopback? %s\n", netint.isLoopback());
out.printf("PointToPoint? %s\n", netint.isPointToPoint());
out.printf("Supports multicast? %s\n", netint.supportsMulticast());
out.printf("Virtual? %s\n", netint.isVirtual());
out.printf("Hardware address: %s\n", Arrays.toString(netint.getHardwareAddress()));
out.printf("MTU: %s\n", netint.getMTU());
out.printf("\n");
}
}
--------------------
Microsoft Windows XP Professional SP2
FULL JDK VERSION(S):
-------------------
java version "1.6.0_02"
Java(TM) SE Runtime Environment (build 1.6.0_02-b06)
Java HotSpot(TM) Client VM (build 1.6.0_02-b06, mixed mode)
DESCRIPTION:
------------
Steps to reproduce
------------------
Compile and run the testcase using the following command
>> javac LIR412.java
>> java LIR412
Testcase
--------
import java.io.*;
import java.net.*;
import java.util.*;
import static java.lang.System.out;
public class LIR412 {
public static void main(String args[]) throws SocketException {
Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface netint : Collections.list(nets)) {
if (netint.getName().compareTo("lo")==0) { //considering only loopback addresses
out.printf("Hardware address: %s\n", Arrays.toString(netint.getHardwareAddress()));
}
}
}
}
- Expected Result:
Hardware address: null //should be displayed
- Additional Information
Desired output is seen in Linux platform.
Test Case (with enhanced output):
---------------------------------
import java.io.*;
import java.net.*;
import java.util.*;
import static java.lang.System.out;
public class LIR412 {
public static void main(String args[]) throws SocketException {
Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface netint : Collections.list(nets)) {
displayInterfaceInformation(netint);
}
}
static void displayInterfaceInformation(NetworkInterface netint) throws
SocketException {
out.printf("Parent Info:%s\n", netint.getParent());
out.printf("Display name: %s\n", netint.getDisplayName());
out.printf("Name: %s\n", netint.getName());
Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
for (InetAddress inetAddress : Collections.list(inetAddresses)) {
out.printf("InetAddress: %s\n", inetAddress);
}
List<InterfaceAddress> ias = netint.getInterfaceAddresses();
Iterator<InterfaceAddress> iias = ias.iterator();
while (iias.hasNext()) {
InterfaceAddress ia = iias.next();
out.println(" Interface Address");
out.println(" Address: " + ia.getAddress());
out.println(" Broadcast: " + ia.getBroadcast());
System.out.println(" Prefix length: "
+ ia.getNetworkPrefixLength());
}
Enumeration<NetworkInterface> subIfs = netint.getSubInterfaces();
for (NetworkInterface subIf : Collections.list(subIfs)) {
out.printf("\tSub Interface Display name: %s\n", subIf
.getDisplayName());
out.printf("\tSub Interface Name: %s\n", subIf.getName());
}
out.printf("Up? %s\n", netint.isUp());
out.printf("Loopback? %s\n", netint.isLoopback());
out.printf("PointToPoint? %s\n", netint.isPointToPoint());
out.printf("Supports multicast? %s\n", netint.supportsMulticast());
out.printf("Virtual? %s\n", netint.isVirtual());
out.printf("Hardware address: %s\n", Arrays.toString(netint.getHardwareAddress()));
out.printf("MTU: %s\n", netint.getMTU());
out.printf("\n");
}
}
- backported by
-
JDK-2226216 H/W Address of Loopback Interface does not conform to doc
- Closed
- relates to
-
JDK-8058216 NetworkInterface.getHardwareAddress can return zero length byte array when run with preferIPv4Stack
- Closed