On 11/15/2013 12:37 PM, Ioi Lam wrote:
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?


AFAIK The extension mechanism [1] doesn't specify the ordering of files searched in the directories listed in
java.ext.dirs system property.

If there are two JAR files in lib/ext containing the class file of the same name, the behavior is undefined.

Mandy
[1] http://docs.oracle.com/javase/7/docs/technotes/guides/extensions/spec.html#installed

Reply via email to