I've discovered that InetAddress.getLocalHost() returns different IP addresses on one of our machines with default options and -Djava.net.preferIPv4Stack=true. After some insvestigation, it occured that machine was reconfigured and had IP address changed in Network Settings. At the same time, it still had old IP address in C:\Windows\system32\drivers\etc\hosts.
To summarize:
With -Djava.net.preferIPv4Stack=true, it returns correct IP address (from network settings).
With -Djava.net.preferIPv4Stack=false, it returns IP address from hosts file (from hosts file).
It appears that new code uses name resolver to obtain local host address while old one doesn't.
To summarize:
With -Djava.net.preferIPv4Stack=true, it returns correct IP address (from network settings).
With -Djava.net.preferIPv4Stack=false, it returns IP address from hosts file (from hosts file).
It appears that new code uses name resolver to obtain local host address while old one doesn't.