langtools/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java
changeset 1789 7ac8c0815000
parent 1365 ced0e3c4678f
child 1990 5d90be5d60bb
equal deleted inserted replaced
1788:ced0a1a7ec80 1789:7ac8c0815000
    86             appClassLoader = new URLClassLoader(urls);
    86             appClassLoader = new URLClassLoader(urls);
    87         else
    87         else
    88             appClassLoader = new URLClassLoader(urls, docletParentClassLoader);
    88             appClassLoader = new URLClassLoader(urls, docletParentClassLoader);
    89 
    89 
    90         // attempt to find doclet
    90         // attempt to find doclet
    91         Class dc = null;
    91         Class<?> dc = null;
    92         try {
    92         try {
    93             dc = appClassLoader.loadClass(docletClassName);
    93             dc = appClassLoader.loadClass(docletClassName);
    94         } catch (ClassNotFoundException exc) {
    94         } catch (ClassNotFoundException exc) {
    95             messager.error(null, "main.doclet_class_not_found", docletClassName);
    95             messager.error(null, "main.doclet_class_not_found", docletClassName);
    96             messager.exit();
    96             messager.exit();
   102      * Generate documentation here.  Return true on success.
   102      * Generate documentation here.  Return true on success.
   103      */
   103      */
   104     public boolean start(RootDoc root) {
   104     public boolean start(RootDoc root) {
   105         Object retVal;
   105         Object retVal;
   106         String methodName = "start";
   106         String methodName = "start";
   107         Class[] paramTypes = new Class[1];
   107         Class<?>[] paramTypes = new Class<?>[1];
   108         Object[] params = new Object[1];
   108         Object[] params = new Object[1];
   109         paramTypes[0] = RootDoc.class;
   109         paramTypes[0] = RootDoc.class;
   110         params[0] = root;
   110         params[0] = root;
   111         try {
   111         try {
   112             retVal = invoke(methodName, null, paramTypes, params);
   112             retVal = invoke(methodName, null, paramTypes, params);
   128      * arguments to option.  Negative value means error occurred.
   128      * arguments to option.  Negative value means error occurred.
   129      */
   129      */
   130     public int optionLength(String option) {
   130     public int optionLength(String option) {
   131         Object retVal;
   131         Object retVal;
   132         String methodName = "optionLength";
   132         String methodName = "optionLength";
   133         Class[] paramTypes = new Class[1];
   133         Class<?>[] paramTypes = new Class<?>[1];
   134         Object[] params = new Object[1];
   134         Object[] params = new Object[1];
   135         paramTypes[0] = option.getClass();
   135         paramTypes[0] = option.getClass();
   136         params[0] = option;
   136         params[0] = option;
   137         try {
   137         try {
   138             retVal = invoke(methodName, new Integer(0), paramTypes, params);
   138             retVal = invoke(methodName, new Integer(0), paramTypes, params);
   155     public boolean validOptions(List<String[]> optlist) {
   155     public boolean validOptions(List<String[]> optlist) {
   156         Object retVal;
   156         Object retVal;
   157         String options[][] = optlist.toArray(new String[optlist.length()][]);
   157         String options[][] = optlist.toArray(new String[optlist.length()][]);
   158         String methodName = "validOptions";
   158         String methodName = "validOptions";
   159         DocErrorReporter reporter = messager;
   159         DocErrorReporter reporter = messager;
   160         Class[] paramTypes = new Class[2];
   160         Class<?>[] paramTypes = new Class<?>[2];
   161         Object[] params = new Object[2];
   161         Object[] params = new Object[2];
   162         paramTypes[0] = options.getClass();
   162         paramTypes[0] = options.getClass();
   163         paramTypes[1] = DocErrorReporter.class;
   163         paramTypes[1] = DocErrorReporter.class;
   164         params[0] = options;
   164         params[0] = options;
   165         params[1] = reporter;
   165         params[1] = reporter;
   183      */
   183      */
   184     public LanguageVersion languageVersion() {
   184     public LanguageVersion languageVersion() {
   185         try {
   185         try {
   186             Object retVal;
   186             Object retVal;
   187             String methodName = "languageVersion";
   187             String methodName = "languageVersion";
   188             Class[] paramTypes = new Class[0];
   188             Class<?>[] paramTypes = new Class<?>[0];
   189             Object[] params = new Object[0];
   189             Object[] params = new Object[0];
   190             try {
   190             try {
   191                 retVal = invoke(methodName, JAVA_1_1, paramTypes, params);
   191                 retVal = invoke(methodName, JAVA_1_1, paramTypes, params);
   192             } catch (DocletInvokeException exc) {
   192             } catch (DocletInvokeException exc) {
   193                 return JAVA_1_1;
   193                 return JAVA_1_1;
   206 
   206 
   207     /**
   207     /**
   208      * Utility method for calling doclet functionality
   208      * Utility method for calling doclet functionality
   209      */
   209      */
   210     private Object invoke(String methodName, Object returnValueIfNonExistent,
   210     private Object invoke(String methodName, Object returnValueIfNonExistent,
   211                           Class[] paramTypes, Object[] params)
   211                           Class<?>[] paramTypes, Object[] params)
   212         throws DocletInvokeException {
   212         throws DocletInvokeException {
   213             Method meth;
   213             Method meth;
   214             try {
   214             try {
   215                 meth = docletClass.getMethod(methodName, paramTypes);
   215                 meth = docletClass.getMethod(methodName, paramTypes);
   216             } catch (NoSuchMethodException exc) {
   216             } catch (NoSuchMethodException exc) {