[Soot-list] Jasmin outputs different class file versions

Khilan Gudka khilan.gudka at imperial.ac.uk
Mon Mar 17 18:49:00 EDT 2008


After some investigation, I think i've found what the problem is: class
constants. In java versions less than 1.5, the class object (A.class) is
retrieved using reflection, while in 1.5 onwards it is obtained from the
constant pool. For completeness, here is my test case:

public class Test {
    public static void main(String[] args) {
        Class c = Test.class;
    }
}

In jdk 1.3, the following bytecode is produced:

public class Test extends java.lang.Object{
static java.lang.Class class$Test;

public Test();
  Code:
   0:    aload_0
   1:    invokespecial    #6; //Method java/lang/Object."<init>":()V
   4:    return

public static void main(java.lang.String[]);
  Code:
   0:    getstatic    #7; //Field class$Test:Ljava/lang/Class;
   3:    ifnonnull    18
   6:    ldc    #8; //String Test
   8:    invokestatic    #9; //Method
class$:(Ljava/lang/String;)Ljava/lang/Class;
   11:    dup
   12:    putstatic    #7; //Field class$Test:Ljava/lang/Class;
   15:    goto    21
   18:    getstatic    #7; //Field class$Test:Ljava/lang/Class;
   21:    astore_1
   22:    return

static java.lang.Class class$(java.lang.String);
  Code:
   0:    aload_0
   1:    invokestatic    #1; //Method
java/lang/Class.forName:(Ljava/lang/String;)Ljava/lang/Class;
   4:    areturn
   5:    astore_1
   6:    new    #3; //class java/lang/NoClassDefFoundError
   9:    dup
   10:    aload_1
   11:    invokevirtual    #4; //Method
java/lang/Throwable.getMessage:()Ljava/lang/String;
   14:    invokespecial    #5; //Method
java/lang/NoClassDefFoundError."<init>":(Ljava/lang/String;)V
   17:    athrow
  Exception table:
   from   to  target type
     0     5     5   Class java/lang/ClassNotFoundException


}

However, in 1.5:

public class Test extends java.lang.Object{
public Test();
  Code:
   0:    aload_0
   1:    invokespecial    #1; //Method java/lang/Object."<init>":()V
   4:    return

public static void main(java.lang.String[]);
  Code:
   0:    ldc_w    #2; //class Test
   3:    astore_1
   4:    return

}

Is there any easy way to generate the code for jdk 1.3 using soot?

Thanks
Khilan

On 17/03/2008, Patrick Lam <plam at cs.mcgill.ca> wrote:
>
> Khilan Gudka wrote:
> > Dear All,
> >
> > I have two class files A and B both of version 45.3. I transform them
> > using Soot, however, the resulting class file for A has version 46,
> > while the one for B has version 49. I compiled jasmin with target=1.3,
> > but i'm still getting the same result.
> >
> > Any guidance would be greatly appreciated
>
>
> Perhaps you might get better responses if you made your test cases
> available.
>
> pat
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20080317/0d2061a1/attachment.htm


More information about the Soot-list mailing list