Return-Path: X-Original-To: apmail-ant-user-archive@www.apache.org Delivered-To: apmail-ant-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9AA481856F for ; Mon, 15 Jun 2015 03:51:53 +0000 (UTC) Received: (qmail 84886 invoked by uid 500); 15 Jun 2015 03:51:53 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 84821 invoked by uid 500); 15 Jun 2015 03:51:53 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 84810 invoked by uid 99); 15 Jun 2015 03:51:53 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Jun 2015 03:51:53 +0000 Received: from samaflost.de (v35516.1blu.de [178.254.33.213]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id E9F0A1A0260 for ; Mon, 15 Jun 2015 03:51:52 +0000 (UTC) Received: from localhost (localhost.localdomain [127.0.0.1]) by samaflost.de (Postfix) with ESMTP id 44C6E588ED6B for ; Mon, 15 Jun 2015 05:51:49 +0200 (CEST) Received: from samaflost.de ([127.0.0.1]) by localhost (v35516.1blu.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lKF0EUyGuIi0 for ; Mon, 15 Jun 2015 05:51:17 +0200 (CEST) Received: by samaflost.de (Postfix, from userid 1000) id 3F81F588A529; Mon, 15 Jun 2015 05:51:17 +0200 (CEST) From: Stefan Bodewig To: user@ant.apache.org Subject: Re: WELCOME to user@ant.apache.org References: <1434070318.3124.ezmlm@ant.apache.org> <87bngi3bpp.fsf@v35516.1blu.de> <87381uw738.fsf@v35516.1blu.de> <87fv5udtvw.fsf@v35516.1blu.de> <87bngidrti.fsf@v35516.1blu.de> Date: Mon, 15 Jun 2015 05:51:17 +0200 In-Reply-To: (Christopher BROWN's message of "Sun, 14 Jun 2015 21:27:15 +0200") Message-ID: <871thdpr2i.fsf@v35516.1blu.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain On 2015-06-14, Christopher BROWN wrote: > Since Java SE 7, URLClassLoader defines a "close()" method which may be > useful in the specific case mentioned: > http://docs.oracle.com/javase/7/docs/api/java/net/URLClassLoader.html#close() This won't help if the file in question is on the system classloader or the classloader is going to be used later. > As for the more general case of Windows locking files from Java, as I > understand it, it's because the underlying file descriptor use to read from > or write to files is only release when the associated stream is garbage > collected (the logic is in the "finalize()" method). In my own code, I > have a utility "delete(File)" method that tries to delete the file, and if > it fails (on a Windows system) will loop with 10 millisecond sleep > intervals, on the second and last iterations attempting System.gc() to > force finalization, and it is seems to be a robust workaround in practice. Ant has similar code. In 1.7.0 it was restricted to specific cases like the Delete task, nowadays it is a helper method (tryHardToDelete in FileUtils) that has been factored out and is used whenever a task wants to delete a file. Unfortunately it doesn't help for all cases (like files on the classloader) and that's when the deleteOnExit work around we've added comes into play. Stefan --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org