/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Provides methods for locating tool providers, for example,
* providers of compilers. This class complements the
* functionality of {@link java.util.ServiceLoader}.
*
* @author Peter von der Ahé
* @since 1.6
*/
public class ToolProvider {
/*
* Define the system property "sun.tools.ToolProvider" to enable
* debugging:
*
* java ... -Dsun.tools.ToolProvider ...
*/
// NOTE: do not make this method private as it affects stack traces
try {
frame.getFileName(),
frame.getLineNumber());
}
} else {
}
}
} catch (SecurityException ex) {
ToolProvider.class.getName(),
}
return null;
}
= "com.sun.tools.javac.api.JavacTool";
/**
* Gets the Java™ programming language compiler provided
* with this platform.
* @return the compiler provided with this platform or
* {@code null} if no compiler is provided
*/
}
/**
* Returns the class loader for tools provided with this platform.
* This does not include user-installed tools. Use the
* {@linkplain java.util.ServiceLoader service provider mechanism}
* for locating user installed tools.
*
* @return the class loader for tools provided with this platform
* or {@code null} if no tools are provided
*/
try {
Class<? extends JavaCompiler> c =
return c.getClassLoader();
} catch (Throwable e) {
}
}
instance = new ToolProvider();
return instance;
}
// Cache for tool classes.
// Use weak references to avoid keeping classes around unnecessarily
// Cache for tool classloader.
// Use a weak reference to avoid keeping it around unnecessarily
private ToolProvider() { }
try {
} catch (Throwable e) {
return null;
}
}
if (c == null) {
try {
c = findSystemToolClass(name);
} catch (Throwable e) {
}
}
return c.asSubclass(clazz);
}
{
// try loading class directly, in case tool is on the bootclasspath
try {
} catch (ClassNotFoundException e) {
// if tool not on bootclasspath, look in default tools location (tools.jar)
// if tools not found, no point in trying a URLClassLoader
// so rethrow the original exception.
throw e;
}
}
}
}