[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Assignment statement isn't parsing
Hi Nathan,
My suspicion is that javac is clever enough to notice that A.calc() always
returns 0, so it eliminates the extra assignment in the bytecode it
produces. However, it is not clever enough to see whether
A.calc() causes any side effects, so it kept the call anyway. I suggest
that you examine the bytecode (in some readable form, say in jasmin) to
see whether this is indeed what happens.
Cheers,
Felix
On Wed, 27 Feb 2002, Nathan Kitchen wrote:
> When I run soot with the command line below on the classes generated
> with the source code below, I do not get the right results.
>
> Command line:
> java soot.Main -j --soot-classpath .:$JAVA_HOME/jre/lib/rt.jar -p jb
> use-original-names A
> (The problem is independent of whether I use the phase option to keep
> the original names, but the results are easier to read with it.)
>
> Source code:
>
> public class A {
> void run() {
> int e = 0;
> e = calc();
> }
>
> static int calc() {
> return 0;
> }
> }
>
> Here is the bad result, A.jimp:
>
> public class A extends java.lang.Object
> {
> void run()
> {
> A r0;
> boolean z0;
>
> r0 := @this;
> z0 = 0;
> A.calc();
> return;
> }
>
> public void <init>()
> {
> A r0;
>
> r0 := @this;
> specialinvoke r0.<init>();
> return;
> }
> }
>
> The line "A.calc();" should be "z0 = A.calc();".
> However, if I make e into a double, so that the value from calc() has to
> be cast, I get what I should: "$d0 = A.calc(); z0 = (int) $d0;".
>
> Does someone know how to fix this?
>
> --
> Nathan Kitchen
> kitchen@et.byu.edu
>