[Soot-list] Trying to do getClass() on a static method...need to implement inner classes

Kanad Sinha kanad85 at gmail.com
Wed Jun 16 20:23:45 EDT 2010


Hi,

First of all, thanks for answering an earlier query of mine that you had 
answered a few days back!

I need to get the runtime class of a static method a la getClass(), by 
instrumenting the following code:

new Object() {}.getClass().getEnclosingClass()        /* (1) */

Suppose this is done for a static method of class Main, it seems this 
code generates an _inner class Main$1_, which in Jimple looks like:

class Main$1 extends java.lang.Object
{
     void <init>()
     {
         Main$1 r0;

         r0 := @this: Main$1;
         specialinvoke r0.<java.lang.Object: void <init>()>();
         return;
     }
}

, and the actual code (1) is translated to:

$r10 = new Main$1;
specialinvoke $r10.<Main$1: void <init>()>();
$r11 = virtualinvoke $r10.<java.lang.Object: java.lang.Class getClass()>();
virtualinvoke $r11.<java.lang.Class: java.lang.Class 
getEnclosingClass()>();

I created the new class and inserted the above Jimple code. For the new 
class that I created, I also set /setOuterClass /to the proper class 
(Main in this case). When I run this code, however, it returns null. I 
am guessing I have to do something more to properly register this as an 
inner class. Could anyone suggest what could be done in order to get the 
proper result?

To avoid spamming later on, I thank you in advance for any help forthcoming.

-- Kanad.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20100616/d1f48e10/attachment.html 


More information about the Soot-list mailing list