Fwd: [Soot-list] DeadAssignmentEliminator and assignments x=null
Eric Bodden
eric.bodden at mail.mcgill.ca
Tue Sep 11 17:04:20 EDT 2007
Let me clarify...
> > Object o = new Object();
> > WeakReference w = new WeakReference(o);
> > o = null; //eliminated
> > System.gc();
> > assert w.get()==null; //will fail
>
> Are you sure? I think that the reference is to the new object (the
> initial value of o), not to the local variable o. Otherwise that would
> be very weird indeed in terms of semantics; Java doesn't have
> call-by-reference.
Because "o" is not used after this block of code, the assignment "o =
null;"is removed. This leaves us with:
Object o = new Object();
WeakReference w = new WeakReference(o);
System.gc();
... where w.get() will return the object stored in o (opposed to null,
as usually after GC).
Hence, "assert w.get()==null;" fails.
Eric
--
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada
--
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada
More information about the Soot-list
mailing list