lib/ext JAR file search order

Ioi Lam ioi.lam at oracle.com
Fri Nov 15 20:37:24 UTC 2013


 From sun.misc.Launcher$ExtClassLoader:

         private static URL[] getExtURLs(File[] dirs) throws IOException {
             Vector<URL> urls = new Vector<URL>();
             for (int i = 0; i < dirs.length; i++) {
                 String[] files = dirs[i].list();
                 if (files != null) {
                     for (int j = 0; j < files.length; j++) {
                         if (!files[j].equals("meta-index")) {
                             File f = new File(dirs[i], files[j]);
                             urls.add(getFileURL(f));
                         }
                     }
                 }
             }
             URL[] ua = new URL[urls.size()];
             urls.copyInto(ua);
             return ua;
         }


the search order is completely depending on the order of files returned 
by File.list(), whose Javadoc explictly says the order is not defined:

http://docs.oracle.com/javase/6/docs/api/java/io/File.html#list()

   "There is no guarantee that the name strings in the
    resulting array will appear in any specific order;
    they are not, in particular, guaranteed to appear
    in alphabetical order."

So, what happens when the same class file exists in two JAR files in 
lib/ext?

Thanks
- Ioi



More information about the core-libs-dev mailing list