com.sun.source.util.TaskEvent Java Examples

The following examples show how to use com.sun.source.util.TaskEvent. 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: JavaCompiler.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check if we should process annotations.
 * If so, and if no scanner is yet registered, then set up the DocCommentScanner
 * to catch doc comments, and set keepComments so the parser records them in
 * the compilation unit.
 *
 * @param processors user provided annotation processors to bypass
 * discovery, {@code null} means that no processors were provided
 */
public void initProcessAnnotations(Iterable<? extends Processor> processors) {
    // Process annotations if processing is not disabled and there
    // is at least one Processor available.
    if (options.isSet(PROC, "none")) {
        processAnnotations = false;
    } else if (procEnvImpl == null) {
        procEnvImpl = JavacProcessingEnvironment.instance(context);
        procEnvImpl.setProcessors(processors);
        processAnnotations = procEnvImpl.atLeastOneProcessor();

        if (processAnnotations) {
            options.put("save-parameter-names", "save-parameter-names");
            reader.saveParameterNames = true;
            keepComments = true;
            genEndPos = true;
            if (!taskListener.isEmpty())
                taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING));
            deferredDiagnosticHandler = new Log.DeferredDiagnosticHandler(log);
        } else { // free resources
            procEnvImpl.close();
        }
    }
}
 
Example #2
Source File: JavaCompiler.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check if we should process annotations.
 * If so, and if no scanner is yet registered, then set up the DocCommentScanner
 * to catch doc comments, and set keepComments so the parser records them in
 * the compilation unit.
 *
 * @param processors user provided annotation processors to bypass
 * discovery, {@code null} means that no processors were provided
 */
public void initProcessAnnotations(Iterable<? extends Processor> processors) {
    // Process annotations if processing is not disabled and there
    // is at least one Processor available.
    if (options.isSet(PROC, "none")) {
        processAnnotations = false;
    } else if (procEnvImpl == null) {
        procEnvImpl = JavacProcessingEnvironment.instance(context);
        procEnvImpl.setProcessors(processors);
        processAnnotations = procEnvImpl.atLeastOneProcessor();

        if (processAnnotations) {
            options.put("save-parameter-names", "save-parameter-names");
            reader.saveParameterNames = true;
            keepComments = true;
            genEndPos = true;
            if (!taskListener.isEmpty())
                taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING));
            deferredDiagnosticHandler = new Log.DeferredDiagnosticHandler(log);
        } else { // free resources
            procEnvImpl.close();
        }
    }
}
 
Example #3
Source File: PackageProcessor.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void finished(TaskEvent e) {
    if (e.getKind() != TaskEvent.Kind.ANALYZE)
        return;

    if (!elements.remove(e.getTypeElement().getQualifiedName()))
        return;

    if (e.getTypeElement().getSimpleName().contentEquals("MyClass")) {
        Element owner = e.getTypeElement().getEnclosingElement();
        if (owner.getKind() != ElementKind.PACKAGE)
            throw new RuntimeException("class owner should be a package: " + owner);
        if (owner.getAnnotationMirrors().size() != 1)
            throw new RuntimeException("the owner package should have one annotation: " + owner);
    }
}
 
Example #4
Source File: AbstractCodingRulesAnalyzer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void finished(TaskEvent taskEvent) {
    if (taskEvent.getKind().equals(eventKind)) {
        TypeElement typeElem = taskEvent.getTypeElement();
        Tree tree = trees.getTree(typeElem);
        if (tree != null) {
            JavaFileObject prevSource = log.currentSourceFile();
            try {
                log.useSource(taskEvent.getCompilationUnit().getSourceFile());
                treeVisitor.scan((JCTree)tree);
            } finally {
                log.useSource(prevSource);
            }
        }
    }
}
 
Example #5
Source File: TestSimpleAddRemove.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
//            System.err.println("TestProcessor.process " + roundEnv);
            JavacTask task = JavacTask.instance(processingEnv);
            if (++round == 1) {
                switch (ak) {
                    case ADD_IN_PROCESSOR:
                        task.addTaskListener(listener);
                        break;
                    case ADD_IN_LISTENER:
                        addInListener(task, TaskEvent.Kind.ANALYZE, listener);
                        break;
                }
            } else if (roundEnv.processingOver()) {
                switch (rk) {
                    case REMOVE_IN_PROCESSOR:
                        task.removeTaskListener(listener);
                        break;
                    case REMOVE_IN_LISTENER:
                        removeInListener(task, TaskEvent.Kind.GENERATE, listener);
                        break;
                }
            }
            return true;
        }
 
