-
Bug
-
Resolution: Won't Fix
-
P3
-
None
-
6
-
generic, x86
-
generic, windows_xp
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
===
===
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
===
- duplicates
-
JDK-6430209 spurious compiler error elicited by packageElement.getEnclosedElements()
-
- Closed
-
- relates to
-
JDK-6976744 test/tools/javac/processing/6430209/T6430209.java passes incorrectly
-
- Closed
-