From: Stefan B. <ste...@be...> - 2008-11-23 06:54:06
|
Hi, thanks again for your explanations. I agree that explicit imports are best. However, you also asked about opinions, so here's mine. Oti wrote: > What is the classpath if you start java -jar ? > Empty. > Then you could say: look at the manifest inside the .jar. > That is true, but many times it is also empty, e.g. in jython-complete.jar! > Another example: if you start JBoss, almost everything is hot deployed later. > > (As a side note, all the above illustrates that scanning the classpath > is by no means a guarantee that we pick every possible package - to > not speak of OSGI environments). So what you say is that a) scanning the classpath is costly, and b) doing it once may not return all packages. I consider a failing import a really rare thing that does not happen in a working deployment, so what about scanning the entire classpath and rebuilding the package cache whenever an import fails? That would give you speed in the normal case where the cache contains the package in question, and adaptation in the case where the classpath changes over time. It may not work in all cases, especially if special class loaders are doing stuff behind our back, but it should work in many more cases than it currently does. (Although I see the advantage of failing early at development time rather than behaving different at runtime). Stefan |