Example #6
Source File: TestSimpleAddRemove.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
//            System.err.println("TestProcessor.process " + roundEnv);
            JavacTask task = JavacTask.instance(processingEnv);
            if (++round == 1) {
                switch (ak) {
                    case ADD_IN_PROCESSOR:
                        task.addTaskListener(listener);
                        break;
                    case ADD_IN_LISTENER:
                        addInListener(task, TaskEvent.Kind.ANALYZE, listener);
                        break;
                }
            } else if (roundEnv.processingOver()) {
                switch (rk) {
                    case REMOVE_IN_PROCESSOR:
                        task.removeTaskListener(listener);
                        break;
                    case REMOVE_IN_LISTENER:
                        removeInListener(task, TaskEvent.Kind.GENERATE, listener);
                        break;
                }
            }
            return true;
        }
 
Example #7
Source File: JavacPlugin.java    From manifold with Apache License 2.0 6 votes vote down vote up
private void addInputFile( TaskEvent e )
{
  if( !_initialized )
  {
    CompilationUnitTree compilationUnit = e.getCompilationUnit();
    ExpressionTree pkg = compilationUnit.getPackageName();
    String packageQualifier = pkg == null ? "" : (pkg.toString() + '.');
    for( Tree classDecl : compilationUnit.getTypeDecls() )
    {
      if( classDecl instanceof JCTree.JCClassDecl )
      {
        _javaInputFiles.add( new Pair<>( packageQualifier + ((JCTree.JCClassDecl)classDecl).getSimpleName(), compilationUnit.getSourceFile() ) );
      }
    }
  }
}
 
Example #8
Source File: AbstractCodingRulesAnalyzer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void finished(TaskEvent taskEvent) {
    if (taskEvent.getKind().equals(eventKind)) {
        TypeElement typeElem = taskEvent.getTypeElement();
        Tree tree = trees.getTree(typeElem);
        if (tree != null) {
            JavaFileObject prevSource = log.currentSourceFile();
            try {
                log.useSource(taskEvent.getCompilationUnit().getSourceFile());
                treeVisitor.scan((JCTree)tree);
            } finally {
                log.useSource(prevSource);
            }
        }
    }
}
 
Example #9
Source File: TestSimpleAddRemove.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
//            System.err.println("TestProcessor.process " + roundEnv);
            JavacTask task = JavacTask.instance(processingEnv);
            if (++round == 1) {
                switch (ak) {
                    case ADD_IN_PROCESSOR:
                        task.addTaskListener(listener);
                        break;
                    case ADD_IN_LISTENER:
                        addInListener(task, TaskEvent.Kind.ANALYZE, listener);
                        break;
                }
            } else if (roundEnv.processingOver()) {
                switch (rk) {
                    case REMOVE_IN_PROCESSOR:
                        task.removeTaskListener(listener);
                        break;
                    case REMOVE_IN_LISTENER:
                        removeInListener(task, TaskEvent.Kind.GENERATE, listener);
                        break;
                }
            }
            return true;
        }
 
Example #10
Source File: CodingRulesAnalyzerPlugin.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override @DefinedBy(Api.COMPILER_TREE)
public void finished(TaskEvent taskEvent) {
    List<AbstractCodingRulesAnalyzer> currentAnalyzers = this.analyzers.get(taskEvent.getKind());

    if (currentAnalyzers != null) {
        TypeElement typeElem = taskEvent.getTypeElement();
        Tree tree = trees.getTree(typeElem);
        if (tree != null) {
            JavaFileObject prevSource = log.currentSourceFile();
            try {
                log.useSource(taskEvent.getCompilationUnit().getSourceFile());
                for (AbstractCodingRulesAnalyzer analyzer : currentAnalyzers) {
                    analyzer.treeVisitor.scan((JCTree)tree);
                }
            } finally {
                log.useSource(prevSource);
            }
        }
    }
}
 
Example #11
Source File: JavacPlugin.java    From manifold with Apache License 2.0 6 votes vote down vote up
@Override
public void finished( TaskEvent e )
{
  switch( e.getKind() )
  {
    case PARSE:
    {
      addInputFile( e );
      break;
    }

    case ENTER:
      process( e );
      break;
  }
}
 
Example #12
Source File: JavaCompiler.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check if we should process annotations.
 * If so, and if no scanner is yet registered, then set up the DocCommentScanner
 * to catch doc comments, and set keepComments so the parser records them in
 * the compilation unit.
 *
 * @param processors user provided annotation processors to bypass
 * discovery, {@code null} means that no processors were provided
 */
