[Checkers] Need a constant value method
Artemus Harper
subanark at gmail.com
Fri Oct 17 01:55:39 EDT 2008
Any chance of adding a method to get the constant value for an expression.
E.g.
public static Object getConstantValue(Tree tree)
{
return ((JCTree)tree).type.constValue();
}
This uses the internal API, so it would be better that such a method be in
InternalUtils. If there is a better way to do this I would like to know.
Currently I'm using this to determine the size of an array:
Object @Size("10") [] array = new Object[5*2];
which would allow me to determine the size even if the size is calculated or
from a constant variable.
...
or
...
public int max(int @Size("!0,*?")[] array) { ... }
Which is a method that takes a non-0 size array. Such method could be called
if the array was annotated to be non-0, or its length was tested to be
non-zero.
--
Artemus Harper
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.csail.mit.edu/mailman/private/checkers/attachments/20081016/9eef3d64/attachment.htm
More information about the checkers
mailing list