Hi Brett,
I am not sure about the problem you are trying to solve - it seems to work fine at least with Java 6. In both cases, java.util.Date.after(..) should be called, and we store that fact. We do not store the static type of the receiver and arguments of calls yet. This is also something we plan to add soon. With just that additional information however, your query will likely miss cases where only the *dynamic* type of the receiver is Timestamp.
In the meantime, if you want to spot all possible date comparisons, you can try:
class DateCompareMethod extends Method {
DateCompareMethod() {
this.getDeclaringType().hasQualifiedName("java.util","Date") and
(this.hasName("before") or this.hasName("after") or this.hasName("compareTo"))
}
}
from Call c
where c.getCallee() instanceof DateCompareMethod
select c, "Is this comparison correct?"
We first create a special class of methods "DateCompareMethod" that consists of
java.util.Date.after(..), java.util.Date.before(..), java.util.Date.compareTo(..).
Then we search for calls where the callee is one of these methods.
Hope it helps.