test/langtools/tools/javac/lvti/harness/LocalVariableInferenceTester.java
changeset 49294 3556298e481d
parent 47268 48ec75306997
child 49437 9925be430918
equal deleted inserted replaced
49293:9e1c1889136e 49294:3556298e481d
    78     int errors = 0;
    78     int errors = 0;
    79     int checks = 0;
    79     int checks = 0;
    80 
    80 
    81     void compileAndCheck(JavaFileObject input) throws IOException {
    81     void compileAndCheck(JavaFileObject input) throws IOException {
    82         JavaCompiler c = ToolProvider.getSystemJavaCompiler();
    82         JavaCompiler c = ToolProvider.getSystemJavaCompiler();
    83         JavacTask task = (JavacTask) c.getTask(null, fm, null, null, null, Arrays.asList(input));
    83         JavacTask task = (JavacTask) c.getTask(null, fm, null, Arrays.asList("-g"), null, Arrays.asList(input));
    84         JavacTrees trees = JavacTrees.instance(task);
    84         JavacTrees trees = JavacTrees.instance(task);
    85         Types types = Types.instance(((JavacTaskImpl)task).getContext());
    85         Types types = Types.instance(((JavacTaskImpl)task).getContext());
    86         Iterable<? extends CompilationUnitTree> roots = task.parse();
    86         Iterable<? extends CompilationUnitTree> roots = task.parse();
    87         task.analyze(); //force attribution
       
    88         Log log = Log.instance(((JavacTaskImpl)task).getContext());
    87         Log log = Log.instance(((JavacTaskImpl)task).getContext());
       
    88         //force code generation (to shake out non-denotable issues)
       
    89         boolean hasClasses = task.generate().iterator().hasNext();
       
    90         if (!hasClasses) {
       
    91             throw new AssertionError("Errors occurred during compilation!");
       
    92         }
    89         errors += log.nerrors;
    93         errors += log.nerrors;
    90         new LocalVarTypeChecker(trees, types).scan(roots, null);
    94         new LocalVarTypeChecker(trees, types).scan(roots, null);
    91         System.err.println("Checks executed: " + checks);
    95         System.err.println("Checks executed: " + checks);
    92         if (errors != 0) {
    96         if (errors != 0) {
    93             throw new AssertionError("Errors were found");
    97             throw new AssertionError("Errors were found");