Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@jakarta.apache.org Received: (qmail 10730 invoked by uid 500); 29 Jun 2001 03:04:43 -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 10715 invoked from network); 29 Jun 2001 03:04:41 -0000 From: "Conor MacNeill" To: Subject: RE: Request: AntClassLoader.getResource() Date: Fri, 29 Jun 2001 13:06:23 +1000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Importance: Normal In-Reply-To: X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N This has been fixed in CVS already. > -----Original Message----- > From: Herman, Dave [mailto:dherman@intrado.com] > Sent: Friday, 29 June 2001 12:48 PM > To: 'ant-dev@jakarta.apache.org' > Subject: Request: AntClassLoader.getResource() > > > Hello, > > I have a request for a new method in AntClassLoader. Here's the scenario: > I'm running some JUnit tests within a task. These test classes are > not necessarily found in the system class path, but my explicit > > element nested within the junit task tells ant where to find the > classes. As > a result, they're not loaded with the system class loader, but by the > AntClassLoader. > > These classes rely on external files, which they are trying to load via: > > getClass().getResource(String fileName) > > The getResource method in a Class object first calls the > getResource method > in its class loader to try to find the resource, and if that > fails, it then > tries the system class loader. Because AntClassLoader has not > overridden the > getResource method, it doesn't search its class path correctly, > and returns > null. Then when the class tries the system class loader, since the class's > directory is not in the system class path, it fails there as well. As a > result, I get null. > > I'm proposing the following changes: > > 1. Get rid of the following method: > private InputStream getResourceStream(File file, String > resourceName) > 2. Create these two methods: > private URL getResourceURL(File file, String resourceName) > public URL getResource(String name) > 3. Modify the following method: > public InputStream getResource(String name) > to call the getResourceURL method instead. > > I've attached a patch file (patch.txt) that can be applied to the > version I > downloaded from the web site, but I didn't know how to get into the CVS > repository to get the very latest version. So this patch needs to > be applied > to the version that's available from: > > http://jakarta.apache.org/builds/jakarta-ant/release/v1.3/src/jaka rta-ant-1. 3-src.zip In case this is totally useless, I've attached a more human-readable description of the changes I'm suggesting as well (description.txt). TIA for feedback or for the addition of the patch to the next release. Thanks, Dave Herman dherman@intrado.com