[Soot-list] constructors with field defaults?

Chris Pickett chris.pickett at mail.mcgill.ca
Tue Apr 11 21:21:48 EDT 2006


On Tue, April 11, 2006 6:34 pm, Eric Bodden wrote:
> Hi, Greg.
>
>
> I don't think so, because those assignments in fact do not exist in the
> bytecode. The VM rather assumes fields to have those values *implicitly*
> unless anything else is assigned.

Eric is basically right, but I want to clarify.  The VM specification says
that all fields are initialized to 0 when the object is allocated:

http://java.sun.com/docs/books/vmspec/2nd-edition/html/Concepts.doc.html#15858

Any writes that happen in the constructor happen after the default values
have already been assigned.

You could get the set of fields that are unchanged from their default zero
value by subtracting the set of constructor-modified fields from the set
of all fields.  Then if you want these values propagated for an analysis
you could insert redundant writes into the constructor; it would be best
to do this at the top of the constructor in case there is a dependency.

Cheers,
Chris

>
> Eric
>
>
>> -----Original Message-----
>> From: soot-list-bounces at sable.mcgill.ca
>> [mailto:soot-list-bounces at sable.mcgill.ca] On Behalf Of Greg Dennis
>> Sent: Tuesday, April 11, 2006 1:14 PM
>> To: soot-list at sable.mcgill.ca
>> Subject: [Soot-list] constructors with field defaults?
>>
>>
>> Is there an option that will force soot to output
>> constructors that explicitly assign the default values to all fields that
>> are not assigned in the source code?
>>
>> For example, given the following class and constructor
>>
>>
>> class C { T x, y;
>> int i; boolean b;
>>
>> C(T x) {
>> this.x = x; }
>> }
>>
>>
>> I would like the soot output to look as if the constructor
>> were written as follows
>>
>> C(T x) {
>> this.x = x; this.y = null; this.i = 0; this.b = false; }
>>
>>
>> Is there an option that causes soot to create these explicit
>> assignments of the default values to fields?
>>
>> Thanks,
>> Greg
>> _______________________________________________
>> Soot-list mailing list
>> Soot-list at sable.mcgill.ca
>> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>>
>>
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>
>
>




More information about the Soot-list mailing list