Java Code Examples for com.sun.source.util.JavacTask#analyze()
The following examples show how to use
com.sun.source.util.JavacTask#analyze() .
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: T7043922.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
void compileAndCheck() throws Exception { JavaSource source = new JavaSource(); ErrorChecker ec = new ErrorChecker(); JavacTask ct = (JavacTask)tool.getTask(null, fm, ec, null, null, Arrays.asList(source)); ct.analyze(); if (ec.errorFound) { throw new Error("invalid diagnostics for source:\n" + source.getCharContent(true) + "\nCompiler diagnostics:\n" + ec.printDiags()); } }
Example 2
Source File: DisjunctiveTypeWellFormednessTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public void run() { JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker, null, null, Arrays.asList(source)); try { ct.analyze(); } catch (Throwable t) { processException(t); return; } check(); }
Example 3
Source File: T7142086.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
void run(List<JavaFileObject> sources) throws Exception { DiagnosticChecker dc = new DiagnosticChecker(); JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); JavacTask ct = (JavacTask)comp.getTask(null, fm, dc, null, null, sources); ct.analyze(); }
Example 4
Source File: GenericOverrideTest.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public void run() { JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker, level.opts != null ? Arrays.asList(level.opts) : null, null, Arrays.asList(source)); try { ct.analyze(); } catch (Throwable ex) { throw new AssertionError("Error thrown when compiling the following code:\n" + source.getCharContent(true)); } check(); }
Example 5
Source File: GenericOverrideTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public void run() { JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker, level.opts != null ? Arrays.asList(level.opts) : null, null, Arrays.asList(source)); try { ct.analyze(); } catch (Throwable ex) { throw new AssertionError("Error thrown when compiling the following code:\n" + source.getCharContent(true)); } check(); }
Example 6
Source File: IntersectionTargetTypeTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, null, null, Arrays.asList(source)); try { ct.analyze(); } catch (Throwable ex) { throw new AssertionError("Error thrown when compiling the following code:\n" + source.getCharContent(true)); } check(); }
Example 7
Source File: T7086601b.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, null, null, Arrays.asList(source)); try { ct.analyze(); } catch (Throwable ex) { throw new AssertionError("Error thrown when compiling the following code:\n" + source.getCharContent(true)); } check(); }
Example 8
Source File: T6608214.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws IOException { JavaFileObject sfo = new SimpleJavaFileObject(URI.create(""),Kind.SOURCE) { public CharSequence getCharContent(boolean ignoreEncodingErrors) { return "class Test<S> { <T extends S & Runnable> void test(){}}"; } }; List<? extends JavaFileObject> files = Arrays.asList(sfo); String bootPath = System.getProperty("sun.boot.class.path"); List<String> opts = Arrays.asList("-bootclasspath", bootPath, "-Xjcov"); JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); JavacTask ct = (JavacTask)tool.getTask(null, null, null,opts,null,files); ct.analyze(); }
Example 9
Source File: StructuralMostSpecificTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public void run() { JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker, Arrays.asList("-XDverboseResolution=all,-predef,-internal,-object-init"), null, Arrays.asList(source)); try { ct.analyze(); } catch (Throwable ex) { throw new AssertionError("Error thron when analyzing the following source:\n" + source.getCharContent(true)); } check(); }
Example 10
Source File: SamConversionComboTest.java From hottub with GNU General Public License v2.0 | 5 votes |
void test() throws Exception { System.out.println("\n===================================="); System.out.println(fInterface + ", " + context + ", " + methodReference); System.out.println(samSourceFile + "\n" + clientSourceFile); DiagnosticChecker dc = new DiagnosticChecker(); JavacTask ct = (JavacTask)comp.getTask(null, fm, dc, null, null, Arrays.asList(samSourceFile, clientSourceFile)); ct.analyze(); if (dc.errorFound == checkSamConversion()) { throw new AssertionError(samSourceFile + "\n\n" + clientSourceFile); } count++; }
Example 11
Source File: FDTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, null, null, Arrays.asList(source)); try { ct.analyze(); } catch (Throwable ex) { fail("Error thrown when analyzing the following source:\n" + source.getCharContent(true)); } check(); }
Example 12
Source File: Main.java From hottub with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws IOException { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); JavacTask task = (JavacTask) compiler.getTask(null, null, null, null, null, List.of(new MyFileObject())); trees = Trees.instance(task); Iterable<? extends CompilationUnitTree> asts = task.parse(); task.analyze(); for (CompilationUnitTree ast : asts) { new MyVisitor().scan(ast, null); } }
Example 13
Source File: TestSelfRef.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, null, null, Arrays.asList(source)); try { ct.analyze(); } catch (Throwable ex) { throw new AssertionError("Error thron when compiling the following code:\n" + source.getCharContent(true)); } check(); }
Example 14
Source File: DisjunctiveTypeWellFormednessTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public void run() { JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker, null, null, Arrays.asList(source)); try { ct.analyze(); } catch (Throwable t) { processException(t); return; } check(); }
Example 15
Source File: StructuralMostSpecificTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public void run() { JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker, Arrays.asList("-XDverboseResolution=all,-predef,-internal,-object-init"), null, Arrays.asList(source)); try { ct.analyze(); } catch (Throwable ex) { throw new AssertionError("Error thron when analyzing the following source:\n" + source.getCharContent(true)); } check(); }
Example 16
Source File: IntersectionTargetTypeTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, null, null, Arrays.asList(source)); try { ct.analyze(); } catch (Throwable ex) { throw new AssertionError("Error thrown when compiling the following code:\n" + source.getCharContent(true)); } check(); }
Example 17
Source File: T6608214.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws IOException { JavaFileObject sfo = new SimpleJavaFileObject(URI.create(""),Kind.SOURCE) { public CharSequence getCharContent(boolean ignoreEncodingErrors) { return "class Test<S> { <T extends S & Runnable> void test(){}}"; } }; List<? extends JavaFileObject> files = Arrays.asList(sfo); String bootPath = System.getProperty("sun.boot.class.path"); List<String> opts = Arrays.asList("-bootclasspath", bootPath, "-Xjcov"); JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); JavacTask ct = (JavacTask)tool.getTask(null, null, null,opts,null,files); ct.analyze(); }
Example 18
Source File: InterruptedExceptionTest.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, Arrays.asList(xlint.getXlintOption()), null, Arrays.asList(source)); ct.analyze(); check(); }
Example 19
Source File: ProfileOptionTest.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Test void testTargetProfileCombinations() throws Exception { JavaFileObject fo = new StringJavaFileObject("Test.java", "class Test { }"); for (Target t: Target.values()) { switch (t) { case JDK1_1: case JDK1_2: // no equivalent -source continue; } for (Profile p: Profile.values()) { List<String> opts = new ArrayList<String>(); opts.addAll(Arrays.asList("-source", t.name, "-target", t.name)); opts.add("-Xlint:-options"); // dont warn about no -bootclasspath if (p != Profile.DEFAULT) opts.addAll(Arrays.asList("-profile", p.name)); StringWriter sw = new StringWriter(); JavacTask task = (JavacTask) javac.getTask(sw, fm, null, opts, null, Arrays.asList(fo)); task.analyze(); // sadly, command line errors are not (yet?) reported to // the diag listener String out = sw.toString(); if (!out.isEmpty()) System.err.println(out.trim()); switch (t) { case JDK1_8: if (!out.isEmpty()) error("unexpected output from compiler"); break; default: if (p != Profile.DEFAULT && !out.contains("profile " + p.name + " is not valid for target release " + t.name)) { error("expected message not found"); } } } } }
Example 20
Source File: GenericConstructorAndDiamondTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, null, null, Arrays.asList(source)); ct.analyze(); check(); }