由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - what's inside an java object?
相关主题
Static就是个混球请教一个动态cast的问题
array 在java里 是一定放在heap 吗?any free or trial JVM optimizer??
copy constructor都什么时候be called啊TIJ上写错了?
How to know the size of a java object ?线程hardy会一直等待下去么?
Re: 初级问题Java Object 一定在 Heap 里吗
[合集] 谁能解释一下这里的protected specifier问一个GC的问题
请问有没有generic的arrayRe: 谁有Java或Oracle的毒招 ?
Is it possible to get Class object for T from a generic class? (下列空档,是否可填)Java中如何动态生成对象
相关话题的讨论汇总
话题: java话题: object话题: c++话题: answer话题: machine
进入Java版参与讨论
1 (共1页)
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

1 (共1页)
进入Java版参与讨论
相关主题
Java中如何动态生成对象Re: 初级问题
一个Java程序员的话(3)[合集] 谁能解释一下这里的protected specifier
How to represent n:n relationship in Java?请问有没有generic的array
About TreeMap in JavaIs it possible to get Class object for T from a generic class? (下列空档,是否可填)
Static就是个混球请教一个动态cast的问题
array 在java里 是一定放在heap 吗?any free or trial JVM optimizer??
copy constructor都什么时候be called啊TIJ上写错了?
How to know the size of a java object ?线程hardy会一直等待下去么?
相关话题的讨论汇总
话题: java话题: object话题: c++话题: answer话题: machine