[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Accessing .self() in constructor
Um, don't you need to use self() to get a proxy rather than the OzoneObject
itself? I didn't even try "this" once I saw self().
I've worked around this now anyway :).
\x/ill :-}
--On Tue, Dec 28, 1999 7:02 PM -0900 Tim Brown <Tim.Brown@incenter.org>
wrote:
> Why can;t you just use "this"?
>
> William Uther wrote:
>
>> Hi,
>> I'm implementing a circular doubly-linked list in Ozone. When a list
>> element is created I want to initialize the 'prev' and 'next' pointers to
>> point back to the object itself.
>>
>> Now in straight java this would be:
>>
>> class elt {
>> elt prev, next;
>> elt() {
>> prev = this;
>> next = this;
>> }
>> }
>>
>> And, if I understand things correctly, in Ozone this becomes:
>>
>> class eltImpl extends OzoneObject implements elt {
>> elt prev, next;
>> elt() {
>> prev = (elt)self();
>> next = (elt)self();
>> }
>> }
>>
>> The problem is that the self() method accesses something called the state
>> (line 68 of OzoneObject.java). That state is not initialized until after
>> the object is constructed. (The env object is constructed line 81 of
>> ObjectSpace.java, but the state isn't created till line 86.)
>>
>> Now, I think I can work around this in my code, so the following is just
>> speculation:
>>
>> I was trying to figure out how to fix Ozone to handle this case
>> correctly. I can see a couple of solutions:
>> -Make an 'OzoneConstructor' that is called after creating each object.
>> This would mean renaming the constructor of most ozone objects.
>> -Modify the OzoneObject constructor so that it takes a reference that
>> allows it to set the state. This would mean adding a constructor to all
>> ozone objects, even those that don't explicitly need one.
>> - Modify the methods in OzoneObject so that if they are called when
>> state is null they work around the problem somehow (yeah, this might
>> not work).
>>
>> Any other suggestions?
>>
>> \x/ill :-}
>
> --
> Tim Brown
> URL: http://www.incenter.org
>
>
>