f*****e 发帖数: 57 | 1 Coming from c++ world, I am confused :->
A c++ object contains all the data members and the vtable(if exists). The
methods are just like c function sitting somewhere, with the difference of
taking an addition hidden arguement(this). There is only one copy of each
method, which is shared by all the objects of the same class.
Is a java object the same? It's not clear to me, and I couldn't google the
right answer. The few java developers I asked, they seems not care about the
mechanics(typical ja | c*****t 发帖数: 1879 | 2 You need to know more about Java first. If you are really interested,
get a java disambler (like Jasmine) and play with it a bit.
the
the
answer.
machine
This
【在 f*****e 的大作中提到】 : Coming from c++ world, I am confused :-> : A c++ object contains all the data members and the vtable(if exists). The : methods are just like c function sitting somewhere, with the difference of : taking an addition hidden arguement(this). There is only one copy of each : method, which is shared by all the objects of the same class. : Is a java object the same? It's not clear to me, and I couldn't google the : right answer. The few java developers I asked, they seems not care about the : mechanics(typical ja
| g*****g 发帖数: 34805 | 3 I think data and methods are in different location.
However, it's true that the detailed implementation
is not important, which is also true for most C++ developers.
the
the
answer.
machine
This
【在 f*****e 的大作中提到】 : Coming from c++ world, I am confused :-> : A c++ object contains all the data members and the vtable(if exists). The : methods are just like c function sitting somewhere, with the difference of : taking an addition hidden arguement(this). There is only one copy of each : method, which is shared by all the objects of the same class. : Is a java object the same? It's not clear to me, and I couldn't google the : right answer. The few java developers I asked, they seems not care about the : mechanics(typical ja
| r*****l 发帖数: 2859 | 4 If you want to learn Java, try to figure out what is OO first.
From the way you explained C++ object, you don't seem to know
the concept of OO at all.
the
the
answer.
machine
This
【在 f*****e 的大作中提到】 : Coming from c++ world, I am confused :-> : A c++ object contains all the data members and the vtable(if exists). The : methods are just like c function sitting somewhere, with the difference of : taking an addition hidden arguement(this). There is only one copy of each : method, which is shared by all the objects of the same class. : Is a java object the same? It's not clear to me, and I couldn't google the : right answer. The few java developers I asked, they seems not care about the : mechanics(typical ja
| s******e 发帖数: 493 | 5
the
the
answer.
machine
This
Basically you can think that java uses the same four areas as c++ does. heap
, code, data, and stack. As I know, the method code are shared. But how to
organize the memory is kind of depending on the jvm vendor in java. Usually
this is not important if you are not writing jvm or doing some fancy thing
such as dynamic replacement of an active class.
java uses metadata object to store the refelction data of a class. The
metadata object itself is also a subclass of obj
【在 f*****e 的大作中提到】 : Coming from c++ world, I am confused :-> : A c++ object contains all the data members and the vtable(if exists). The : methods are just like c function sitting somewhere, with the difference of : taking an addition hidden arguement(this). There is only one copy of each : method, which is shared by all the objects of the same class. : Is a java object the same? It's not clear to me, and I couldn't google the : right answer. The few java developers I asked, they seems not care about the : mechanics(typical ja
| L*********r 发帖数: 92 | 6 Generally, the memory layout of Java object has the header and body.
The header has a reference to the class which defines the method.
The body is almost same as a non-vf/vb C++ object as what you already know.
the
the
answer.
machine
This
【在 f*****e 的大作中提到】 : Coming from c++ world, I am confused :-> : A c++ object contains all the data members and the vtable(if exists). The : methods are just like c function sitting somewhere, with the difference of : taking an addition hidden arguement(this). There is only one copy of each : method, which is shared by all the objects of the same class. : Is a java object the same? It's not clear to me, and I couldn't google the : right answer. The few java developers I asked, they seems not care about the : mechanics(typical ja
| m******t 发帖数: 2416 | 7
the
the
answer.
I for one don't know and don't care about the run-time memory layout of Java
objects - because I can't pretty much do anything about it even if I did.
Besides, different JVMs may choose to implement it differently.
machine
This
Remote "references" are implemented completely differently from the object
references within the same JVM.
Each JVM may choose to implement late binding differently, but I think most
of the implementations are based on virtual tables, just like in C++.
【在 f*****e 的大作中提到】 : Coming from c++ world, I am confused :-> : A c++ object contains all the data members and the vtable(if exists). The : methods are just like c function sitting somewhere, with the difference of : taking an addition hidden arguement(this). There is only one copy of each : method, which is shared by all the objects of the same class. : Is a java object the same? It's not clear to me, and I couldn't google the : right answer. The few java developers I asked, they seems not care about the : mechanics(typical ja
|
|