[BUGFIX] For some reason, JCLiteral objects contain '1' or '0' (integers) for booleans, not actual booleans. You can tell the difference via the getKind() method. hence, boolean fields in annotations

were throwing unexpected type errors (Integer instead of Boolean). Fixed this.
This commit is contained in:
Reinier Zwitserloot committed 2009-06-27 03:56:33 +02:00
1 parent 18931bec53
commit c4611d669d
1 file changed
+5 -1
+5 -1
View File
@@ -88,7 +88,11 @@ public class Javac {
private static Object calculateGuess(JCExpression expr) {
if ( expr instanceof JCLiteral ) {
return ((JCLiteral)expr).value;
JCLiteral lit = (JCLiteral)expr;
if ( lit.getKind() == com.sun.source.tree.Tree.Kind.BOOLEAN_LITERAL ) {
return ((Number)lit.value).intValue() == 0 ? false : true;
}
return lit.value;
} else if ( expr instanceof JCIdent || expr instanceof JCFieldAccess ) {
String x = expr.toString();
if ( x.endsWith(".class") ) x = x.substring(0, x.length() - 6);