mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 10:04:42 +02:00
6748546: javadoc API should be classloader-friendly
Reviewed-by: bpatel
This commit is contained in:
parent
ebc51f0813
commit
1a0a9d1a6f
3 changed files with 113 additions and 7 deletions
|
@ -32,7 +32,6 @@ import static com.sun.javadoc.LanguageVersion.*;
|
|||
import com.sun.tools.javac.util.List;
|
||||
|
||||
import java.net.*;
|
||||
import java.lang.OutOfMemoryError;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
@ -70,7 +69,8 @@ public class DocletInvoker {
|
|||
}
|
||||
|
||||
public DocletInvoker(Messager messager,
|
||||
String docletClassName, String docletPath) {
|
||||
String docletClassName, String docletPath,
|
||||
ClassLoader docletParentClassLoader) {
|
||||
this.messager = messager;
|
||||
this.docletClassName = docletClassName;
|
||||
|
||||
|
@ -82,7 +82,10 @@ public class DocletInvoker {
|
|||
cpString = appendPath(System.getProperty("java.class.path"), cpString);
|
||||
cpString = appendPath(docletPath, cpString);
|
||||
URL[] urls = pathToURLs(cpString);
|
||||
if (docletParentClassLoader == null)
|
||||
appClassLoader = new URLClassLoader(urls);
|
||||
else
|
||||
appClassLoader = new URLClassLoader(urls, docletParentClassLoader);
|
||||
|
||||
// attempt to find doclet
|
||||
Class dc = null;
|
||||
|
|
|
@ -59,6 +59,21 @@ public class Main {
|
|||
return jdoc.begin(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Programmatic interface.
|
||||
* @param args The command line parameters.
|
||||
* @param docletParentClassLoader The parent class loader used when
|
||||
* creating the doclet classloader. If null, the class loader used
|
||||
* to instantiate doclets will be created without specifying a parent
|
||||
* class loader.
|
||||
* @return The return code.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static int execute(ClassLoader docletParentClassLoader, String... args) {
|
||||
Start jdoc = new Start(docletParentClassLoader);
|
||||
return jdoc.begin(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Programmatic interface.
|
||||
* @param programName Name of the program (for error messages).
|
||||
|
@ -70,6 +85,22 @@ public class Main {
|
|||
return jdoc.begin(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Programmatic interface.
|
||||
* @param programName Name of the program (for error messages).
|
||||
* @param args The command line parameters.
|
||||
* @param docletParentClassLoader The parent class loader used when
|
||||
* creating the doclet classloader. If null, the class loader used
|
||||
* to instantiate doclets will be created without specifying a parent
|
||||
* class loader.
|
||||
* @return The return code.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static int execute(String programName, ClassLoader docletParentClassLoader, String... args) {
|
||||
Start jdoc = new Start(programName, docletParentClassLoader);
|
||||
return jdoc.begin(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Programmatic interface.
|
||||
* @param programName Name of the program (for error messages).
|
||||
|
@ -84,6 +115,26 @@ public class Main {
|
|||
return jdoc.begin(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Programmatic interface.
|
||||
* @param programName Name of the program (for error messages).
|
||||
* @param defaultDocletClassName Fully qualified class name.
|
||||
* @param docletParentClassLoader The parent class loader used when
|
||||
* creating the doclet classloader. If null, the class loader used
|
||||
* to instantiate doclets will be created without specifying a parent
|
||||
* class loader.
|
||||
* @param args The command line parameters.
|
||||
* @return The return code.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static int execute(String programName,
|
||||
String defaultDocletClassName,
|
||||
ClassLoader docletParentClassLoader,
|
||||
String... args) {
|
||||
Start jdoc = new Start(programName, defaultDocletClassName, docletParentClassLoader);
|
||||
return jdoc.begin(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Programmatic interface.
|
||||
* @param programName Name of the program (for error messages).
|
||||
|
@ -105,4 +156,33 @@ public class Main {
|
|||
defaultDocletClassName);
|
||||
return jdoc.begin(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Programmatic interface.
|
||||
* @param programName Name of the program (for error messages).
|
||||
* @param errWriter PrintWriter to receive error messages.
|
||||
* @param warnWriter PrintWriter to receive error messages.
|
||||
* @param noticeWriter PrintWriter to receive error messages.
|
||||
* @param defaultDocletClassName Fully qualified class name.
|
||||
* @param docletParentClassLoader The parent class loader used when
|
||||
* creating the doclet classloader. If null, the class loader used
|
||||
* to instantiate doclets will be created without specifying a parent
|
||||
* class loader.
|
||||
* @param args The command line parameters.
|
||||
* @return The return code.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static int execute(String programName,
|
||||
PrintWriter errWriter,
|
||||
PrintWriter warnWriter,
|
||||
PrintWriter noticeWriter,
|
||||
String defaultDocletClassName,
|
||||
ClassLoader docletParentClassLoader,
|
||||
String... args) {
|
||||
Start jdoc = new Start(programName,
|
||||
errWriter, warnWriter, noticeWriter,
|
||||
defaultDocletClassName,
|
||||
docletParentClassLoader);
|
||||
return jdoc.begin(args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,10 +54,8 @@ class Start {
|
|||
/** Context for this invocation. */
|
||||
private final Context context;
|
||||
|
||||
/**
|
||||
* Name of the program
|
||||
*/
|
||||
private final String defaultDocletClassName;
|
||||
private final ClassLoader docletParentClassLoader;
|
||||
|
||||
private static final String javadocName = "javadoc";
|
||||
|
||||
|
@ -91,21 +89,45 @@ class Start {
|
|||
PrintWriter warnWriter,
|
||||
PrintWriter noticeWriter,
|
||||
String defaultDocletClassName) {
|
||||
this(programName, errWriter, warnWriter, noticeWriter, defaultDocletClassName, null);
|
||||
}
|
||||
|
||||
Start(String programName,
|
||||
PrintWriter errWriter,
|
||||
PrintWriter warnWriter,
|
||||
PrintWriter noticeWriter,
|
||||
String defaultDocletClassName,
|
||||
ClassLoader docletParentClassLoader) {
|
||||
context = new Context();
|
||||
messager = new Messager(context, programName, errWriter, warnWriter, noticeWriter);
|
||||
this.defaultDocletClassName = defaultDocletClassName;
|
||||
this.docletParentClassLoader = docletParentClassLoader;
|
||||
}
|
||||
|
||||
Start(String programName, String defaultDocletClassName) {
|
||||
this(programName, defaultDocletClassName, null);
|
||||
}
|
||||
|
||||
Start(String programName, String defaultDocletClassName,
|
||||
ClassLoader docletParentClassLoader) {
|
||||
context = new Context();
|
||||
messager = new Messager(context, programName);
|
||||
this.defaultDocletClassName = defaultDocletClassName;
|
||||
this.docletParentClassLoader = docletParentClassLoader;
|
||||
}
|
||||
|
||||
Start(String programName, ClassLoader docletParentClassLoader) {
|
||||
this(programName, standardDocletClassName, docletParentClassLoader);
|
||||
}
|
||||
|
||||
Start(String programName) {
|
||||
this(programName, standardDocletClassName);
|
||||
}
|
||||
|
||||
Start(ClassLoader docletParentClassLoader) {
|
||||
this(javadocName, docletParentClassLoader);
|
||||
}
|
||||
|
||||
Start() {
|
||||
this(javadocName);
|
||||
}
|
||||
|
@ -390,7 +412,8 @@ class Start {
|
|||
|
||||
// attempt to find doclet
|
||||
docletInvoker = new DocletInvoker(messager,
|
||||
docletClassName, docletPath);
|
||||
docletClassName, docletPath,
|
||||
docletParentClassLoader);
|
||||
}
|
||||
|
||||
private void setFilter(long filterBits) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue