< prev index next >

src/java.compiler/share/classes/javax/tools/ToolProvider.java

Print this page


   1 /*
   2  * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  26 package javax.tools;
  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&eacute;
  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&trade; 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";


   1 /*
   2  * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  26 package javax.tools;
  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&eacute;
  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&trade; 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";


< prev index next >