public void initProcessAnnotations(Iterable<? extends Processor> processors) {
    // Process annotations if processing is not disabled and there
    // is at least one Processor available.
    if (options.isSet(PROC, "none")) {
        processAnnotations = false;
    } else if (procEnvImpl == null) {
        procEnvImpl = JavacProcessingEnvironment.instance(context);
        procEnvImpl.setProcessors(processors);
        processAnnotations = procEnvImpl.atLeastOneProcessor();

        if (processAnnotations) {
            options.put("save-parameter-names", "save-parameter-names");
            reader.saveParameterNames = true;
            keepComments = true;
            genEndPos = true;
            if (!taskListener.isEmpty())
                taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING));
            deferredDiagnosticHandler = new Log.DeferredDiagnosticHandler(log);
        } else { // free resources
            procEnvImpl.close();
        }
    }
}
 
Example #13
Source File: ErrorPronePlugin.java    From bazel with Apache License 2.0 5 votes vote down vote up
/** Run Error Prone analysis after performing dataflow checks. */
@Override
public void postFlow(Env<AttrContext> env) {
  elapsed.start();
  try {
    errorProneAnalyzer.finished(new TaskEvent(Kind.ANALYZE, env.toplevel, env.enclClass.sym));
  } catch (ErrorProneError e) {
    e.logFatalError(log);
    // let the exception propagate to javac's main, where it will cause the compilation to
    // terminate with Result.ABNORMAL
    throw e;
  } finally {
    elapsed.stop();
  }
}
 
Example #14
Source File: JavacProcessingEnvironment.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/** Run a processing round. */
void run(boolean lastRound, boolean errorStatus) {
    printRoundInfo(lastRound);

    TaskListener taskListener = context.get(TaskListener.class);
    if (taskListener != null)
        taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND));

    try {
        if (lastRound) {
            filer.setLastRound(true);
            Set<Element> emptyRootElements = Collections.emptySet(); // immutable
            RoundEnvironment renv = new JavacRoundEnvironment(true,
                    errorStatus,
                    emptyRootElements,
                    JavacProcessingEnvironment.this);
            discoveredProcs.iterator().runContributingProcs(renv);
        } else {
            discoverAndRunProcs(context, annotationsPresent, topLevelClasses, packageInfoFiles);
        }
    } finally {
        if (taskListener != null)
            taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND));
    }

    nMessagerErrors = messager.errorCount();
}
 
Example #15
Source File: MultiTaskListener.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void started(TaskEvent e) {
    // guard against listeners being updated by a listener
    TaskListener[] ll = this.listeners;
    for (TaskListener l: ll)
        l.started(e);
}
 
Example #16
Source File: JavaCompiler.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Attribute a parse tree.
 * @return the attributed parse tree
 */
public Env<AttrContext> attribute(Env<AttrContext> env) {
    if (compileStates.isDone(env, CompileState.ATTR))
        return env;

    if (verboseCompilePolicy)
        printNote("[attribute " + env.enclClass.sym + "]");
    if (verbose)
        log.printVerbose("checking.attribution", env.enclClass.sym);

    if (!taskListener.isEmpty()) {
        TaskEvent e = new TaskEvent(TaskEvent.Kind.ANALYZE, env.toplevel, env.enclClass.sym);
        taskListener.started(e);
    }

    JavaFileObject prev = log.useSource(
                              env.enclClass.sym.sourcefile != null ?
                              env.enclClass.sym.sourcefile :
                              env.toplevel.sourcefile);
    try {
        attr.attrib(env);
        if (errorCount() > 0 && !shouldStop(CompileState.ATTR)) {
            //if in fail-over mode, ensure that AST expression nodes
            //are correctly initialized (e.g. they have a type/symbol)
            attr.postAttr(env.tree);
        }
        compileStates.put(env, CompileState.ATTR);
    }
    finally {
        log.useSource(prev);
    }

    return env;
}
 
Example #17
Source File: ValidatingTaskListener.java    From buck with Apache License 2.0 5 votes vote down vote up
@Override
public void started(TaskEvent e) {
  TaskEvent.Kind kind = e.getKind();

  if (kind == TaskEvent.Kind.ENTER) {
    enterDepth += 1;
  } else if (kind == TaskEvent.Kind.ANNOTATION_PROCESSING) {
    annotationProcessing = true;
  }
}
 
Example #18
Source File: JavaCompiler.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Attribute a parse tree.
 * @return the attributed parse tree
 */
