Wed, 15 Oct 2008 08:07:59 -0700
6748541: javadoc should be reusable
Reviewed-by: bpatel
1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java Tue Oct 14 17:05:48 2008 +0100 1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java Wed Oct 15 08:07:59 2008 -0700 1.3 @@ -51,7 +51,7 @@ 1.4 */ 1.5 public class ConfigurationImpl extends Configuration { 1.6 1.7 - private static final ConfigurationImpl instance = new ConfigurationImpl(); 1.8 + private static ConfigurationImpl instance = new ConfigurationImpl(); 1.9 1.10 /** 1.11 * The build date. Note: For now, we will use 1.12 @@ -189,6 +189,15 @@ 1.13 "com.sun.tools.doclets.formats.html.resources.standard"); 1.14 } 1.15 1.16 + /** 1.17 + * Reset to a fresh new ConfigurationImpl, to allow multiple invocations 1.18 + * of javadoc within a single VM. It would be better not to be using 1.19 + * static fields at all, but .... (sigh). 1.20 + */ 1.21 + public static void reset() { 1.22 + instance = new ConfigurationImpl(); 1.23 + } 1.24 + 1.25 public static ConfigurationImpl getInstance() { 1.26 return instance; 1.27 } 1.28 @@ -475,7 +484,7 @@ 1.29 * {@inheritDoc} 1.30 */ 1.31 public WriterFactory getWriterFactory() { 1.32 - return WriterFactoryImpl.getInstance(); 1.33 + return new WriterFactoryImpl(this); 1.34 } 1.35 1.36 /**
2.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java Tue Oct 14 17:05:48 2008 +0100 2.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java Wed Oct 15 08:07:59 2008 -0700 2.3 @@ -41,12 +41,14 @@ 2.4 * 2.5 */ 2.6 public class HtmlDoclet extends AbstractDoclet { 2.7 + public HtmlDoclet() { 2.8 + configuration = (ConfigurationImpl) configuration(); 2.9 + } 2.10 2.11 /** 2.12 * The global configuration information for this run. 2.13 */ 2.14 - public ConfigurationImpl configuration = 2.15 - (ConfigurationImpl) configuration(); 2.16 + public ConfigurationImpl configuration; 2.17 2.18 /** 2.19 * The "start" method as required by Javadoc. 2.20 @@ -56,8 +58,12 @@ 2.21 * @return true if the doclet ran without encountering any errors. 2.22 */ 2.23 public static boolean start(RootDoc root) { 2.24 - HtmlDoclet doclet = new HtmlDoclet(); 2.25 - return doclet.start(doclet, root); 2.26 + try { 2.27 + HtmlDoclet doclet = new HtmlDoclet(); 2.28 + return doclet.start(doclet, root); 2.29 + } finally { 2.30 + ConfigurationImpl.reset(); 2.31 + } 2.32 } 2.33 2.34 /**
3.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java Tue Oct 14 17:05:48 2008 +0100 3.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java Wed Oct 15 08:07:59 2008 -0700 3.3 @@ -37,27 +37,13 @@ 3.4 */ 3.5 public class WriterFactoryImpl implements WriterFactory { 3.6 3.7 - private static WriterFactoryImpl instance; 3.8 - 3.9 private ConfigurationImpl configuration; 3.10 3.11 - private WriterFactoryImpl(ConfigurationImpl configuration) { 3.12 + public WriterFactoryImpl(ConfigurationImpl configuration) { 3.13 this.configuration = configuration; 3.14 } 3.15 3.16 /** 3.17 - * Return an instance of this factory. 3.18 - * 3.19 - * @return an instance of this factory. 3.20 - */ 3.21 - public static WriterFactoryImpl getInstance() { 3.22 - if (instance == null) { 3.23 - instance = new WriterFactoryImpl(ConfigurationImpl.getInstance()); 3.24 - } 3.25 - return instance; 3.26 - } 3.27 - 3.28 - /** 3.29 * {@inheritDoc} 3.30 */ 3.31 public ConstantsSummaryWriter getConstantsSummaryWriter() throws Exception {
4.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java Tue Oct 14 17:05:48 2008 +0100 4.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java Wed Oct 15 08:07:59 2008 -0700 4.3 @@ -45,7 +45,7 @@ 4.4 /** 4.5 * The global configuration information for this run. 4.6 */ 4.7 - public Configuration configuration = configuration(); 4.8 + public Configuration configuration; 4.9 4.10 /** 4.11 * The only doclet that may use this toolkit is {@value} 4.12 @@ -74,6 +74,7 @@ 4.13 * @return true if the doclet executed without error. False otherwise. 4.14 */ 4.15 public boolean start(AbstractDoclet doclet, RootDoc root) { 4.16 + configuration = configuration(); 4.17 configuration.root = root; 4.18 if (! isValidDoclet(doclet)) { 4.19 return false;
5.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java Tue Oct 14 17:05:48 2008 +0100 5.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java Wed Oct 15 08:07:59 2008 -0700 5.3 @@ -113,9 +113,9 @@ 5.4 public boolean keywords = false; 5.5 5.6 /** 5.7 - * The meta tag keywords sole-instance. 5.8 + * The meta tag keywords instance. 5.9 */ 5.10 - public final MetaKeywords metakeywords = MetaKeywords.getInstance(this); 5.11 + public final MetaKeywords metakeywords = new MetaKeywords(this); 5.12 5.13 /** 5.14 * The list of doc-file subdirectories to exclude 5.15 @@ -211,12 +211,12 @@ 5.16 public boolean notimestamp= false; 5.17 5.18 /** 5.19 - * The package grouping sole-instance. 5.20 + * The package grouping instance. 5.21 */ 5.22 - public final Group group = Group.getInstance(this); 5.23 + public final Group group = new Group(this); 5.24 5.25 /** 5.26 - * The tracker of external package links (sole-instance). 5.27 + * The tracker of external package links. 5.28 */ 5.29 public final Extern extern = new Extern(this); 5.30
6.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Group.java Tue Oct 14 17:05:48 2008 +0100 6.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Group.java Wed Oct 15 08:07:59 2008 -0700 6.3 @@ -56,8 +56,6 @@ 6.4 */ 6.5 public class Group { 6.6 6.7 - private static Group instance; 6.8 - 6.9 /** 6.10 * Map of regular expressions with the corresponding group name. 6.11 */ 6.12 @@ -96,17 +94,10 @@ 6.13 } 6.14 } 6.15 6.16 - private Group(Configuration configuration) { 6.17 + public Group(Configuration configuration) { 6.18 this.configuration = configuration; 6.19 } 6.20 6.21 - public static Group getInstance(Configuration configuration) { 6.22 - if (instance == null) { 6.23 - instance = new Group(configuration); 6.24 - } 6.25 - return instance; 6.26 - } 6.27 - 6.28 /** 6.29 * Depending upon the format of the package name provided in the "-group" 6.30 * option, generate two separate maps. There will be a map for mapping
7.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MetaKeywords.java Tue Oct 14 17:05:48 2008 +0100 7.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MetaKeywords.java Wed Oct 15 08:07:59 2008 -0700 7.3 @@ -43,8 +43,6 @@ 7.4 */ 7.5 public class MetaKeywords { 7.6 7.7 - private static MetaKeywords instance = null; 7.8 - 7.9 /** 7.10 * The global configuration information for this run. 7.11 */ 7.12 @@ -53,23 +51,11 @@ 7.13 /** 7.14 * Constructor 7.15 */ 7.16 - private MetaKeywords(Configuration configuration) { 7.17 + public MetaKeywords(Configuration configuration) { 7.18 this.configuration = configuration; 7.19 } 7.20 7.21 /** 7.22 - * Return an instance of MetaKeywords. This class is a singleton. 7.23 - * 7.24 - * @param configuration the current configuration of the doclet. 7.25 - */ 7.26 - public static MetaKeywords getInstance(Configuration configuration) { 7.27 - if (instance == null) { 7.28 - instance = new MetaKeywords(configuration); 7.29 - } 7.30 - return instance; 7.31 - } 7.32 - 7.33 - /** 7.34 * Returns an array of strings where each element 7.35 * is a class, method or field name. This array is 7.36 * used to create one meta keyword tag for each element.
8.1 --- a/test/com/sun/javadoc/AuthorDD/AuthorDD.java Tue Oct 14 17:05:48 2008 +0100 8.2 +++ b/test/com/sun/javadoc/AuthorDD/AuthorDD.java Wed Oct 15 08:07:59 2008 -0700 8.3 @@ -72,7 +72,8 @@ 8.4 8.5 /** Run javadoc */ 8.6 public static void runJavadoc(String[] javadocArgs) { 8.7 - if (com.sun.tools.javadoc.Main.execute(javadocArgs) != 0) { 8.8 + if (com.sun.tools.javadoc.Main.execute(AuthorDD.class.getClassLoader(), 8.9 + javadocArgs) != 0) { 8.10 throw new Error("Javadoc failed to execute"); 8.11 } 8.12 }
9.1 --- a/test/com/sun/javadoc/lib/JavadocTester.java Tue Oct 14 17:05:48 2008 +0100 9.2 +++ b/test/com/sun/javadoc/lib/JavadocTester.java Wed Oct 15 08:07:59 2008 -0700 9.3 @@ -197,6 +197,7 @@ 9.4 new PrintWriter(warnings, true), 9.5 new PrintWriter(notices, true), 9.6 docletClass, 9.7 + getClass().getClassLoader(), 9.8 args); 9.9 System.setOut(prev); 9.10 standardOut = new StringBuffer(stdout.toString());
10.1 --- a/test/tools/javadoc/BooleanConst.java Tue Oct 14 17:05:48 2008 +0100 10.2 +++ b/test/tools/javadoc/BooleanConst.java Wed Oct 15 08:07:59 2008 -0700 10.3 @@ -37,7 +37,7 @@ 10.4 public static void main(String[] args) { 10.5 // run javadoc on package p 10.6 if (com.sun.tools.javadoc.Main. 10.7 - execute("javadoc", "BooleanConst", 10.8 + execute("javadoc", "BooleanConst", BooleanConst.class.getClassLoader(), 10.9 new String[] {System.getProperty("test.src", ".") + java.io.File.separatorChar + "BooleanConst.java"}) != 0) 10.10 throw new Error(); 10.11 }
11.1 --- a/test/tools/javadoc/BreakIteratorWarning.java Tue Oct 14 17:05:48 2008 +0100 11.2 +++ b/test/tools/javadoc/BreakIteratorWarning.java Wed Oct 15 08:07:59 2008 -0700 11.3 @@ -41,6 +41,7 @@ 11.4 if (com.sun.tools.javadoc.Main.execute( 11.5 "javadoc", 11.6 "BreakIteratorWarning", 11.7 + BreakIteratorWarning.class.getClassLoader(), 11.8 new String[] {"-Xwerror", thisFile}) != 0) 11.9 throw new Error("Javadoc encountered warnings or errors."); 11.10 }
12.1 --- a/test/tools/javadoc/FlagsTooEarly.java Tue Oct 14 17:05:48 2008 +0100 12.2 +++ b/test/tools/javadoc/FlagsTooEarly.java Wed Oct 15 08:07:59 2008 -0700 12.3 @@ -40,6 +40,7 @@ 12.4 if (com.sun.tools.javadoc.Main.execute( 12.5 "javadoc", 12.6 "FlagsTooEarly", 12.7 + FlagsTooEarly.class.getClassLoader(), 12.8 new String[] {"-Xwerror", thisFile}) != 0) 12.9 throw new Error("Javadoc encountered warnings or errors."); 12.10 }
13.1 --- a/test/tools/javadoc/InlineTagsWithBraces.java Tue Oct 14 17:05:48 2008 +0100 13.2 +++ b/test/tools/javadoc/InlineTagsWithBraces.java Wed Oct 15 08:07:59 2008 -0700 13.3 @@ -60,6 +60,7 @@ 13.4 if (com.sun.tools.javadoc.Main.execute( 13.5 "javadoc", 13.6 "InlineTagsWithBraces", 13.7 + InlineTagsWithBraces.class.getClassLoader(), 13.8 new String[] {"-Xwerror", thisFile}) != 0) 13.9 throw new Error("Javadoc encountered warnings or errors."); 13.10 }
14.1 --- a/test/tools/javadoc/LangVers.java Tue Oct 14 17:05:48 2008 +0100 14.2 +++ b/test/tools/javadoc/LangVers.java Wed Oct 15 08:07:59 2008 -0700 14.3 @@ -43,6 +43,7 @@ 14.4 if (com.sun.tools.javadoc.Main.execute( 14.5 "javadoc", 14.6 "LangVers", 14.7 + LangVers.class.getClassLoader(), 14.8 new String[] {"-source", "1.5", thisFile}) != 0) 14.9 throw new Error("Javadoc encountered warnings or errors."); 14.10 }
15.1 --- a/test/tools/javadoc/MethodLinks.java Tue Oct 14 17:05:48 2008 +0100 15.2 +++ b/test/tools/javadoc/MethodLinks.java Wed Oct 15 08:07:59 2008 -0700 15.3 @@ -36,7 +36,7 @@ 15.4 { 15.5 public static void main(String[] args) { 15.6 if (com.sun.tools.javadoc.Main. 15.7 - execute("javadoc", "MethodLinks", 15.8 + execute("javadoc", "MethodLinks", MethodLinks.class.getClassLoader(), 15.9 new String[] {System.getProperty("test.src", ".") + 15.10 java.io.File.separatorChar + "MethodLinks.java"} 15.11 ) != 0)
16.1 --- a/test/tools/javadoc/NoStar.java Tue Oct 14 17:05:48 2008 +0100 16.2 +++ b/test/tools/javadoc/NoStar.java Wed Oct 15 08:07:59 2008 -0700 16.3 @@ -44,7 +44,7 @@ 16.4 { 16.5 public static void main(String[] args) { 16.6 if (com.sun.tools.javadoc.Main. 16.7 - execute("javadoc", "NoStar", 16.8 + execute("javadoc", "NoStar", NoStar.class.getClassLoader(), 16.9 new String[] {System.getProperty("test.src", ".") + java.io.File.separatorChar + "NoStar.java"}) != 0) 16.10 throw new Error(); 16.11 }
17.1 --- a/test/tools/javadoc/T4994049/T4994049.java Tue Oct 14 17:05:48 2008 +0100 17.2 +++ b/test/tools/javadoc/T4994049/T4994049.java Wed Oct 15 08:07:59 2008 -0700 17.3 @@ -55,7 +55,8 @@ 17.4 public static void main(String... args) { 17.5 for (String file : args) { 17.6 File source = new File(System.getProperty("test.src", "."), file); 17.7 - if (execute("javadoc", "T4994049", new String[]{source.getPath()} ) != 0) 17.8 + if (execute("javadoc", "T4994049", T4994049.class.getClassLoader(), 17.9 + new String[]{source.getPath()} ) != 0) 17.10 throw new Error(); 17.11 } 17.12 }
18.1 --- a/test/tools/javadoc/XWerror.java Tue Oct 14 17:05:48 2008 +0100 18.2 +++ b/test/tools/javadoc/XWerror.java Wed Oct 15 08:07:59 2008 -0700 18.3 @@ -36,7 +36,7 @@ 18.4 { 18.5 public static void main(String[] args) { 18.6 if (com.sun.tools.javadoc.Main. 18.7 - execute("javadoc", "XWerror", 18.8 + execute("javadoc", "XWerror", XWerror.class.getClassLoader(), 18.9 new String[] {"-Xwerror", 18.10 System.getProperty("test.src", ".") + 18.11 java.io.File.separatorChar +
19.1 --- a/test/tools/javadoc/completionFailure/CompletionFailure.java Tue Oct 14 17:05:48 2008 +0100 19.2 +++ b/test/tools/javadoc/completionFailure/CompletionFailure.java Wed Oct 15 08:07:59 2008 -0700 19.3 @@ -37,6 +37,7 @@ 19.4 // run javadoc on package pkg 19.5 if (com.sun.tools.javadoc.Main.execute("javadoc", 19.6 "CompletionFailure", 19.7 + CompletionFailure.class.getClassLoader(), 19.8 new String[]{"pkg"}) != 0) 19.9 throw new Error(); 19.10 }
20.1 --- a/test/tools/javadoc/dupOk/DupOk.java Tue Oct 14 17:05:48 2008 +0100 20.2 +++ b/test/tools/javadoc/dupOk/DupOk.java Wed Oct 15 08:07:59 2008 -0700 20.3 @@ -36,7 +36,7 @@ 20.4 public static void main(String[] args) { 20.5 // run javadoc on package p 20.6 if (com.sun.tools.javadoc.Main. 20.7 - execute("javadoc", "DupOk", 20.8 + execute("javadoc", "DupOk", DupOk.class.getClassLoader(), 20.9 new String[] 20.10 {"-sourcepath", 20.11 System.getProperty("test.src", ".") + java.io.File.separatorChar + "sp1" +
21.1 --- a/test/tools/javadoc/imports/MissingImport.java Tue Oct 14 17:05:48 2008 +0100 21.2 +++ b/test/tools/javadoc/imports/MissingImport.java Wed Oct 15 08:07:59 2008 -0700 21.3 @@ -41,6 +41,7 @@ 21.4 if (com.sun.tools.javadoc.Main.execute( 21.5 "javadoc", 21.6 "MissingImport", 21.7 + MissingImport.class.getClassLoader(), 21.8 new String[] {thisFile}) != 0) 21.9 throw new Error("Javadoc encountered warnings or errors."); 21.10 }
22.1 --- a/test/tools/javadoc/lib/Tester.java Tue Oct 14 17:05:48 2008 +0100 22.2 +++ b/test/tools/javadoc/lib/Tester.java Wed Oct 15 08:07:59 2008 -0700 22.3 @@ -89,7 +89,9 @@ 22.4 public void run() throws IOException { 22.5 try { 22.6 if (com.sun.tools.javadoc.Main.execute("javadoc", 22.7 - docletName, args) != 0) { 22.8 + docletName, 22.9 + getClass().getClassLoader(), 22.10 + args) != 0) { 22.11 throw new Error("Javadoc errors encountered."); 22.12 } 22.13 System.out.println("--> Output written to " + outputFile);
23.1 --- a/test/tools/javadoc/nestedClass/NestedClass.java Tue Oct 14 17:05:48 2008 +0100 23.2 +++ b/test/tools/javadoc/nestedClass/NestedClass.java Wed Oct 15 08:07:59 2008 -0700 23.3 @@ -39,7 +39,7 @@ 23.4 23.5 public static void main(String[] args) { 23.6 if (com.sun.tools.javadoc.Main. 23.7 - execute("javadoc", "NestedClass", 23.8 + execute("javadoc", "NestedClass", NestedClass.class.getClassLoader(), 23.9 new String[] {System.getProperty("test.src", ".") + 23.10 java.io.File.separatorChar + 23.11 "NestedClass.java"})
24.1 --- a/test/tools/javadoc/sourceOnly/p/SourceOnly.java Tue Oct 14 17:05:48 2008 +0100 24.2 +++ b/test/tools/javadoc/sourceOnly/p/SourceOnly.java Wed Oct 15 08:07:59 2008 -0700 24.3 @@ -31,7 +31,7 @@ 24.4 public static void main(String[] args) { 24.5 // run javadoc on package p 24.6 int result = com.sun.tools.javadoc.Main. 24.7 - execute("javadoc", "p.SourceOnly", new String[] {"p"}); 24.8 + execute("javadoc", "p.SourceOnly", SourceOnly.class.getClassLoader(), new String[] {"p"}); 24.9 if (result != 0) 24.10 throw new Error(); 24.11 }
25.1 --- a/test/tools/javadoc/sourceOption/SourceOption.java Tue Oct 14 17:05:48 2008 +0100 25.2 +++ b/test/tools/javadoc/sourceOption/SourceOption.java Wed Oct 15 08:07:59 2008 -0700 25.3 @@ -36,6 +36,7 @@ 25.4 if (com.sun.tools.javadoc.Main.execute( 25.5 "javadoc", 25.6 "SourceOption", 25.7 + SourceOption.class.getClassLoader(), 25.8 new String[] {"-source", "1.3", "p"}) != 0) 25.9 throw new Error("Javadoc encountered warnings or errors."); 25.10 }
26.1 --- a/test/tools/javadoc/subpackageIgnore/SubpackageIgnore.java Tue Oct 14 17:05:48 2008 +0100 26.2 +++ b/test/tools/javadoc/subpackageIgnore/SubpackageIgnore.java Wed Oct 15 08:07:59 2008 -0700 26.3 @@ -36,6 +36,7 @@ 26.4 if (com.sun.tools.javadoc.Main.execute( 26.5 "javadoc", 26.6 "SubpackageIgnore", 26.7 + SubpackageIgnore.class.getClassLoader(), 26.8 new String[] {"-Xwerror", 26.9 "-sourcepath", 26.10 System.getProperty("test.src", "."),