From ant-dev-return-13666-apmail-jakarta-ant-dev-archive=jakarta.apache.org@jakarta.apache.org Thu May 10 13:24:35 2001 Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@jakarta.apache.org Received: (qmail 51179 invoked by uid 500); 10 May 2001 13:24:25 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: ant-dev@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 51122 invoked from network); 10 May 2001 13:24:20 -0000 Message-ID: <00ff01c0d955$09ce5aa0$c1e4223f@cognetnt> From: "Conor MacNeill" To: References: <3.0.6.32.20010510220843.01e101b0@mail.alphalink.com.au> Subject: Re: class static initialization and classloaders Date: Thu, 10 May 2001 23:27:28 +1000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N Pete, ----- Original Message ----- From: "Peter Donald" > > It is by jdks design that this is done - I have run into it heaps in past > (Avalon/Phoenix was historically littered with hacks to force static > resolution and initialization). > > One of the reasons I wanted resolution of all classes at loading time - it > removes this problem. The only way I know how to do it is to use > > Class.forName( "com.biz.Foo", true, null ); > or > Class.forName( "com.biz.Foo", true, myClassLoader ); > > Which was -1ed in the vote IIRC ... ;) > Resolution is not the issue, I believe. I experimented by setting the AntClassLoader to always resolve regardles of whether it was requested by the caller. It made no difference - the static initialisers were not run. BTW, why did you say class resolution when you really meant class initialization? > * force resolution of classes on loading to identify classloader > issues early. (At least in global classloader). I do not believe resolveClass() and the initialize parameter of Class.forName achieve the same thing (linking v initialization). Besides the latter is JDK1.2+ so generally not an option for Ant 1.x. Conor