Re: What does the CLR do when you instantiate an object? - Continue
From: Anon (Anon_at_Anon.Anon)
Date: 02/18/04
- Next message: Jonathan Keljo [MS]: "Re: mscorwks.dll throwing tons of exceptions"
- Previous message: Fabian Schmied: "Re: Button click single"
- Maybe in reply to: Anon: "Re: What does the CLR do when you instantiate an object? - Continue"
- Next in thread: stack: "Re: What does the CLR do when you instantiate an object? - Continue"
- Reply: stack: "Re: What does the CLR do when you instantiate an object? - Continue"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 18 Feb 2004 08:45:05 -0500
Here are the steps for seeing ParentClass class information. I stopped the
process right at the beginning of the ChildClass constructor. ParentClass
constructor has not been called yet.
1) !DumpObj with ChildClass object address
2) Get the EEClass address
3) !DumpClass with ChildClass EEClass address
4) Get the ParentClass Address
5) !DumpClass with ParentClass address
6) Get the method table address
7)!DumpMT -MD with parent's method table address.
There you go, all class information of the child and its descendants are
built before the parent constructor is called.
Please do not confuse class type information with object instance. By doing
dump its clear that only a ChildClass instance is created, but all type
information needed is built before constructors start. This supports
Willy,Jon, Myself, and the CLI spec.
"stack" <anonymous@discussions.microsoft.com> wrote in message
news:EBD1E323-7BB8-4DBF-BBB0-5C8EA76BFA78@microsoft.com...
> First let me make clear once for all, in this course of the discusison, I
never said that
> two "seperate objects" were created, I challenge any of you to find my
original posts and
> let others who might have not seen the earlier discussion to see what my
position or opinion is on this issue, that is if by "separate objects", you
meant that two distinct memory areas
> I have been saying that after the memory of the child class has been
allocated or
> designated, within that same memory area, object of the parent class
exists and it is created before the object of the child class instantiation
is completed for the reasons I stated in the last threereplies.
>
> I did not know that Anon had problem with the statement that "every object
of a child class is also an object of its parent class". When I first made
the statement, you response was:
>
> "If you are viewing it from VB.NET/C# point of view and the fact that you
can
> cast an object to one of its parent types then yes I'd agree with you. It
> looks like two different objects exists and have been created"
>
> So I thought you are OK with the statement. But since now you objected it,
> Let me say that I am OK with your suggestion to replace the words "object
of a class"
> with "Type of a class". Personally, I think two phases are interchangeable
and the formal is
> more commonly used in the media. Even yourself said many times that you
had an object of child class in the memory, when I asked you whether you are
confident to say
> so, you said that you agreed with Jon that the object is "type of the
child class". Then means that you did not use the term consistently
yourself.
>
> I believe if the true value of "is" operator is guaranteed for a
reference type (here I am talking "is" operator in C#, not VB.Net, the "is"
operator has different meanings in the two languages), such as in the
relationship between child and parent classes, for every object e of child
class (e is Parent Class) is always true (actually compiler complains in
such cases),then that object is an object of the parent class. It happens
there is another Keyword TypeOf , when you say e is type of child class, in
some cases the listeners will be confused with the keyword TypeOf, for that
reason I still believe that "is an object" is a better words to be used. But
anyway, I am OK with your terminology, so long as we all understand what it
means.
>
> As for whether an object of child class is created "immediately" ( I
interpreted Jon's
> "immediately' as right after new (class) is run but before the CLR loader
calls
> the instance constructor), I said no, three of you think yes. I backed up
my claim with MSDN document, you guys even could not find any official
document to support your claim that an object of the child class is created
before any constructor is called. Anon, cited the CLR standard, but the
standard mentioned that constructor invoking is involved in the object
creation. I even found a book by Jeffrey Richter titled "Applied Microsoft
.NET Framework Programming", he also described what the new key word does
when it is used to created new object, it basically said the same thing as
in the quotation I cited from MSDN, 1) it allocates memory 2) It
initializes the object's overhead members (a point to the MT and creates
SyncBlockIndex for object management purpose) 3) It calls instance
constructor. Again it is against all of your opinion. I also visited Sun's
web site to check what it says about the process of object creation in Java.
In one page, it states that the sole purpose of a constructor is to create
instance of class. I could not found a single source which supports you
guy's claim.
>
> Then on debugging side, I did not see a MT table which contains all
methods, including the methods inherited from the parent classes, Jon
totally ignore that fact, Willy said that it is there it is just not in the
dump, well, I do not think any one will buy black hole type of argument, and
Anon indicated that further research is needed to find out. Therefore you
did not provide any physical evidence either to back up your claim.
>
> Even IF you guys are right that an object of the child class is already
created in the memory before the CLR invoking any constructors, then it
has to be the new key work triggs runtime to perform all the object
creation task, that is in direct contradiction to the MSDN quotation I cited
before, yet none of you has gut to say that MSDN is wrong ,and that the new
key word does much more than what it is stated in the document. Are you
afraid that you will loss MVP title if you declare that MSDN made false
statement? oh you do not dare to say because you are not sure whether you
are right ? To me, all the time you are barking at wrong tree when you tried
to disprove my points.
>
> Instead of focusing your arguments to address those key points in our
discussion, some of you prefer to make some cheap shoot instead, like "any
decent circle class will have...", Well, I used that to illustrate a point,
not to make "a decent" class. I did not see any "decent class" came out your
sample codes either. Besides, there is no such standard for a "decent
class", any class serves author's purpose is decent to me.
>
- Next message: Jonathan Keljo [MS]: "Re: mscorwks.dll throwing tons of exceptions"
- Previous message: Fabian Schmied: "Re: Button click single"
- Maybe in reply to: Anon: "Re: What does the CLR do when you instantiate an object? - Continue"
- Next in thread: stack: "Re: What does the CLR do when you instantiate an object? - Continue"
- Reply: stack: "Re: What does the CLR do when you instantiate an object? - Continue"
- Messages sorted by: [ date ] [ thread ]