[Soot-list] Clinits encountered in an inter-procedural analysis

Rhodes H. F. Brown rhodesb at cs.uvic.ca
Mon Jul 17 16:02:35 EDT 2006


On 17-Jul-06, at 12:47 PM, Ahmer Ahmedani wrote:

> The analysis, even though it follows the edges in the call graph,  
> does not
> go into the clinit method for class Two. I am not sure why since  
> class Two
> is touched for the first time at the mentioned statement.
>
> Can you think of a plausible reason.

Because there is no way ensure that the use of 'Two.j' in your main()  
*is* in fact the first use of the 'Two' class. Consider the following  
example:

class CL_Use {
   static int j = 50;
   static {
     System.out.println("<clinit>:CL_Use");
   }
}

class CL_Parent {
   static {
     System.out.println("<clinit>:CL_Parent");
     System.out.println(CL_Use.j);
   }
}

public class CL extends CL_Parent {
   static {
     System.out.println("<clinit>:CL");
   }

   public static void main(String[] args) {
     System.out.println(CL_Use.j);
   }
}

Here, the "used" class is initialized before main() even begins. And  
furthermore, there is no way to infer this by studying the 'CL' class  
independently.

-Rhodes



More information about the Soot-list mailing list