34 /**
35 * Provides methods for locating tool providers, for example,
36 * providers of compilers. This class complements the
37 * functionality of {@link java.util.ServiceLoader}.
38 *
39 * @author Peter von der Ahé
40 * @since 1.6
41 */
42 public class ToolProvider {
43
44 private static final String systemJavaCompilerModule = "jdk.compiler";
45 private static final String systemJavaCompilerName = "com.sun.tools.javac.api.JavacTool";
46
47 /**
48 * Do not call.
49 */
50 @Deprecated(forRemoval=true, since="14")
51 public ToolProvider() {}
52
53 /**
54 * Returns the Java™ programming language compiler provided
55 * with this platform.
56 * <p>The file manager returned by calling
57 * {@link JavaCompiler#getStandardFileManager getStandardFileManager}
58 * on this compiler supports paths provided by any
59 * {@linkplain java.nio.file.FileSystem filesystem}.</p>
60 * @return the compiler provided with this platform or
61 * {@code null} if no compiler is provided
62 * @implNote This implementation returns the compiler provided
63 * by the {@code jdk.compiler} module if that module is available,
64 * and {@code null} otherwise.
65 */
66 public static JavaCompiler getSystemJavaCompiler() {
67 return getSystemTool(JavaCompiler.class,
68 systemJavaCompilerModule, systemJavaCompilerName);
69 }
70
71 private static final String systemDocumentationToolModule = "jdk.javadoc";
72 private static final String systemDocumentationToolName = "jdk.javadoc.internal.api.JavadocTool";
73
74 /**
75 * Returns the Java™ programming language documentation tool provided
76 * with this platform.
77 * <p>The file manager returned by calling
78 * {@link DocumentationTool#getStandardFileManager getStandardFileManager}
79 * on this tool supports paths provided by any
80 * {@linkplain java.nio.file.FileSystem filesystem}.</p>
81 * @return the documentation tool provided with this platform or
82 * {@code null} if no documentation tool is provided
83 * @implNote This implementation returns the tool provided
84 * by the {@code jdk.javadoc} module if that module is available,
85 * and {@code null} otherwise.
86 */
87 public static DocumentationTool getSystemDocumentationTool() {
88 return getSystemTool(DocumentationTool.class,
89 systemDocumentationToolModule, systemDocumentationToolName);
90 }
91
92 /**
93 * Returns a class loader that may be used to load system tools,
94 * or {@code null} if no such special loader is provided.
95 * @implSpec This implementation always returns {@code null}.
|
34 /**
35 * Provides methods for locating tool providers, for example,
36 * providers of compilers. This class complements the
37 * functionality of {@link java.util.ServiceLoader}.
38 *
39 * @author Peter von der Ahé
40 * @since 1.6
41 */
42 public class ToolProvider {
43
44 private static final String systemJavaCompilerModule = "jdk.compiler";
45 private static final String systemJavaCompilerName = "com.sun.tools.javac.api.JavacTool";
46
47 /**
48 * Do not call.
49 */
50 @Deprecated(forRemoval=true, since="14")
51 public ToolProvider() {}
52
53 /**
54 * Returns the Java programming language compiler provided
55 * with this platform.
56 * <p>The file manager returned by calling
57 * {@link JavaCompiler#getStandardFileManager getStandardFileManager}
58 * on this compiler supports paths provided by any
59 * {@linkplain java.nio.file.FileSystem filesystem}.</p>
60 * @return the compiler provided with this platform or
61 * {@code null} if no compiler is provided
62 * @implNote This implementation returns the compiler provided
63 * by the {@code jdk.compiler} module if that module is available,
64 * and {@code null} otherwise.
65 */
66 public static JavaCompiler getSystemJavaCompiler() {
67 return getSystemTool(JavaCompiler.class,
68 systemJavaCompilerModule, systemJavaCompilerName);
69 }
70
71 private static final String systemDocumentationToolModule = "jdk.javadoc";
72 private static final String systemDocumentationToolName = "jdk.javadoc.internal.api.JavadocTool";
73
74 /**
75 * Returns the Java programming language documentation tool provided
76 * with this platform.
77 * <p>The file manager returned by calling
78 * {@link DocumentationTool#getStandardFileManager getStandardFileManager}
79 * on this tool supports paths provided by any
80 * {@linkplain java.nio.file.FileSystem filesystem}.</p>
81 * @return the documentation tool provided with this platform or
82 * {@code null} if no documentation tool is provided
83 * @implNote This implementation returns the tool provided
84 * by the {@code jdk.javadoc} module if that module is available,
85 * and {@code null} otherwise.
86 */
87 public static DocumentationTool getSystemDocumentationTool() {
88 return getSystemTool(DocumentationTool.class,
89 systemDocumentationToolModule, systemDocumentationToolName);
90 }
91
92 /**
93 * Returns a class loader that may be used to load system tools,
94 * or {@code null} if no such special loader is provided.
95 * @implSpec This implementation always returns {@code null}.
|