ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conor MacNeill" <co...@cortexebusiness.com.au>
Subject RE: Request: AntClassLoader.getResource()
Date Fri, 29 Jun 2001 03:06:23 GMT
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 <junit> task. These test classes are
> not necessarily found in the system class path, but my explicit
> <classpath>
> 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



Mime
View raw message