public Env<AttrContext> attribute(Env<AttrContext> env) {
    if (compileStates.isDone(env, CompileState.ATTR))
        return env;

    if (verboseCompilePolicy)
        printNote("[attribute " + env.enclClass.sym + "]");
    if (verbose)
        log.printVerbose("checking.attribution", env.enclClass.sym);

    if (!taskListener.isEmpty()) {
        TaskEvent e = new TaskEvent(TaskEvent.Kind.ANALYZE, env.toplevel, env.enclClass.sym);
        taskListener.started(e);
    }

    JavaFileObject prev = log.useSource(
                              env.enclClass.sym.sourcefile != null ?
                              env.enclClass.sym.sourcefile :
                              env.toplevel.sourcefile);
    try {
        attr.attrib(env);
        if (errorCount() > 0 && !shouldStop(CompileState.ATTR)) {
            //if in fail-over mode, ensure that AST expression nodes
            //are correctly initialized (e.g. they have a type/symbol)
            attr.postAttr(env.tree);
        }
        compileStates.put(env, CompileState.ATTR);
    }
    finally {
        log.useSource(prev);
    }

    return env;
}
 
Example #19
Source File: MultiTaskListener.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void started(TaskEvent e) {
    // guard against listeners being updated by a listener
    TaskListener[] ll = this.listeners;
    for (TaskListener l: ll)
        l.started(e);
}
 
Example #20
Source File: JavacProcessingEnvironment.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/** Run a processing round. */
void run(boolean lastRound, boolean errorStatus) {
    printRoundInfo(lastRound);

    if (!taskListener.isEmpty())
        taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND));

    try {
        if (lastRound) {
            filer.setLastRound(true);
            Set<Element> emptyRootElements = Collections.emptySet(); // immutable
            RoundEnvironment renv = new JavacRoundEnvironment(true,
                    errorStatus,
                    emptyRootElements,
                    JavacProcessingEnvironment.this);
            discoveredProcs.iterator().runContributingProcs(renv);
        } else {
            discoverAndRunProcs(context, annotationsPresent, topLevelClasses, packageInfoFiles);
        }
    } catch (Throwable t) {
        // we're specifically expecting Abort here, but if any Throwable
        // comes by, we should flush all deferred diagnostics, rather than
        // drop them on the ground.
        deferredDiagnosticHandler.reportDeferredDiagnostics();
        log.popDiagnosticHandler(deferredDiagnosticHandler);
        throw t;
    } finally {
        if (!taskListener.isEmpty())
            taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND));
    }
}
 
Example #21
Source File: JavaCompiler.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Check if we should process annotations.
 * If so, and if no scanner is yet registered, then set up the DocCommentScanner
 * to catch doc comments, and set keepComments so the parser records them in
 * the compilation unit.
 *
 * @param processors user provided annotation processors to bypass
 * discovery, {@code null} means that no processors were provided
 */
public void initProcessAnnotations(Iterable<? extends Processor> processors,
                                   Collection<? extends JavaFileObject> initialFiles,
                                   Collection<String> initialClassNames) {
    // Process annotations if processing is not disabled and there
    // is at least one Processor available.
    if (options.isSet(PROC, "none")) {
        processAnnotations = false;
    } else if (procEnvImpl == null) {
        procEnvImpl = JavacProcessingEnvironment.instance(context);
        procEnvImpl.setProcessors(processors);
        processAnnotations = procEnvImpl.atLeastOneProcessor();

        if (processAnnotations) {
            options.put("parameters", "parameters");
            reader.saveParameterNames = true;
            keepComments = true;
            genEndPos = true;
            if (!taskListener.isEmpty())
                taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING));
            deferredDiagnosticHandler = new Log.DeferredDiagnosticHandler(log);
            procEnvImpl.getFiler().setInitialState(initialFiles, initialClassNames);
        } else { // free resources
            procEnvImpl.close();
        }
    }
}
 
Example #22
Source File: NewDependencyCollector.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
@DefinedBy(Api.COMPILER_TREE)
public void finished(TaskEvent e) {
    if (e.getKind() == TaskEvent.Kind.COMPILATION) {
        collectPubApisOfDependencies(context, explicitJFOs);
        deps = getDependencies(context, explicitJFOs, false);
        cpDeps = getDependencies(context, explicitJFOs, true);
    }
}
 
Example #23
Source File: TypeProcOnly.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void finished(TaskEvent e) {
    if (e.getKind() != TaskEvent.Kind.ANALYZE)
        return;

    if (!elements.remove(e.getTypeElement().getQualifiedName()))
        return;

    System.out.println(INDICATOR);
}
 
Example #24
Source File: TypeProcOnly.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void finished(TaskEvent e) {
    if (e.getKind() != TaskEvent.Kind.ANALYZE)
        return;

    if (!elements.remove(e.getTypeElement().getQualifiedName()))
        return;

    System.out.println(INDICATOR);
}
 
