-
Bug
-
Resolution: Fixed
-
P3
-
6
-
None
-
b74
-
generic
-
generic
-
Not verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2183556 | OpenJDK6 | Joe Darcy | P3 | Resolved | Fixed | b17 |
javax.lang.model.util.Elements.getConstantExpression() and negative argument value like 0xfd cause invalid string result "0xfd". While java.lang.Byte.decode("0xfd") and byte assignment like byte b = 0xfd cause to either exception or compiling error.
You may reproduce it using following code:
===
package tmp;
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()) {
byte b = -3;
System.out.println("byte: " + processingEnv.getElementUtils().getConstantExpression(b));
}
return true;
}
}
===
The result is like this:
# javac -processor tmp.Proc java.lang.Object
byte: 0xfd
You may reproduce it using following code:
===
package tmp;
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()) {
byte b = -3;
System.out.println("byte: " + processingEnv.getElementUtils().getConstantExpression(b));
}
return true;
}
}
===
The result is like this:
# javac -processor tmp.Proc java.lang.Object
byte: 0xfd
- backported by
-
JDK-2183556 javax.lang.model.util.Elements.getConstantExpression() with negative byte value fails
-
- Resolved
-
- relates to
-
JDK-6517779 javax.lang.model.util.Elements.getConstantExpression() doesn't throw any exception
-
- Closed
-