Issue with symbol completion failures during the final round of annotation processing

Liam Miller-Cushon cushon at
Mon Oct 20 20:23:37 UTC 2014

I encountered an issue that causes symbol completion failures to be ignored
during the final round of annotation processing. A diagnostic is printed to
stderr, but the compilation still finishes with a 0 exit code.

Is this a known issue? It affects javac 6, 7, and 8. It does not affect
javac 9, probably thanks to JDK-8038455.

Here's the repro:

$ javac -cp $JAVA_HOME/lib/tools.jar
$ javac -cp $JAVA_HOME/lib/tools.jar:. -processor
error: cannot access Test
  Consult the following stack trace for details.$CompletionFailure:
$ echo $?

=== ===
class Test {}

=== ===
import java.util.Set;

import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;


public class CompletionFailureProcessor extends AbstractProcessor {

  public SourceVersion getSupportedSourceVersion() {
    return SourceVersion.latest();

  Element element;

  public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {

    if (roundEnv.getRootElements().isEmpty()) {
      // last round has no root elements
      throw new Symbol.CompletionFailure((Symbol) element, "");
    } else {
      // save an element for constructing the CompletionFailure next round
      element = roundEnv.getRootElements().iterator().next();

    return false;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the compiler-dev mailing list