Reproducible with JDK 6 or 7:
---%<---
$ cat ProcessorImpl.java UsesGenerated.java
import java.io.IOException;
import java.io.Writer;
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic.Kind;
@SupportedAnnotationTypes("*")
@SupportedSourceVersion(SourceVersion.RELEASE_7)
public class ProcessorImpl extends AbstractProcessor {
boolean ran;
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (roundEnv.processingOver()) {
return false;
}
if (ran) {
return false;
}
try {
Writer w = processingEnv.getFiler().createSourceFile("Generated").openWriter();
w.write("class Generated {}");
w.close();
} catch (IOException x) {
processingEnv.getMessager().printMessage(Kind.ERROR, x.toString());
}
ran = true;
return true;
}
}
public class UsesGenerated {
Generated g;
}
$ javac ProcessorImpl.java
$ javac -J-showversion -processorpath . -processor ProcessorImpl UsesGenerated.java
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)
UsesGenerated.java:2: cannot find symbol
symbol : class Generated
location: class UsesGenerated
Generated g;
^
$ javap -classpath . Generated UsesGenerated
Compiled from "Generated.java"
class Generated extends java.lang.Object{
Generated();
}
Compiled from "UsesGenerated.java"
public class UsesGenerated extends java.lang.Object{
Generated g;
public UsesGenerated();
}
---%<---
The error output from javac makes it look like compilation failed. In fact, everything went normally and all classes have been compiled successfully. "cannot find symbol" errors may be misleading when they are produced before a source-generating annotation processor has run.