javax.tools.Tool Java Examples
The following examples show how to use
javax.tools.Tool.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: T6395981.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String... args) { Tool compiler = ToolProvider.getSystemJavaCompiler(); Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class); for (String arg : args) expected.add(SourceVersion.valueOf(arg)); Set<SourceVersion> found = compiler.getSourceVersions(); Set<SourceVersion> notExpected = EnumSet.copyOf(found); for (SourceVersion version : expected) { if (!found.contains(version)) throw new AssertionError("Expected source version not found: " + version); else notExpected.remove(version); } if (!notExpected.isEmpty()) throw new AssertionError("Unexpected source versions: " + notExpected); }
Example #2
Source File: T6395981.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public static void main(String... args) { Tool compiler = ToolProvider.getSystemJavaCompiler(); Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class); for (String arg : args) expected.add(SourceVersion.valueOf(arg)); Set<SourceVersion> found = compiler.getSourceVersions(); Set<SourceVersion> notExpected = EnumSet.copyOf(found); for (SourceVersion version : expected) { if (!found.contains(version)) throw new AssertionError("Expected source version not found: " + version); else notExpected.remove(version); } if (!notExpected.isEmpty()) throw new AssertionError("Unexpected source versions: " + notExpected); }
Example #3
Source File: T6395981.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String... args) { Tool compiler = ToolProvider.getSystemJavaCompiler(); Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class); for (String arg : args) expected.add(SourceVersion.valueOf(arg)); Set<SourceVersion> found = compiler.getSourceVersions(); Set<SourceVersion> notExpected = EnumSet.copyOf(found); for (SourceVersion version : expected) { if (!found.contains(version)) throw new AssertionError("Expected source version not found: " + version); else notExpected.remove(version); } if (!notExpected.isEmpty()) throw new AssertionError("Unexpected source versions: " + notExpected); }
Example #4
Source File: T6395981.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(String... args) { Tool compiler = ToolProvider.getSystemJavaCompiler(); Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class); for (String arg : args) expected.add(SourceVersion.valueOf(arg)); Set<SourceVersion> found = compiler.getSourceVersions(); Set<SourceVersion> notExpected = EnumSet.copyOf(found); for (SourceVersion version : expected) { if (!found.contains(version)) throw new AssertionError("Expected source version not found: " + version); else notExpected.remove(version); } if (!notExpected.isEmpty()) throw new AssertionError("Unexpected source versions: " + notExpected); }
Example #5
Source File: T6395981.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static void main(String... args) { Tool compiler = ToolProvider.getSystemJavaCompiler(); Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class); for (String arg : args) expected.add(SourceVersion.valueOf(arg)); Set<SourceVersion> found = compiler.getSourceVersions(); Set<SourceVersion> notExpected = EnumSet.copyOf(found); for (SourceVersion version : expected) { if (!found.contains(version)) throw new AssertionError("Expected source version not found: " + version); else notExpected.remove(version); } if (!notExpected.isEmpty()) throw new AssertionError("Unexpected source versions: " + notExpected); }
Example #6
Source File: T6395981.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public static void main(String... args) { Tool compiler = ToolProvider.getSystemJavaCompiler(); Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class); for (String arg : args) expected.add(SourceVersion.valueOf(arg)); Set<SourceVersion> found = compiler.getSourceVersions(); Set<SourceVersion> notExpected = EnumSet.copyOf(found); for (SourceVersion version : expected) { if (!found.contains(version)) throw new AssertionError("Expected source version not found: " + version); else notExpected.remove(version); } if (!notExpected.isEmpty()) throw new AssertionError("Unexpected source versions: " + notExpected); }
Example #7
Source File: T6395981.java From hottub with GNU General Public License v2.0 | 6 votes |
public static void main(String... args) { Tool compiler = ToolProvider.getSystemJavaCompiler(); Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class); for (String arg : args) expected.add(SourceVersion.valueOf(arg)); Set<SourceVersion> found = compiler.getSourceVersions(); Set<SourceVersion> notExpected = EnumSet.copyOf(found); for (SourceVersion version : expected) { if (!found.contains(version)) throw new AssertionError("Expected source version not found: " + version); else notExpected.remove(version); } if (!notExpected.isEmpty()) throw new AssertionError("Unexpected source versions: " + notExpected); }
Example #8
Source File: T6395981.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String... args) { Tool compiler = ToolProvider.getSystemJavaCompiler(); Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class); for (String arg : args) expected.add(SourceVersion.valueOf(arg)); Set<SourceVersion> found = compiler.getSourceVersions(); Set<SourceVersion> notExpected = EnumSet.copyOf(found); for (SourceVersion version : expected) { if (!found.contains(version)) throw new AssertionError("Expected source version not found: " + version); else notExpected.remove(version); } if (!notExpected.isEmpty()) throw new AssertionError("Unexpected source versions: " + notExpected); }
Example #9
Source File: JShellWrapper.java From pro with GNU General Public License v3.0 | 5 votes |
static int run(InputStream in, OutputStream out, OutputStream err, String... arguments) { var loader = ServiceLoader.load(Tool.class, JShellConfigRunner.class.getClassLoader()); var jshell = loader.stream() .map(provider -> provider.get()) .filter(tool -> tool.name().equals("jshell")) .findFirst() .orElseThrow(() -> new IllegalStateException("can not find jshell")); return jshell.run(in, out, err, arguments); }
Example #10
Source File: T6350124.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
static void compile(String... args) { StringBuffer sb = new StringBuffer("compile:"); for (String a: args) sb.append(' ').append(a); System.err.println(sb); Tool t = ToolProvider.getSystemJavaCompiler(); int rc = t.run(System.in, System.out, System.err, args); System.out.flush(); System.err.flush(); if (rc != 0) throw new Error("compilation failed"); }
Example #11
Source File: T6350124.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
static void compile(String... args) { StringBuffer sb = new StringBuffer("compile:"); for (String a: args) sb.append(' ').append(a); System.err.println(sb); Tool t = ToolProvider.getSystemJavaCompiler(); int rc = t.run(System.in, System.out, System.err, args); System.out.flush(); System.err.flush(); if (rc != 0) throw new Error("compilation failed"); }
Example #12
Source File: T6350124.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
static void compile(String... args) { StringBuffer sb = new StringBuffer("compile:"); for (String a: args) sb.append(' ').append(a); System.err.println(sb); Tool t = ToolProvider.getSystemJavaCompiler(); int rc = t.run(System.in, System.out, System.err, args); System.out.flush(); System.err.flush(); if (rc != 0) throw new Error("compilation failed"); }
Example #13
Source File: T6350124.java From hottub with GNU General Public License v2.0 | 5 votes |
static void compile(String... args) { StringBuffer sb = new StringBuffer("compile:"); for (String a: args) sb.append(' ').append(a); System.err.println(sb); Tool t = ToolProvider.getSystemJavaCompiler(); int rc = t.run(System.in, System.out, System.err, args); System.out.flush(); System.err.flush(); if (rc != 0) throw new Error("compilation failed"); }
Example #14
Source File: TestName.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
Optional<Tool> findFirst(String name) { getClass().getModule().addUses(Tool.class); for (Tool p : ServiceLoader.load(Tool.class, ClassLoader.getSystemClassLoader())) { if (p.name().equals(name)) { return Optional.of(p); } } return Optional.empty(); }
Example #15
Source File: TestName.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void run() throws Exception { Optional<Tool> opt = findFirst("javac"); if (!opt.isPresent()) { throw new Exception("tool not found"); } if (!(opt.get() instanceof JavacTool)) { throw new Exception("unexpected tool found"); } }
Example #16
Source File: T6350124.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
static void compile(String... args) { StringBuffer sb = new StringBuffer("compile:"); for (String a: args) sb.append(' ').append(a); System.err.println(sb); Tool t = ToolProvider.getSystemJavaCompiler(); int rc = t.run(System.in, System.out, System.err, args); System.out.flush(); System.err.flush(); if (rc != 0) throw new Error("compilation failed"); }
Example #17
Source File: ToolProviderTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private int runShellServiceLoader(String... args) { ServiceLoader<Tool> sl = ServiceLoader.load(Tool.class); for (Tool provider : sl) { if (provider.name().equals("jshell")) { return provider.run(cmdInStream, cmdout, cmderr, args); } } throw new AssertionError("Repl tool not found by ServiceLoader: " + sl); }
Example #18
Source File: TestName.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
Optional<Tool> findFirst(String name) { getClass().getModule().addUses(Tool.class); for (Tool p : ServiceLoader.load(Tool.class, ClassLoader.getSystemClassLoader())) { if (p.name().equals(name)) { return Optional.of(p); } } return Optional.empty(); }
Example #19
Source File: TestName.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void run() throws Exception { Optional<Tool> opt = findFirst("javadoc"); if (!opt.isPresent()) { throw new Exception("tool not found"); } if (!(opt.get() instanceof JavadocTool)) { throw new Exception("unexpected tool found"); } }
Example #20
Source File: T6350124.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static void compile(String... args) { StringBuffer sb = new StringBuffer("compile:"); for (String a: args) sb.append(' ').append(a); System.err.println(sb); Tool t = ToolProvider.getSystemJavaCompiler(); int rc = t.run(System.in, System.out, System.err, args); System.out.flush(); System.err.flush(); if (rc != 0) throw new Error("compilation failed"); }
Example #21
Source File: T6350124.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
static void compile(String... args) { StringBuffer sb = new StringBuffer("compile:"); for (String a: args) sb.append(' ').append(a); System.err.println(sb); Tool t = ToolProvider.getSystemJavaCompiler(); int rc = t.run(System.in, System.out, System.err, args); System.out.flush(); System.err.flush(); if (rc != 0) throw new Error("compilation failed"); }
Example #22
Source File: T6350124.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
static void compile(String... args) { StringBuffer sb = new StringBuffer("compile:"); for (String a: args) sb.append(' ').append(a); System.err.println(sb); Tool t = ToolProvider.getSystemJavaCompiler(); int rc = t.run(System.in, System.out, System.err, args); System.out.flush(); System.err.flush(); if (rc != 0) throw new Error("compilation failed"); }