Example #25
Source File: TestSimpleAddRemove.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
void inc(TaskEvent.Kind k, boolean started) {
    Count c = get(k);
    if (c == null)
        put(k, c = new Count());

    if (started)
        c.started++;
    else
        c.finished++;
}
 
Example #26
Source File: JavaCompiler.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Attribute a parse tree.
 * @returns the attributed parse tree
 */
public Env<AttrContext> attribute(Env<AttrContext> env) {
    if (compileStates.isDone(env, CompileState.ATTR))
        return env;

    if (verboseCompilePolicy)
        printNote("[attribute " + env.enclClass.sym + "]");
    if (verbose)
        log.printVerbose("checking.attribution", env.enclClass.sym);

    if (!taskListener.isEmpty()) {
        TaskEvent e = new TaskEvent(TaskEvent.Kind.ANALYZE, env.toplevel, env.enclClass.sym);
        taskListener.started(e);
    }

    JavaFileObject prev = log.useSource(
                              env.enclClass.sym.sourcefile != null ?
                              env.enclClass.sym.sourcefile :
                              env.toplevel.sourcefile);
    try {
        attr.attrib(env);
        if (errorCount() > 0 && !shouldStop(CompileState.ATTR)) {
            //if in fail-over mode, ensure that AST expression nodes
            //are correctly initialized (e.g. they have a type/symbol)
            attr.postAttr(env.tree);
        }
        compileStates.put(env, CompileState.ATTR);
        if (rootClasses != null && rootClasses.contains(env.enclClass)) {
            // This was a class that was explicitly supplied for compilation.
            // If we want to capture the public api of this class,
            // then now is a good time to do it.
            reportPublicApi(env.enclClass.sym);
        }
    }
    finally {
        log.useSource(prev);
    }

    return env;
}
 
Example #27
Source File: JavaCompiler.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Attribute a parse tree.
 *
 * @returns the attributed parse tree
 */
public Env<AttrContext> attribute(Env<AttrContext> env) {
    if (compileStates.isDone(env, CompileState.ATTR))
        return env;

    if (verboseCompilePolicy)
        printNote("[attribute " + env.enclClass.sym + "]");
    if (verbose)
        log.printVerbose("checking.attribution", env.enclClass.sym);

    if (taskListener != null) {
        TaskEvent e = new TaskEvent(TaskEvent.Kind.ANALYZE, env.toplevel, env.enclClass.sym);
        taskListener.started(e);
    }

    JavaFileObject prev = log.useSource(
            env.enclClass.sym.sourcefile != null ?
                    env.enclClass.sym.sourcefile :
                    env.toplevel.sourcefile);
    try {
        attr.attrib(env);
        if (errorCount() > 0 && !shouldStop(CompileState.ATTR)) {
            //if in fail-over mode, ensure that AST expression nodes
            //are correctly initialized (e.g. they have a type/symbol)
            attr.postAttr(env);
        }
        compileStates.put(env, CompileState.ATTR);
    } finally {
        log.useSource(prev);
    }

    return env;
}
 
Example #28
Source File: TypeProcOnly.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void finished(TaskEvent e) {
    if (e.getKind() != TaskEvent.Kind.ANALYZE)
        return;

    if (!elements.remove(e.getTypeElement().getQualifiedName()))
        return;

    System.out.println(INDICATOR);
}
 
Example #29
Source File: JavacProcessingEnvironment.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/** Run a processing round. */
void run(boolean lastRound, boolean errorStatus) {
    printRoundInfo(lastRound);

    if (!taskListener.isEmpty())
        taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND));

    try {
        if (lastRound) {
            filer.setLastRound(true);
            Set<Element> emptyRootElements = Collections.emptySet(); // immutable
            RoundEnvironment renv = new JavacRoundEnvironment(true,
                    errorStatus,
                    emptyRootElements,
                    JavacProcessingEnvironment.this);
            discoveredProcs.iterator().runContributingProcs(renv);
        } else {
            discoverAndRunProcs(context, annotationsPresent, topLevelClasses, packageInfoFiles);
        }
    } catch (Throwable t) {
        // we're specifically expecting Abort here, but if any Throwable
        // comes by, we should flush all deferred diagnostics, rather than
        // drop them on the ground.
        deferredDiagnosticHandler.reportDeferredDiagnostics();
        log.popDiagnosticHandler(deferredDiagnosticHandler);
        throw t;
    } finally {
        if (!taskListener.isEmpty())
            taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND));
    }
}
 
Example #30
Source File: MultiTaskListener.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void started(TaskEvent e) {
    // guard against listeners being updated by a listener
    TaskListener[] ll = this.listeners;
    for (TaskListener l: ll)
        l.started(e);
}