[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: DeadAssignmentEliminator
On Tue, 26 Jun 2001, Fabien Deschodt wrote:
> I think that:
> if (((InstanceFieldRef)rhs).getBase() == body.getThisLocal()) {
> isEssential = false;
> is enough as:
> "The keyword this may be used only in the body of an instance method,
> instance initializer or constructor, or in the initializer of an instance
> variable of a class. If it appears anywhere else, a compile-time error
> occurs."
> I think it is also true in byte-code. This should be checked by the verifier.
getThisLocal() will throw an exception for a static method.
> > I just checked that this is a final variable for javac, so it can't be
> > changed in java code.
> "this" is not really final, but according to the Language spec:
> "When used as a primary expression, the keyword this denotes a value, that is
> a reference to the object for which the instance method was invoked (§15.12),
> or to the object being constructed."
> AND
> "The result of the first operand of an assignment operator must be a variable"
>
> So this=... is impossible (hopefully). However, I did not check in the VM
> spec and I don't know if you can produce bytecode with the same effect.
This is not impossible in bytecode; however, Soot will split local
variables so that we'll never see such a thing in pure Jimple. Possibly,
after some transformations getThisRef() may not, in fact, refer to this.
But this seems like a braindead thing to do.
pat