86 * @author Robert Field |
86 * @author Robert Field |
87 * @author Neal Gafter (rewrite) |
87 * @author Neal Gafter (rewrite) |
88 */ |
88 */ |
89 public class Start extends ToolOption.Helper { |
89 public class Start extends ToolOption.Helper { |
90 |
90 |
91 @SuppressWarnings("deprecation") |
91 private static final String OldStdDocletName = |
92 private static final Class<?> OldStdDoclet = |
92 "com.sun.tools.doclets.standard.Standard"; |
93 com.sun.tools.doclets.standard.Standard.class; |
|
94 |
93 |
95 private static final Class<?> StdDoclet = |
94 private static final Class<?> StdDoclet = |
96 jdk.javadoc.doclet.StandardDoclet.class; |
95 jdk.javadoc.doclet.StandardDoclet.class; |
97 /** Context for this invocation. */ |
96 /** Context for this invocation. */ |
98 private final Context context; |
97 private final Context context; |
332 int rc = com.sun.tools.javadoc.Main.execute( |
331 int rc = com.sun.tools.javadoc.Main.execute( |
333 messager.programName, |
332 messager.programName, |
334 messager.getWriter(WriterKind.ERROR), |
333 messager.getWriter(WriterKind.ERROR), |
335 messager.getWriter(WriterKind.WARNING), |
334 messager.getWriter(WriterKind.WARNING), |
336 messager.getWriter(WriterKind.NOTICE), |
335 messager.getWriter(WriterKind.NOTICE), |
337 "com.sun.tools.doclets.standard.Standard", |
336 OldStdDocletName, |
338 nargv); |
337 nargv); |
339 return (rc == 0) ? OK : ERROR; |
338 return (rc == 0) ? OK : ERROR; |
340 } |
339 } |
341 return begin(Arrays.asList(argv), Collections.emptySet()); |
340 return begin(Arrays.asList(argv), Collections.emptySet()); |
342 } |
341 } |
762 } |
761 } |
763 } |
762 } |
764 |
763 |
765 // Step 4: we have a doclet, try loading it |
764 // Step 4: we have a doclet, try loading it |
766 if (docletName != null) { |
765 if (docletName != null) { |
767 try { |
766 return loadDocletClass(docletName); |
768 return Class.forName(docletName, true, getClass().getClassLoader()); |
|
769 } catch (ClassNotFoundException cnfe) { |
|
770 if (apiMode) { |
|
771 throw new IllegalArgumentException("Cannot find doclet class " + userDocletName); |
|
772 } |
|
773 String text = messager.getText("main.doclet_class_not_found", userDocletName); |
|
774 throw new ToolException(CMDERR, text, cnfe); |
|
775 } |
|
776 } |
767 } |
777 |
768 |
778 // Step 5: we don't have a doclet specified, do we have taglets ? |
769 // Step 5: we don't have a doclet specified, do we have taglets ? |
779 if (!userTagletNames.isEmpty() && hasOldTaglet(userTagletNames, userTagletPath)) { |
770 if (!userTagletNames.isEmpty() && hasOldTaglet(userTagletNames, userTagletPath)) { |
780 // found a bogey, return the old doclet |
771 // found a bogey, return the old doclet |
781 return OldStdDoclet; |
772 return loadDocletClass(OldStdDocletName); |
782 } |
773 } |
783 |
774 |
784 // finally |
775 // finally |
785 return StdDoclet; |
776 return StdDoclet; |
|
777 } |
|
778 |
|
779 private Class<?> loadDocletClass(String docletName) throws ToolException { |
|
780 try { |
|
781 return Class.forName(docletName, true, getClass().getClassLoader()); |
|
782 } catch (ClassNotFoundException cnfe) { |
|
783 if (apiMode) { |
|
784 throw new IllegalArgumentException("Cannot find doclet class " + docletName); |
|
785 } |
|
786 String text = messager.getText("main.doclet_class_not_found", docletName); |
|
787 throw new ToolException(CMDERR, text, cnfe); |
|
788 } |
786 } |
789 } |
787 |
790 |
788 /* |
791 /* |
789 * This method returns true iff it finds a legacy taglet, but for |
792 * This method returns true iff it finds a legacy taglet, but for |
790 * all other conditions including errors it returns false, allowing |
793 * all other conditions including errors it returns false, allowing |