diff -r 5b5d965900b8 -r 68cf07910d74 test/tools/javadoc/T4994049/T4994049.java --- a/test/tools/javadoc/T4994049/T4994049.java Mon Oct 11 10:19:57 2010 -0700 +++ b/test/tools/javadoc/T4994049/T4994049.java Tue Oct 12 12:55:38 2010 -0700 @@ -30,7 +30,7 @@ */ import com.sun.javadoc.*; -import java.io.File; +import java.io.*; import static com.sun.tools.javadoc.Main.execute; public class T4994049 extends Doclet { @@ -52,12 +52,47 @@ return false; } - public static void main(String... args) { + public static void main(String... args) throws Exception { + File testSrc = new File(System.getProperty("test.src")); + File tmpSrc = new File("tmpSrc"); + initTabs(testSrc, tmpSrc); + for (String file : args) { - File source = new File(System.getProperty("test.src", "."), file); - if (execute("javadoc", "T4994049", T4994049.class.getClassLoader(), - new String[]{source.getPath()} ) != 0) - throw new Error(); + File source = new File(tmpSrc, file); + int rc = execute("javadoc", "T4994049", T4994049.class.getClassLoader(), + new String[]{ source.getPath() } ); + if (rc != 0) + throw new Error("Unexpected return code from javadoc: " + rc); + } + } + + static void initTabs(File from, File to) throws IOException { + for (File f: from.listFiles()) { + File t = new File(to, f.getName()); + if (f.isDirectory()) { + initTabs(f, t); + } else if (f.getName().endsWith(".java")) { + write(t, read(f).replace("\\t", "\t")); + } + } + } + + static String read(File f) throws IOException { + StringBuilder sb = new StringBuilder(); + try (BufferedReader in = new BufferedReader(new FileReader(f))) { + String line; + while ((line = in.readLine()) != null) { + sb.append(line); + sb.append("\n"); + } + } + return sb.toString(); + } + + static void write(File f, String s) throws IOException { + f.getParentFile().mkdirs(); + try (Writer out = new FileWriter(f)) { + out.write(s); } }