mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-17 19:33:18 +00:00
6748541: javadoc should be reusable
Reviewed-by: bpatel
This commit is contained in:
parent
1dc1dcab49
commit
55ef4bc22e
@ -51,7 +51,7 @@ import java.io.*;
|
||||
*/
|
||||
public class ConfigurationImpl extends Configuration {
|
||||
|
||||
private static final ConfigurationImpl instance = new ConfigurationImpl();
|
||||
private static ConfigurationImpl instance = new ConfigurationImpl();
|
||||
|
||||
/**
|
||||
* The build date. Note: For now, we will use
|
||||
@ -189,6 +189,15 @@ public class ConfigurationImpl extends Configuration {
|
||||
"com.sun.tools.doclets.formats.html.resources.standard");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset to a fresh new ConfigurationImpl, to allow multiple invocations
|
||||
* of javadoc within a single VM. It would be better not to be using
|
||||
* static fields at all, but .... (sigh).
|
||||
*/
|
||||
public static void reset() {
|
||||
instance = new ConfigurationImpl();
|
||||
}
|
||||
|
||||
public static ConfigurationImpl getInstance() {
|
||||
return instance;
|
||||
}
|
||||
@ -475,7 +484,7 @@ public class ConfigurationImpl extends Configuration {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public WriterFactory getWriterFactory() {
|
||||
return WriterFactoryImpl.getInstance();
|
||||
return new WriterFactoryImpl(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -41,12 +41,14 @@ import java.io.*;
|
||||
*
|
||||
*/
|
||||
public class HtmlDoclet extends AbstractDoclet {
|
||||
public HtmlDoclet() {
|
||||
configuration = (ConfigurationImpl) configuration();
|
||||
}
|
||||
|
||||
/**
|
||||
* The global configuration information for this run.
|
||||
*/
|
||||
public ConfigurationImpl configuration =
|
||||
(ConfigurationImpl) configuration();
|
||||
public ConfigurationImpl configuration;
|
||||
|
||||
/**
|
||||
* The "start" method as required by Javadoc.
|
||||
@ -56,8 +58,12 @@ public class HtmlDoclet extends AbstractDoclet {
|
||||
* @return true if the doclet ran without encountering any errors.
|
||||
*/
|
||||
public static boolean start(RootDoc root) {
|
||||
HtmlDoclet doclet = new HtmlDoclet();
|
||||
return doclet.start(doclet, root);
|
||||
try {
|
||||
HtmlDoclet doclet = new HtmlDoclet();
|
||||
return doclet.start(doclet, root);
|
||||
} finally {
|
||||
ConfigurationImpl.reset();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -37,26 +37,12 @@ import com.sun.javadoc.*;
|
||||
*/
|
||||
public class WriterFactoryImpl implements WriterFactory {
|
||||
|
||||
private static WriterFactoryImpl instance;
|
||||
|
||||
private ConfigurationImpl configuration;
|
||||
|
||||
private WriterFactoryImpl(ConfigurationImpl configuration) {
|
||||
public WriterFactoryImpl(ConfigurationImpl configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of this factory.
|
||||
*
|
||||
* @return an instance of this factory.
|
||||
*/
|
||||
public static WriterFactoryImpl getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new WriterFactoryImpl(ConfigurationImpl.getInstance());
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@ -45,7 +45,7 @@ public abstract class AbstractDoclet {
|
||||
/**
|
||||
* The global configuration information for this run.
|
||||
*/
|
||||
public Configuration configuration = configuration();
|
||||
public Configuration configuration;
|
||||
|
||||
/**
|
||||
* The only doclet that may use this toolkit is {@value}
|
||||
@ -74,6 +74,7 @@ public abstract class AbstractDoclet {
|
||||
* @return true if the doclet executed without error. False otherwise.
|
||||
*/
|
||||
public boolean start(AbstractDoclet doclet, RootDoc root) {
|
||||
configuration = configuration();
|
||||
configuration.root = root;
|
||||
if (! isValidDoclet(doclet)) {
|
||||
return false;
|
||||
|
||||
@ -113,9 +113,9 @@ public abstract class Configuration {
|
||||
public boolean keywords = false;
|
||||
|
||||
/**
|
||||
* The meta tag keywords sole-instance.
|
||||
* The meta tag keywords instance.
|
||||
*/
|
||||
public final MetaKeywords metakeywords = MetaKeywords.getInstance(this);
|
||||
public final MetaKeywords metakeywords = new MetaKeywords(this);
|
||||
|
||||
/**
|
||||
* The list of doc-file subdirectories to exclude
|
||||
@ -211,12 +211,12 @@ public abstract class Configuration {
|
||||
public boolean notimestamp= false;
|
||||
|
||||
/**
|
||||
* The package grouping sole-instance.
|
||||
* The package grouping instance.
|
||||
*/
|
||||
public final Group group = Group.getInstance(this);
|
||||
public final Group group = new Group(this);
|
||||
|
||||
/**
|
||||
* The tracker of external package links (sole-instance).
|
||||
* The tracker of external package links.
|
||||
*/
|
||||
public final Extern extern = new Extern(this);
|
||||
|
||||
|
||||
@ -56,8 +56,6 @@ import java.util.*;
|
||||
*/
|
||||
public class Group {
|
||||
|
||||
private static Group instance;
|
||||
|
||||
/**
|
||||
* Map of regular expressions with the corresponding group name.
|
||||
*/
|
||||
@ -96,17 +94,10 @@ public class Group {
|
||||
}
|
||||
}
|
||||
|
||||
private Group(Configuration configuration) {
|
||||
public Group(Configuration configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
public static Group getInstance(Configuration configuration) {
|
||||
if (instance == null) {
|
||||
instance = new Group(configuration);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Depending upon the format of the package name provided in the "-group"
|
||||
* option, generate two separate maps. There will be a map for mapping
|
||||
|
||||
@ -43,8 +43,6 @@ import java.util.*;
|
||||
*/
|
||||
public class MetaKeywords {
|
||||
|
||||
private static MetaKeywords instance = null;
|
||||
|
||||
/**
|
||||
* The global configuration information for this run.
|
||||
*/
|
||||
@ -53,22 +51,10 @@ public class MetaKeywords {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
private MetaKeywords(Configuration configuration) {
|
||||
public MetaKeywords(Configuration configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of MetaKeywords. This class is a singleton.
|
||||
*
|
||||
* @param configuration the current configuration of the doclet.
|
||||
*/
|
||||
public static MetaKeywords getInstance(Configuration configuration) {
|
||||
if (instance == null) {
|
||||
instance = new MetaKeywords(configuration);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of strings where each element
|
||||
* is a class, method or field name. This array is
|
||||
|
||||
@ -72,7 +72,8 @@ public class AuthorDD
|
||||
|
||||
/** Run javadoc */
|
||||
public static void runJavadoc(String[] javadocArgs) {
|
||||
if (com.sun.tools.javadoc.Main.execute(javadocArgs) != 0) {
|
||||
if (com.sun.tools.javadoc.Main.execute(AuthorDD.class.getClassLoader(),
|
||||
javadocArgs) != 0) {
|
||||
throw new Error("Javadoc failed to execute");
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,6 +197,7 @@ public abstract class JavadocTester {
|
||||
new PrintWriter(warnings, true),
|
||||
new PrintWriter(notices, true),
|
||||
docletClass,
|
||||
getClass().getClassLoader(),
|
||||
args);
|
||||
System.setOut(prev);
|
||||
standardOut = new StringBuffer(stdout.toString());
|
||||
|
||||
@ -37,7 +37,7 @@ public class BooleanConst extends Doclet
|
||||
public static void main(String[] args) {
|
||||
// run javadoc on package p
|
||||
if (com.sun.tools.javadoc.Main.
|
||||
execute("javadoc", "BooleanConst",
|
||||
execute("javadoc", "BooleanConst", BooleanConst.class.getClassLoader(),
|
||||
new String[] {System.getProperty("test.src", ".") + java.io.File.separatorChar + "BooleanConst.java"}) != 0)
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
@ -41,6 +41,7 @@ public class BreakIteratorWarning extends Doclet {
|
||||
if (com.sun.tools.javadoc.Main.execute(
|
||||
"javadoc",
|
||||
"BreakIteratorWarning",
|
||||
BreakIteratorWarning.class.getClassLoader(),
|
||||
new String[] {"-Xwerror", thisFile}) != 0)
|
||||
throw new Error("Javadoc encountered warnings or errors.");
|
||||
}
|
||||
|
||||
@ -40,6 +40,7 @@ public class FlagsTooEarly extends Doclet {
|
||||
if (com.sun.tools.javadoc.Main.execute(
|
||||
"javadoc",
|
||||
"FlagsTooEarly",
|
||||
FlagsTooEarly.class.getClassLoader(),
|
||||
new String[] {"-Xwerror", thisFile}) != 0)
|
||||
throw new Error("Javadoc encountered warnings or errors.");
|
||||
}
|
||||
|
||||
@ -60,6 +60,7 @@ public class InlineTagsWithBraces extends Doclet {
|
||||
if (com.sun.tools.javadoc.Main.execute(
|
||||
"javadoc",
|
||||
"InlineTagsWithBraces",
|
||||
InlineTagsWithBraces.class.getClassLoader(),
|
||||
new String[] {"-Xwerror", thisFile}) != 0)
|
||||
throw new Error("Javadoc encountered warnings or errors.");
|
||||
}
|
||||
|
||||
@ -43,6 +43,7 @@ public class LangVers extends Doclet {
|
||||
if (com.sun.tools.javadoc.Main.execute(
|
||||
"javadoc",
|
||||
"LangVers",
|
||||
LangVers.class.getClassLoader(),
|
||||
new String[] {"-source", "1.5", thisFile}) != 0)
|
||||
throw new Error("Javadoc encountered warnings or errors.");
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ public class MethodLinks extends Doclet
|
||||
{
|
||||
public static void main(String[] args) {
|
||||
if (com.sun.tools.javadoc.Main.
|
||||
execute("javadoc", "MethodLinks",
|
||||
execute("javadoc", "MethodLinks", MethodLinks.class.getClassLoader(),
|
||||
new String[] {System.getProperty("test.src", ".") +
|
||||
java.io.File.separatorChar + "MethodLinks.java"}
|
||||
) != 0)
|
||||
|
||||
@ -44,7 +44,7 @@ public class NoStar extends Doclet
|
||||
{
|
||||
public static void main(String[] args) {
|
||||
if (com.sun.tools.javadoc.Main.
|
||||
execute("javadoc", "NoStar",
|
||||
execute("javadoc", "NoStar", NoStar.class.getClassLoader(),
|
||||
new String[] {System.getProperty("test.src", ".") + java.io.File.separatorChar + "NoStar.java"}) != 0)
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
@ -55,7 +55,8 @@ public class T4994049 extends Doclet {
|
||||
public static void main(String... args) {
|
||||
for (String file : args) {
|
||||
File source = new File(System.getProperty("test.src", "."), file);
|
||||
if (execute("javadoc", "T4994049", new String[]{source.getPath()} ) != 0)
|
||||
if (execute("javadoc", "T4994049", T4994049.class.getClassLoader(),
|
||||
new String[]{source.getPath()} ) != 0)
|
||||
throw new Error();
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ public class XWerror extends Doclet
|
||||
{
|
||||
public static void main(String[] args) {
|
||||
if (com.sun.tools.javadoc.Main.
|
||||
execute("javadoc", "XWerror",
|
||||
execute("javadoc", "XWerror", XWerror.class.getClassLoader(),
|
||||
new String[] {"-Xwerror",
|
||||
System.getProperty("test.src", ".") +
|
||||
java.io.File.separatorChar +
|
||||
|
||||
@ -37,6 +37,7 @@ public class CompletionFailure extends Doclet
|
||||
// run javadoc on package pkg
|
||||
if (com.sun.tools.javadoc.Main.execute("javadoc",
|
||||
"CompletionFailure",
|
||||
CompletionFailure.class.getClassLoader(),
|
||||
new String[]{"pkg"}) != 0)
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ public class DupOk extends Doclet
|
||||
public static void main(String[] args) {
|
||||
// run javadoc on package p
|
||||
if (com.sun.tools.javadoc.Main.
|
||||
execute("javadoc", "DupOk",
|
||||
execute("javadoc", "DupOk", DupOk.class.getClassLoader(),
|
||||
new String[]
|
||||
{"-sourcepath",
|
||||
System.getProperty("test.src", ".") + java.io.File.separatorChar + "sp1" +
|
||||
|
||||
@ -41,6 +41,7 @@ public class MissingImport extends Doclet {
|
||||
if (com.sun.tools.javadoc.Main.execute(
|
||||
"javadoc",
|
||||
"MissingImport",
|
||||
MissingImport.class.getClassLoader(),
|
||||
new String[] {thisFile}) != 0)
|
||||
throw new Error("Javadoc encountered warnings or errors.");
|
||||
}
|
||||
|
||||
@ -89,7 +89,9 @@ public class Tester {
|
||||
public void run() throws IOException {
|
||||
try {
|
||||
if (com.sun.tools.javadoc.Main.execute("javadoc",
|
||||
docletName, args) != 0) {
|
||||
docletName,
|
||||
getClass().getClassLoader(),
|
||||
args) != 0) {
|
||||
throw new Error("Javadoc errors encountered.");
|
||||
}
|
||||
System.out.println("--> Output written to " + outputFile);
|
||||
|
||||
@ -39,7 +39,7 @@ public class NestedClass extends Doclet
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (com.sun.tools.javadoc.Main.
|
||||
execute("javadoc", "NestedClass",
|
||||
execute("javadoc", "NestedClass", NestedClass.class.getClassLoader(),
|
||||
new String[] {System.getProperty("test.src", ".") +
|
||||
java.io.File.separatorChar +
|
||||
"NestedClass.java"})
|
||||
|
||||
@ -31,7 +31,7 @@ public class SourceOnly extends com.sun.javadoc.Doclet
|
||||
public static void main(String[] args) {
|
||||
// run javadoc on package p
|
||||
int result = com.sun.tools.javadoc.Main.
|
||||
execute("javadoc", "p.SourceOnly", new String[] {"p"});
|
||||
execute("javadoc", "p.SourceOnly", SourceOnly.class.getClassLoader(), new String[] {"p"});
|
||||
if (result != 0)
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@ public class SourceOption extends Doclet {
|
||||
if (com.sun.tools.javadoc.Main.execute(
|
||||
"javadoc",
|
||||
"SourceOption",
|
||||
SourceOption.class.getClassLoader(),
|
||||
new String[] {"-source", "1.3", "p"}) != 0)
|
||||
throw new Error("Javadoc encountered warnings or errors.");
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@ public class SubpackageIgnore extends Doclet {
|
||||
if (com.sun.tools.javadoc.Main.execute(
|
||||
"javadoc",
|
||||
"SubpackageIgnore",
|
||||
SubpackageIgnore.class.getClassLoader(),
|
||||
new String[] {"-Xwerror",
|
||||
"-sourcepath",
|
||||
System.getProperty("test.src", "."),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user