NetReflectionUtil { public static InetAddress anyLocalAddress(){ try { Method m = InetAddress.class.getDeclaredMethod("anyLocalAddress"); m.setAccessible(true); return (InetAddress) m.invoke(null); } catch (Exception e) { logger.error("Failed to use reflection on InetAddress.anyLocalAddress(): "+e.getMessage(),e); } return null; }  static InetAddress anyLocalAddress();  }
@Test public void test_anyLocalAddress(){ Assert.assertNotNull(NetReflectionUtil.anyLocalAddress()); }