With the following code:
try {
System.out.println(new Date());
InetAddress hostName = InetAddress.getLocalHost();
System.out.println(new Date());
} cat
This problem appears on MacOS Sierra using Java8, updates equals or bigger than 60 (jdk1.8.0_60.jdk, jdk1.8.0_77.jdk, etc).
The solution can be found here: https://github.com/thoeni/inetTester.
This is the content of my /etc/hosts file:
127.0.0.1 localhost mac.local
::1 localhost mac.local
In my case, mac is my computer name.