JDK-6587875 : InetAddress.isReachable() will not work for super users with "large" process ids
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 6u2
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_8
  • CPU: sparc
  • Submitted: 2007-08-01
  • Updated: 2011-05-18
  • Resolved: 2011-05-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6 JDK 7
5.0u14Fixed 6u4Fixed 7 b19Fixed
Any Unix-like - e.g. Linux, Solaris

Any Java 5 or Java 6


InetAddress.isReachable() will not work for super users with "large" process ids.

This is because the process id is passed as an unsigned 16-bit value in the ICMP echo request, and the echoed result compared with the original 32-bit process id.

My fix was to change the data type into which we get the process id. The original (Mike Muuss) "ping" code simply masks the process id with 0xFFFF. Either solution will work fine.


Use this class as a superuser, running in a process with a process id > 0xFFFF.

public class TestIsReachable 
    public static void main(String []args) 
        try {          
            java.net.InetAddress addr = java.net.InetAddress.getByName(args[0]);
            if(addr.isReachable(1000) == true) {
                System.out.println(args[0] + " is Reachable!\n");
            } else {
                System.out.println(args[0] + " is NOT Reachable!\n");
        } catch (java.lang.Exception e) {

EVALUATION The unix version of Inet6AddressImpl does not have this problem, but the implementation was updated to reflect the changes in Inet4AddressImpl so that how we handle pids is consistent.

EVALUATION see description.

SUGGESTED FIX ------- Inet4AddressImpl.c ------- 342c342,343 < jint pid, seq = 1; --- > jchar pid; > jint seq = 1; 347c348 < pid = getpid(); --- > pid = (jchar)getpid(); Similar change for Inet6AddressImpl also.

WORK AROUND Run as a normal user, not a superuser.