public interface ToolProvider
Tool providers are normally located using the service-provider loading facility defined by ServiceLoader
. Each provider must provide a name, and a method to run an instance of the corresponding tool. When a tool is run, it will be provided with an array of string arguments, and a pair of streams: one for normal (or expected) output and the other for reporting any errors that may occur. The interpretation of the string arguments will normally be defined by each individual tool provider, but will generally correspond to the arguments that could be provided to the tool when invoking the tool from the command line.
Modifier and Type | Method | Description |
---|---|---|
default Optional |
description() |
Returns a short description of the tool, or an empty Optional if no description is available. |
static Optional |
findFirst |
Returns the first instance of a ToolProvider with the given name, as loaded by ServiceLoader using the system class loader. |
String |
name() |
Returns the name of this tool provider. |
default int |
run |
Runs an instance of the tool, returning zero for a successful run. |
int |
run |
Runs an instance of the tool, returning zero for a successful run. |
String name()
default Optional<String> description()
Optional
if no description is available.
jar
Create, manipulate, and extract an archive of classes and resources.
javac
Read Java declarations and compile them into class files.
jlink
Assemble a set of modules (...) into a custom runtime image.
Optional
.Optional
if no description is availableint run(PrintWriter out, PrintWriter err, String... args)
out
- a stream to which "expected" output should be writtenerr
- a stream to which any error messages should be writtenargs
- the command-line arguments for the toolNullPointerException
- if any of the arguments are null
, or if there are any null
values in the args
arraydefault int run(PrintStream out, PrintStream err, String... args)
out
and err
streams within PrintWriter
s, and then calls run(PrintWriter, PrintWriter, String[])
.out
- a stream to which "expected" output should be writtenerr
- a stream to which any error messages should be writtenargs
- the command-line arguments for the toolNullPointerException
- if any of the arguments are null
, or if there are any null
values in the args
arraystatic Optional<ToolProvider> findFirst(String name)
ToolProvider
with the given name, as loaded by ServiceLoader
using the system class loader.name
- the name of the desired tool providerOptional<ToolProvider>
of the first instance foundNullPointerException
- if name
is null
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/spi/ToolProvider.html