0

I am using Soot in order to be able to use its call graph but unfortunately I am having trouble with constructors.

I think this is best explained with an answer so here goes:

Consider a class CachingCollector$NoScoreCachingLeafCollector where NoScoreCachingLeafCollector extends FilterLeafCollector.

I want to get the constructor of such class whereby its parameter types are: LeafCollector and int.

For some reason Soot says that there is a constructor with those parameters BUT the first parameter is CachingCollector.

I cannot understand what is happening and I've been trying for a few hours now to no avail. What is confusing me even more is that there are some inner classes which extend some class but the Soot does not add that extra parameter in the beginning.

Any help would be greatly appreciated!!

gracey
  • 213
  • 3
  • 14

1 Answers1

0

Such questions are most quickly answered on the Soot mailing list.

To answer your question: Soot simply shows you what the bytecode actually looks like. The class you are talking about is an inner class. Constructors to such classes are automatically passed a "this" reference to the outer class, such that this outer object can be accessed from within the inner class. That is what Soot shows you.

Eric
  • 1,343
  • 1
  • 11
  • 19
  • OK. The problem is that I had other constructors of inner classes which did not show this behaviour. For example the constructor 'NoScoreCachingCollector' for class CachingCollector$NoScoreCachingCollector only takes the parameter types Collector, int according to SOOT. As you may notice the class NoScoreCachingCollector is also an inner class of CachingCollector. Why is this? – gracey Apr 19 '14 at 11:42
  • Maybe that's because the one class accesses the "this" object of the outer class while the other one does not? – Eric Apr 20 '14 at 12:37
  • But how can one recognise this through the java code please? – gracey Apr 20 '14 at 21:34
  • In the first comment you said that constructors of inner classes are automatically passed a "this" reference to the outer class. So how in this one instance it does not work if the such reference is automatic? – gracey Apr 20 '14 at 21:50
  • 1
    The Compiler can detect the situations in which the this reference is used by the inner class. If it is not used then the compiler can choose to not pass the reference to the constructor (as an optimization) because it will not be used anyway. – Eric Apr 22 '14 at 06:18
  • Ohh ok. Because I am giving soot a set of methods my programmed identified through an AST and at that point I surely cannot know such information. Thanks for your help! – gracey Apr 22 '14 at 20:15