It seems that since Mustang b75 the method javax.lang.model.element.TypeElement.getKind() throws unexpected exception for nonexistent type. Please see example below:
===
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.element.TypeElement;
import java.util.Set;
@SupportedAnnotationTypes("*")
public class Test extends AbstractProcessor {
public boolean process(Set<? extends TypeElement> tes,
RoundEnvironment renv) {
System.out.println("kind: " + processingEnv.getElementUtils().
getTypeElement("nOneXisTenT").getKind());
return true;
}
}
===
---------
F:\projects\jck>Z:\lnk\re\jdk\6.0\latest\binaries\windows-i586\bin\javac.exe -cp classes -processor
Test src/Test.java
An annotation processor threw an uncaught exception.
Consult the following stack trace for details.
com.sun.tools.javac.code.Symbol$CompletionFailure: class file for nOneXisTenT not found
Reproduced on jdk6 b75, windows xp, intel i586
---------
It seems this behavior contradicts to spec that says
====
TypeElement getTypeElement(String name)
...
Returns:
the named type element, or null if it cannot be found
===