-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Chuck,

On 5/22/13 1:42 PM, Caldarale, Charles R wrote:
>> From: Christopher Schultz [mailto:ch...@christopherschultz.net] 
>> Subject: Re: Follow-up: Possible false-postive with
>> JreMemoryLeakPreventionListener and Tomcat's JDBC Pool and
>> OracleTimeoutPollingThread
> 
>> I suspect that the DriverManager will always be loaded by the
>> boot ClassLoader, since the default-dispatch for ClassLoaders is
>> to chekc the parent first, then check "yourself". The
>> DriverManager is at the top-level (well, there is primordial, but
>> that doesn't really count) ClassLoader so you'll always get
>> that.
> 
> Terminology alert: you're confusing the boot class loader with the 
> system class loader, and have erroneously labeled the actual boot 
> class loader as "primordial".  Generally speaking, the boot class 
> loader is responsible for extracting JRE classes from rt.jar (and 
> others that come with the JRE), while the system class loader
> deals with those specified by the java.class.path setting
> (CLASSPATH for those still stuck on environment variables).

Thanks for the pedantry: I was in fact ignoring the difference between
the system and boot ClassLoaders. However, the primordial ClassLoader
does in fact exist, and does in fact load classes, and is not called
the "boot" ClassLoader.

Oracle describes the primordial ClassLoader as that which loads pretty
much everything in the java.* package space. Oracle also describes the
"system" ClassLoader as the "delegation root ancestor of all class
loaders".[1]

In practice, the primordial class loader is identified by a "null"
reference (and is this difficult to inspect) and the system class
loader is represented by an "ExtClassLoader". On top of that is an
AppClassLoader. I'll have to play around with some classes loaded via
endorsed directories to see if I can nail-down how to get a Class with
the "ExtClassLoader" as its class loader instead of AppClassLoader.

DriverManager's ClassLoader is in fact null, the primordial class loader.

You can test it yourself, and discover the ClassLoader hierarchy in
play with a simple program:

public class ClassLoaderTest
{
    public static void main(String[] args)
    {
        printClassLoaders(ClassLoaderTest.class);
        printClassLoaders(Thread.class);
        printClassLoaders(Object.class);
        printClassLoaders(java.sql.DriverManager.class);
    }
    public static void printClassLoaders(Class cls)
    {
        ClassLoader cl = cls.getClassLoader();

        System.out.println("*** ClassLoaders for "
                           + cls.getName() + " ***");
        while(null != cl)
        {
            System.out.println("ClassLoader["
                               + cls.getName() + "]: " + cl);
            cl = cl.getParent();
        }
        System.out.println("ClassLoader["
                           + cls.getName() + "]: " + cl);
    }
}

Run under two different JVMs on my laptop, I get:

$ java -showversion ClassLoaderTest
java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)

*** ClassLoaders for ClassLoaderTest ***
ClassLoader[ClassLoaderTest]: sun.misc.Launcher$AppClassLoader@63644028
ClassLoader[ClassLoaderTest]: sun.misc.Launcher$ExtClassLoader@4ab03512
ClassLoader[ClassLoaderTest]: null
*** ClassLoaders for java.lang.Thread ***
ClassLoader[java.lang.Thread]: null
*** ClassLoaders for java.lang.Object ***
ClassLoader[java.lang.Object]: null
*** ClassLoaders for java.sql.DriverManager ***
ClassLoader[java.sql.DriverManager]: null

$ java ClassLoaderTest
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06-451-11M4406)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01-451, mixed mode)

*** ClassLoaders for ClassLoaderTest ***
ClassLoader[ClassLoaderTest]: sun.misc.Launcher$AppClassLoader@a6eb38a
ClassLoader[ClassLoaderTest]: sun.misc.Launcher$ExtClassLoader@69cd2e5f
ClassLoader[ClassLoaderTest]: null
*** ClassLoaders for java.lang.Thread ***
ClassLoader[java.lang.Thread]: null
*** ClassLoaders for java.lang.Object ***
ClassLoader[java.lang.Object]: null
*** ClassLoaders for java.sql.DriverManager ***
ClassLoader[java.sql.DriverManager]: null

$ java -showversion ClassLoaderTest
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06-451-11M4406)
Java HotSpot(TM) Client VM (build 20.45-b01-451, mixed mode)

*** ClassLoaders for ClassLoaderTest ***
ClassLoader[ClassLoaderTest]: sun.misc.Launcher$AppClassLoader@cf2c80
ClassLoader[ClassLoaderTest]: sun.misc.Launcher$ExtClassLoader@1729854
ClassLoader[ClassLoaderTest]: null
*** ClassLoaders for java.lang.Thread ***
ClassLoader[java.lang.Thread]: null
*** ClassLoaders for java.lang.Object ***
ClassLoader[java.lang.Object]: null
*** ClassLoaders for java.sql.DriverManager ***
ClassLoader[java.sql.DriverManager]: null

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIbBAEBCAAGBQJRnipcAAoJEBzwKT+lPKRYVHIP90ZDie3fKOS+pM9rjMah95/6
M4ZLz/QjPTNylZDvXCR6uNHygv2ubSEwzTAoE77QwCO0IVxwV0wsPfKLKE2mULQc
ZKD1pRJSWBWeHJhzIRlVSlOIPkXdu3jc9+AZV94VCn7pwsXLCKZnlGU2GKKf91cD
yrA2OMwkwC98b6XvVYE5dPQuPJibN2S5A0Iy9f7eLOgFaJh9Cl6ldMFxRaZ206k4
b+huVAkOjZMvjZJ1ugDw3MJluED7/opvZiTtuyCq1PyvDB0pR3xsjvzUOR/MoCxR
BmLH4SrfwVPt+gBOJZOqeMdKfR8xXohJfEov39ABgYpegl0DsaeHO58m612GQ1IZ
/AIc3f8bgNlgjKCLp2+QeCw0SUqPAmOdRUDUOCJc82Z0flUmc4Z0wGn+Q4TsOL7d
Ntu7w1X9ASO9De54GFcpnjPoyQqj6adf6fsOgQprOuV9fDTo2a/Gc48WnGpBzSJl
v6WjZSspEPcNGFg/r0S5N6dNY4hOZYdnhSb6F3z1EwD1dnpOyIV3LrePytn5iGac
nKyqJfm1kZUATR+KPPjUJEQEG2yoo9H3pHbtJAP8bgU1uJQiAMmilsin+Vt1avWW
tv7SXjA4WkhyajKItm84QTbFHwSX+xaKcgqyoh/r83i9Nlqyzh6Ry3QSw7gNB3lB
BY9Lqxc4HOXqr8lyIQQ=
=S6U6
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to