Article View: borland.public.jbuilder.java.language
Article #15237Re: Determining calling method
From: Steve Schafer (TeamB)
Date: Fri, 25 Jun 1999 00:00
Date: Fri, 25 Jun 1999 00:00
21 lines
1425 bytes
1425 bytes
On Fri, 25 Jun 1999 09:11:23 -0500, Lars Roe <roex0029@tc.umn.edu> wrote: >I noticed that ObjectOutputStream has a method >writeDefaultObject() which knows the object that called it. >How can it know without being passed a reference? It is only legal to call defaultWriteObject from within the writeObject method of a Serializable object. The Serializable's writeObject method is in turn called by ObjectOutputStream.writeObject, which initializes a private field called currentObject that holds a reference to the object being streamed. In other words, the only context in which defaultWriteObject is ever called is one in which the currentObject field has been initialized to point to the correct object, and this is what defaultWriteObject uses. If an attempt is made to invoke defaultWriteObject in some other context, it will throw an exception. -Steve
Technical Details
Message-ID:
<37d49f81.122006457@90.0.0.40>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<37738E0B.CBB84BBF@tc.umn.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,8dd1f56c98b39666 X-Google-Attributes: gidf74b3,public From: pandeng@telepath.com (Steve Schafer (TeamB)) Subject: Re: Determining calling method Date: 1999/06/25 Message-ID: <37d49f81.122006457@90.0.0.40> X-Deja-AN: 493802069 Content-Transfer-Encoding: 7bit References: <37738E0B.CBB84BBF@tc.umn.edu> Content-Type: text/plain; charset=us-ascii Organization: TeamB Mime-Version: 1.0 Reply-To: pandeng@telepath.com Newsgroups: borland.public.jbuilder.java.language