-
Bug
-
Resolution: Fixed
-
P3
-
6, 7
-
b74
-
generic
-
generic
-
Not verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2183555 | OpenJDK6 | Joe Darcy | P3 | Resolved | Fixed | b17 |
Elements.getConstantExpression() doesn't throw any exception when argument is not a primitive value or string while the spec states exception throwing.
You may reproduce it using following code:
===
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.TypeElement;
import javax.lang.model.SourceVersion;
import java.util.Set;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion;
@SupportedSourceVersion(SourceVersion.RELEASE_6)
@SupportedAnnotationTypes("*")
public class Proc extends AbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if(roundEnv.processingOver()) {
System.out.println("object: " + processingEnv.getElementUtils().getConstantExpression(new Object()));
}
return true;
}
}
===
The result is like this:
# javac -processor tmp.Proc java.lang.Object
object: java.lang.Object@ab853b
Failed test:
api/javax_lang/model/util/Elements/index.html#GetConstantExpression0002
You may reproduce it using following code:
===
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.TypeElement;
import javax.lang.model.SourceVersion;
import java.util.Set;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion;
@SupportedSourceVersion(SourceVersion.RELEASE_6)
@SupportedAnnotationTypes("*")
public class Proc extends AbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if(roundEnv.processingOver()) {
System.out.println("object: " + processingEnv.getElementUtils().getConstantExpression(new Object()));
}
return true;
}
}
===
The result is like this:
# javac -processor tmp.Proc java.lang.Object
object: java.lang.Object@ab853b
Failed test:
api/javax_lang/model/util/Elements/index.html#GetConstantExpression0002
- backported by
-
JDK-2183555 javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
-
- Resolved
-
- relates to
-
JDK-6517907 javax.lang.model.util.Elements.getConstantExpression() with negative byte value fails
-
- Closed
-