Library.listClasses

Jonathan Gibbons Jonathan.Gibbons at Sun.COM
Wed Nov 11 11:48:16 PST 2009


Mark Reinhold wrote:
>> Date: Wed, 11 Nov 2009 11:09:13 -0800
>> From: jonathan.gibbons at sun.com
>>     
>
>   
>> Is Library.listClasses likely to be a light-weight or an expensive operation?
>>     
>
> Right now it's fairly expensive.  It doesn't do even the simplest kinds
> of caching; I could fix that easily if needed sooner rather than later.
>
> In the long run it'll be pretty fast, even on the first invocation, once
> we optimize the on-disk installed-module format.
>
>   
>> javac needs to list the classes on a package-by-package basis, so if
>> listClasses is cheap (or if repeated calls are cheap), then I can run
>> listClasses every time and filter the output. But if the  method is expensive,
>> then I will likely have to cache the results.
>>     
>
> Even in the long run I suspect that a listClasses(String packageName)
> method will be cheaper than the listClasses() method.
>
> I suggest that for now you don't cache this information in the compiler.
> If performance proves to be an early issue then I'll address it in the
> library code.
>
> - Mark
>   
OK.   FWIW, the compiler needs
    listClasses(String packageName, boolean includeSubpackages)

See: JavaFileManager.list: 
http://java.sun.com/javase/6/docs/api/javax/tools/JavaFileManager.html#list%28javax.tools.JavaFileManager.Location,%20java.lang.String,%20java.util.Set,%20boolean%29

-- Jon



More information about the jigsaw-dev mailing list