TopBlend: Here is the first difference. There are 22 differences. is old. is new.


javax.tools
Class ToolProvider


java.lang.Object
  extended by javax.tools.ToolProvider

public class ToolProvider
extends Object

Provides methods for locating tool providers, for example, providers of Java compilers. This class complements the functionality of ServiceLoader . A simple mechanism for looking up tool providers. A tool is a subinterface of Tool. Tool providers may be installed in an implementation of the Java platform in the form of extensions, that is, jar files placed into any of the usual extension directories. Tools may also be made available by adding them to the applet or application class path or by some other platform-specific means.

In this lookup mechanism a tool is represented by an interface. A provider of a given tool contains one or more concrete classes that extend this tool interface with data and code specific to the provider. The only requirement enforced here is that provider classes must have a zero-argument constructor so that they may be instantiated during lookup.

Since:
1.6
A tool provider identifies itself by placing a provider-configuration file in the resource directory META-INF/services . The file's name should consist of the fully-qualified name of the tool interface. The file should contain a list of fully-qualified concrete provider-class names, one per line. Space and tab characters surrounding each name, as well as blank lines, are ignored. The comment character is '#' ( 0x23 ); on each line all characters following the first comment character are ignored. The file must be encoded in UTF-8.

If a particular concrete provider class is named in more than one configuration file, or is named in the same configuration file more than once, then the duplicates will be ignored. The configuration file naming a particular provider need not be in the same jar file or other distribution unit as the provider itself. The provider must be accessible from the same class loader that was initially queried to locate the configuration file; note that this is not necessarily the class loader that found the file.

For example, if com.vendor.Tool is a provider of the JavaCompilerTool tool then its jar file would contain the file META-INF/services/javax.tools.JavaCompilerTool . This file would contain the single line:


 
 com.vendor.Tool
 
The provider-lookup mechanism always executes in the security context of the caller. Trusted system code should typically invoke the methods in this class from within a privileged security context.


Method Summary
static  JavaCompiler JavaCompilerTool getSystemJavaCompiler defaultJavaCompiler ()
          Gets the Java compiler provided with default JavaCompilerTool on this platform.
static  ClassLoader getSystemToolClassLoader ()
          Returns the class loader for tools provided with this platform.
static
<T extends Tool
Iterable
installedTools ( Class <T> tool)
          Locates and incrementally instantiates available tools of the specified type using the extension class loader.
 
Methods inherited from class java.lang. Object
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait
 

Method Detail

getSystemJavaCompiler defaultJavaCompiler


public static JavaCompilerJavaCompilerToolgetSystemJavaCompiler defaultJavaCompiler ()
Gets the Java compiler provided with default JavaCompilerTool on this platform.

Returns:
the default Java compiler provided with on this platform or null if no compiler is provided by default.

getSystemToolClassLoader installedTools


public static ClassLoader<T extends Tool> Iterable<T> getSystemToolClassLoader installedTools () ( Class<T> tool)
 throws IllegalArgumentException
Returns the class loader for tools provided with this platform. This does not include user-installed tools. Use the service provider mechanism for locating user installed tools. Locates and incrementally instantiates available tools of the specified type using the extension class loader.

If the extension class loader cannot be found then the system class loader is used; if there is no system class loader then the bootstrap class loader is used.

For example, to locate all available Java compilers, use this code:


 for (JavaCompilerTool compiler : installedTools(JavaCompilerTool.class))
 System.out.format("Found compiler %s%n", compiler.getClass());
 

Parameters:
tool - the tool interface
Returns:
the class loader for tools provided with this platform or null if no tools are provided an Iterable that yields an Iterator that yields tools objects of the specified type, in some arbitrary order. The iterator may throw an error if a provider-configuration file violates the specified format or if a tool class cannot be found and instantiated.
Throws:
IllegalArgumentException - if tool is not an interface