# HG changeset patch # User jjg # Date 1291054188 28800 # Node ID f432af22de2988287c9830c05f24e6bdfcdca696 # Parent a9ed6bf644fcd266ff2722c8550f445ab58eb233 7003006: add option to list directory in deterministic order Reviewed-by: mcimadamore diff -r a9ed6bf644fc -r f432af22de29 langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java --- a/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java Tue Nov 23 15:28:34 2010 -0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java Mon Nov 29 10:09:48 2010 -0800 @@ -25,6 +25,7 @@ package com.sun.tools.javac.file; +import java.util.Comparator; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileNotFoundException; @@ -110,6 +111,20 @@ protected boolean mmappedIO; protected boolean ignoreSymbolFile; + protected enum SortFiles implements Comparator { + FORWARD { + public int compare(File f1, File f2) { + return f1.getName().compareTo(f2.getName()); + } + }, + REVERSE { + public int compare(File f1, File f2) { + return -f1.getName().compareTo(f2.getName()); + } + }; + }; + protected SortFiles sortFiles; + /** * Register a Context.Factory to create a JavacFileManager. */ @@ -152,6 +167,11 @@ mmappedIO = options.isSet("mmappedIO"); ignoreSymbolFile = options.isSet("ignore.symbol.file"); + + String sf = options.get("sortFiles"); + if (sf != null) { + sortFiles = (sf.equals("reverse") ? SortFiles.REVERSE : SortFiles.FORWARD); + } } public JavaFileObject getFileForInput(String name) { @@ -293,6 +313,9 @@ if (files == null) return; + if (sortFiles != null) + Arrays.sort(files, sortFiles); + for (File f: files) { String fname = f.getName(); if (f.isDirectory()) {