27
28 import java.security.AccessController;
29 import java.security.PrivilegedAction;
30 import java.util.Iterator;
31 import java.util.ServiceConfigurationError;
32 import java.util.ServiceLoader;
33
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";
|
27
28 import java.security.AccessController;
29 import java.security.PrivilegedAction;
30 import java.util.Iterator;
31 import java.util.ServiceConfigurationError;
32 import java.util.ServiceLoader;
33
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 private ToolProvider() {}
48
49 /**
50 * Returns the Java programming language compiler provided
51 * with this platform.
52 * <p>The file manager returned by calling
53 * {@link JavaCompiler#getStandardFileManager getStandardFileManager}
54 * on this compiler supports paths provided by any
55 * {@linkplain java.nio.file.FileSystem filesystem}.</p>
56 * @return the compiler provided with this platform or
57 * {@code null} if no compiler is provided
58 * @implNote This implementation returns the compiler provided
59 * by the {@code jdk.compiler} module if that module is available,
60 * and {@code null} otherwise.
61 */
62 public static JavaCompiler getSystemJavaCompiler() {
63 return getSystemTool(JavaCompiler.class,
64 systemJavaCompilerModule, systemJavaCompilerName);
65 }
66
67 private static final String systemDocumentationToolModule = "jdk.javadoc";
|