How can I work around this JRE bug in getNetworkPrefixLength()? <p>There appears to be a known bug in the JRE implementation:</p> <ul> <li><a href="http://bugs.java.com/view_bug.do?bug_id=6707289" rel="nofollow">http://bugs.java.com/view_bug.do?bug_id=6707289</a></li> <li><a href="https://bugs.openjdk.java.net/browse/JDK-7107883" rel="nofollow">https://bugs.openjdk.java.net/browse/JDK-7107883</a></li> </ul> <p>But how can I fix it without updating the JRE/JDK? I need to get broadcast address, and use <code>getBroadcast()</code> for this, but it returns 0.0.0.0 (because <code>getNetworkPrefixLength()</code> returns -1, although the real network mask is 24).</p>