<div dir="ltr">So, I did the experiment I suggested:<div><br></div><div>jar tf $jdk/jre/lib/rt.jar | sed -n 's/\.class$//p' | sed 's/\//./g' | while read class; do j java LoadClass $class; done<br></div><div>
<br></div><div>and got 148 UnsatisfiedLinkErrors (a.k.a. "a rich crop of bugs")</div><div><br></div><div>Here are the ones Alan himself may want to fix:</div><div><br></div><div><div>Exception in thread "main" java.lang.UnsatisfiedLinkError: java.net.SocketInputStream.init()V</div>
<div><span class="" style="white-space:pre"> </span>at java.net.SocketInputStream.init(Native Method)</div><div><span class="" style="white-space:pre"> </span>at java.net.SocketInputStream.<clinit>(SocketInputStream.java:47)</div>
<div><span class="" style="white-space:pre"> </span>at java.lang.Class.forName0(Native Method)</div><div><span class="" style="white-space:pre"> </span>at java.lang.Class.forName(Class.java:270)</div><div><span class="" style="white-space:pre"> </span>at LoadClass.main(LoadClass.java:4)</div>
<div>Exception in thread "main" java.lang.UnsatisfiedLinkError: java.net.SocketOutputStream.init()V</div><div><span class="" style="white-space:pre"> </span>at java.net.SocketOutputStream.init(Native Method)</div>
<div><span class="" style="white-space:pre"> </span>at java.net.SocketOutputStream.<clinit>(SocketOutputStream.java:46)</div><div><span class="" style="white-space:pre"> </span>at java.lang.Class.forName0(Native Method)</div>
<div><span class="" style="white-space:pre"> </span>at java.lang.Class.forName(Class.java:270)</div><div><span class="" style="white-space:pre"> </span>at LoadClass.main(LoadClass.java:4)</div></div><div><div>Exception in thread "main" java.lang.UnsatisfiedLinkError: sun.nio.ch.EPoll.eventSize()I</div>
<div><span class="" style="white-space:pre"> </span>at sun.nio.ch.EPoll.eventSize(Native Method)</div><div><span class="" style="white-space:pre"> </span>at sun.nio.ch.EPoll.<clinit>(EPoll.java:53)</div><div><span class="" style="white-space:pre"> </span>at java.lang.Class.forName0(Native Method)</div>
<div><span class="" style="white-space:pre"> </span>at java.lang.Class.forName(Class.java:270)</div><div><span class="" style="white-space:pre"> </span>at LoadClass.main(LoadClass.java:4)</div><div>Exception in thread "main" java.lang.UnsatisfiedLinkError: sun.nio.ch.EPollArrayWrapper.sizeofEPollEvent()I</div>
<div><span class="" style="white-space:pre"> </span>at sun.nio.ch.EPollArrayWrapper.sizeofEPollEvent(Native Method)</div><div><span class="" style="white-space:pre"> </span>at sun.nio.ch.EPollArrayWrapper.<clinit>(EPollArrayWrapper.java:67)</div>
<div><span class="" style="white-space:pre"> </span>at java.lang.Class.forName0(Native Method)</div><div><span class="" style="white-space:pre"> </span>at java.lang.Class.forName(Class.java:270)</div><div><span class="" style="white-space:pre"> </span>at LoadClass.main(LoadClass.java:4)</div>
<div>Exception in thread "main" java.lang.UnsatisfiedLinkError: sun.nio.ch.FileKey.initIDs()V</div><div><span class="" style="white-space:pre"> </span>at sun.nio.ch.FileKey.initIDs(Native Method)</div><div><span class="" style="white-space:pre"> </span>at sun.nio.ch.FileKey.<clinit>(FileKey.java:73)</div>
<div><span class="" style="white-space:pre"> </span>at java.lang.Class.forName0(Native Method)</div><div><span class="" style="white-space:pre"> </span>at java.lang.Class.forName(Class.java:270)</div><div><span class="" style="white-space:pre"> </span>at LoadClass.main(LoadClass.java:4)</div>
<div>Exception in thread "main" java.lang.UnsatisfiedLinkError: sun.nio.ch.KQueue.keventSize()I</div><div><span class="" style="white-space:pre"> </span>at sun.nio.ch.KQueue.keventSize(Native Method)</div><div><span class="" style="white-space:pre"> </span>at sun.nio.ch.KQueue.<clinit>(KQueue.java:50)</div>
<div><span class="" style="white-space:pre"> </span>at java.lang.Class.forName0(Native Method)</div><div><span class="" style="white-space:pre"> </span>at java.lang.Class.forName(Class.java:270)</div><div><span class="" style="white-space:pre"> </span>at LoadClass.main(LoadClass.java:4)</div>
<div>Exception in thread "main" java.lang.UnsatisfiedLinkError: sun.nio.ch.Net.isExclusiveBindAvailable()I</div><div><span class="" style="white-space:pre"> </span>at sun.nio.ch.Net.isExclusiveBindAvailable(Native Method)</div>
<div><span class="" style="white-space:pre"> </span>at <a href="http://sun.nio.ch.Net">sun.nio.ch.Net</a>.<clinit>(Net.java:58)</div><div><span class="" style="white-space:pre"> </span>at java.lang.Class.forName0(Native Method)</div>
<div><span class="" style="white-space:pre"> </span>at java.lang.Class.forName(Class.java:270)</div><div><span class="" style="white-space:pre"> </span>at LoadClass.main(LoadClass.java:4)</div><div>Exception in thread "main" java.lang.UnsatisfiedLinkError: sun.nio.ch.SctpNet.init()V</div>
<div><span class="" style="white-space:pre"> </span>at sun.nio.ch.SctpNet.init(Native Method)</div><div><span class="" style="white-space:pre"> </span>at sun.nio.ch.SctpNet.<clinit>(SctpNet.java:368)</div><div><span class="" style="white-space:pre"> </span>at java.lang.Class.forName0(Native Method)</div>
<div><span class="" style="white-space:pre"> </span>at java.lang.Class.forName(Class.java:270)</div><div><span class="" style="white-space:pre"> </span>at LoadClass.main(LoadClass.java:4)</div><div>Exception in thread "main" java.lang.UnsatisfiedLinkError: sun.nio.ch.Net.isExclusiveBindAvailable()I</div>
<div><span class="" style="white-space:pre"> </span>at sun.nio.ch.Net.isExclusiveBindAvailable(Native Method)</div><div><span class="" style="white-space:pre"> </span>at <a href="http://sun.nio.ch.Net">sun.nio.ch.Net</a>.<clinit>(Net.java:58)</div>
<div><span class="" style="white-space:pre"> </span>at sun.nio.ch.SocketOptionRegistry$LazyInitialization.options(SocketOptionRegistry.java:61)</div><div><span class="" style="white-space:pre"> </span>at sun.nio.ch.SocketOptionRegistry$LazyInitialization.<clinit>(SocketOptionRegistry.java:57)</div>
<div><span class="" style="white-space:pre"> </span>at java.lang.Class.forName0(Native Method)</div><div><span class="" style="white-space:pre"> </span>at java.lang.Class.forName(Class.java:270)</div><div><span class="" style="white-space:pre"> </span>at LoadClass.main(LoadClass.java:4)</div>
</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Sep 19, 2013 at 6:21 PM, Martin Buchholz <span dir="ltr"><<a href="mailto:martinrb@google.com" target="_blank">martinrb@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div class="im">On Thu, Sep 19, 2013 at 5:30 PM, Alan Bateman <span dir="ltr"><<a href="mailto:Alan.Bateman@oracle.com" target="_blank">Alan.Bateman@oracle.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Martin,<br>
<br>
I'm curious how you ran into this.</blockquote><div><br></div></div><div>I'm not aware of any way to trigger this using just public APIs.</div><div>We sometimes fiddle with the internals of the JDK networking implementation. </div>
<div>So it's possible that no one will run into this in a "strictly conforming" java program.</div><div class="im"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I agree this should be fixed, it's just not immediately obviously which APIs would cause Net to be loaded before other classes that would cause the native library to be loaded. I'm not aware of any bug reports so I'm curious if you have the original stack trace (not from the Class.forName).<span><font color="#888888"><br>
</font></span></blockquote></div></div></div></div>
</blockquote></div><br></div>