X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0FCB03A4B4D for ; Fri, 21 Jan 2005 15:24:14 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 27495-03 for ; Fri, 21 Jan 2005 15:24:04 +0000 (GMT) Received: from mx1.redhat.com (mx1.redhat.com [66.187.233.31]) by svr1.postgresql.org (Postfix) with ESMTP id BB12F3A4B58 for ; Fri, 21 Jan 2005 15:22:14 +0000 (GMT) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j0LFMFa5013010 for ; Fri, 21 Jan 2005 10:22:15 -0500 Received: from mail.boston.redhat.com (mail.boston.redhat.com [172.16.76.12]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j0LFMEO07073 for ; Fri, 21 Jan 2005 10:22:15 -0500 Received: from localhost.localdomain (sebastian-int.corp.redhat.com [172.16.52.221]) by mail.boston.redhat.com (8.12.8/8.12.8) with ESMTP id j0LFMEp5016994 for ; Fri, 21 Jan 2005 10:22:14 -0500 From: Vadim Nasardinov Organization: Red Hat / Westford To: pgsql-jdbc@postgresql.org Subject: Re: context classloader Date: Fri, 21 Jan 2005 10:22:50 -0500 User-Agent: KMail/1.7 References: <200501190957.26908@vadim.nasardinov> <41EEC8E1.1010007@opencloud.com> In-Reply-To: <41EEC8E1.1010007@opencloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200501211022.50196@vadim.nasardinov> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200501/205 X-Sequence-Number: 12085 On Wednesday 19 January 2005 15:53, Oliver Jowett wrote: > Firstly, your statement is not true. getClass().getClassLoader() > will always return the classloader that was used to load the driver > class, which *is* predictable. That part is predictable, yes. What's not predictable is which *particular* classloader this will be. > You can always, for example, put driverconfig.properties in the path > of the same classloader that loads the driver Not always, you can't. > In contrast, if you're relying on the CCL, you have essentially no > guarantees about where it will search. It could be a completely > unrelated CL that can't even see the driver jar! Why is that so terrible? > Secondly, I think you missed my point. It is the *timing* of > initialization that I am concerned about. Timing of class > initialization is hard to predict; how do you make sure that the CCL > is correctly set when this happens? I think I understood your point the first time around. My counterpoint is, the current getClass().getClassLoader() approach is in a very similar boat. If one can put org/postgresql/driverconfig.properties on the same classpath as the driver, then, yes, they're all set. (Except for the bootstrap classloader case.) If they can't do that, then they're essentially in the same boat. How does one make sure that the classloader that loads org.postgresql.Driver is also the one that can find their driverconfig.properties? > How do you document this so that users don't get confused? As the first step, documenting the existence of driverconfig.properties would be nice. Other than http://archives.postgresql.org/pgsql-jdbc/2004-10/thrd2.php#00023 is it mentioned anywhere else? Does anyone actually use this? > It seems unreasonable to require someone who just wants to use the > JDBC driver to have to understand the mechanics of class > initialization and guard against accidentally causing initialization > before they're ready! It's an argument I wholeheartedly agree with. I'd just like to point out that it also applies to the current situation. > It could do that (it does that if the system classloader is null) > but it seems less useful -- why can the driver suddenly no longer > load defaults if it ends up in the bootstrap classpath? I keep forgetting to ask. How do you put the driver in the bootstrap classpath? The only way that I know of is to use one of the following flags under Sun's JRE: -Xbootclasspath -Xbootclasspath/a -Xbootclasspath/p I was under the impression that using these is very uncommon. Thanks for taking the time to answer my questions. Vadim