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