Why the object created by ClassLoader do not have chance to garbage collect itself
<p>I am referring to this code example, which is being reported in <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6254531" rel="nofollow">http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6254531</a></p>

<pre><code>import java.net.URL;

class Loader {
    public static void main(String[] args) throws Exception {
        for (;;) {
            System.gc();
            System.out.print(".");
            System.out.flush();
            new java.net.URLClassLoader(
                new URL[] { new java.io.File(".").toURL() },
                ClassLoader.getSystemClassLoader().getParent()
            ).loadClass("Weakling").newInstance();
        }
    }
}
public class Weakling {
    private static ThreadLocal&lt;Object&gt; local;
    private static Weakling staticRef;
    private Object var = new byte[1000*1000];
    public Weakling() {
        local = new ThreadLocal&lt;Object&gt;();
        local.set(this);
        staticRef = this;
    }

    @Override
    protected void finalize() {
        System.out.print("F");
        System.out.flush();
    }
}
</code></pre>

<p>The finalize will never be called. However, if I change the</p>

<pre><code>            new java.net.URLClassLoader(
                new URL[] { new java.io.File(".").toURL() },
                ClassLoader.getSystemClassLoader().getParent()
            ).loadClass("Weakling").newInstance();
</code></pre>

<p>to</p>

<pre><code>new Weakling();
</code></pre>

<p>It works very well and no leaking detected.</p>

<p>Can anyone explain why the object created by ClassLoader do not have chance to garbage collect itself?</p>
