[Soot-list] Jasmin outputs different class file versions

Khilan Gudka khilan.gudka at imperial.ac.uk
Mon Mar 17 19:34:29 EDT 2008


Dear Patrick,

Sorry about that. What you said is absolutely correct and I shall
remember that in future. Thanks a lot!

Yes, javac for java 1.3 produces different code from javac for java
1.5. In particular, Java 1.5 additionally has class constants (for
class objects). At the java source level in both cases, one can access
the class object for a class "A" via the path "A.class", however, this
is compiled differently by the two respective versions of javac.

In 1.3 (and 1.4), it gets turned into a reflective call to
Class.forName("A"), while in 1.5 (and 1.6) it turns into code that gets
the class object from the constant pool (ldc_w). The reason why soot was
generating class files targetted at 1.5 was because I was referring to
the class object via a class constant (soot.jimple.ClassConstant). As
this is only supported in 1.5 onwards, this is why soot generated class
files with a major number of 49 (which is java 1.5).

The solution is to use Class.forName(java.lang.String) to obtain the
class object.

Thanks,
Khilan

On 17/03/2008, Patrick Lam <plam at sable.mcgill.ca> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
> Khilan Gudka wrote:
> > public class Test {
> >     public static void main(String[] args) {
> >         Class c = Test.class;
> >     }
> > }
>
>
> Please try to help us (prospective answerers) out here. Are you saying
> that javac from 1.3 produces different code than javac from 1.5, and
> that when you use Soot on the Java source code, you get the 1.5-like
> code? If that is the case, then it's going to be hard to get Soot to
> generate the 1.3-like code. But perhaps you meant to ask some other
> question; I can't tell.
>
> Before asking a question, try reading it first and asking yourself if
> you've included enough information that someone could possibly say
> something informed in response to your question.
>
> pat
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFH3vhyNTVxnNGEyOgRAnoiAJ41QqU6F8BGynf0GpPKaNGw/ANLAACfQU5G
> UAC+0+EQhSR6eEIUeu3Tl2c=
> =Zt4/
> -----END PGP SIGNATURE-----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20080317/9d68acc8/attachment-0001.htm


More information about the Soot-list mailing list