November 20, 2008, 11:50:13 am *
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Transitive Closure  (Read 737 times)
prademak
Newbie
*
Posts: 2


« on: January 23, 2008, 04:02:17 pm »

This doesn't fully qualify for a "cool query", but I'm not sure where else to post this:

I'm playing around with SemmleCode and I was wondering how you could make SemmleCode compute the transitive closure for the whole Call relation.

Would that be something like this?

from Call c
select c.getCaller+() 

I know this isn't a very useful query, but I just would like to know if I understand SemmleCode correctly..
Logged
Oege de Moor
Newbie
*
Posts: 30


« Reply #1 on: January 25, 2008, 09:58:41 am »

Thanks for your interest.

Of course it's a cool query!

The version you've given below is however not the most useful form: usually one is interested in polymorphic calls, so when the tool sees a call like "foo.bar()" you get not only the method "bar" in the static type of "foo", but also all its overrides in subclasses. To get that behaviour, you should be using "polyCalls".

For example, here is a query to find methods that are not called from Java code:

Code:
from Method main, Callable m
where not(main.hasName("main") and main.polyCalls+(m))
select m

Of course computing polyCalls+ can result in a huge relation, so such queries can be slow to evaluate. The good news is that we've invented a novel optimisation that makes the above query quite snappy - less than a minute on a modest laptop, with a moderately sized, fully populated project. That novel optimisation will be included in the professional edition of SemmleCode, to be released soon, so stay tuned!

One issue to watch out for when playing with queries over the call graph is that they only inspect calls from Java source or bytecode - if a call occurs via reflection, or from native code, it is ignored.

Hope this helps!


Logged
Pages: [1]
  Print  
 
Jump to: