ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brus, Tom" <>
Subject class loading speed can be improved in
Date Wed, 25 Apr 2007 13:18:55 GMT

We have a lot of classes that are loaded by the AntClassLoader. From
performance measurements I noticed that a lot of time was spend in
File.exists() during class loading. I checked the code and noticed that

     InputStream getResourceStream  (File file, String resourceName);

and in

     URL         getResourceURL     (File file, String resourceName);

The following check is done first:

     if (!file.exists()) {
         return null;

This seems smart, because if the file does not exist the answer is
clear. Unless of course 'exists()' is slow; which it turns out to be (on
Windows at least). A considerable improvement can be accomplished by
first checking the 'zipFiles' Hashtable: if "zipFiles.get(file)" returns
non-null we can be sure that the file exists and that it is not a
directory. Remember that most calls will be for a jar file that has
already been opened. So those expensive (compared to Hashtable.get())
tests on File can be skipped most of the time.

One of our test runs was reduced by 1/3 in runtime by a quick patch I
made (it loads thousands of classes...).

Has this issue ever been noticed/discussed?

Tom Brus

The contents of this e-mail are intended for the named addressee only. It contains information
that may be confidential. Unless you are the named addressee or an authorized designee, you
may not copy or use it, or disclose it to anyone else. If you received it in error please
notify us immediately and then destroy it.

Compuware Europe B.V. (Registration number: 33245192) is a company registered in The Netherlands
whose registered office is at  Hoogoorddreef 5, 1101 BA  Amsterdam, The Netherlands. Compuware
B.V. (Registration number: 33227492) is a company registered in the Netherlands whose registered
office is at Hoogoorddreef 5, 1101 BA  Amsterdam, The Netherlands

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message