
23 Nov
2009
23 Nov
'09
2:10 p.m.
Hi Chris,
Interesting, I wonder when that changed? I'm fairly sure that never used to be the case. I don't think it's something that you should rely on, especially since the VM spec says the following:
...
Here's something else I guess you shouldn't depend on: further experimentation shows that the order of the class member declarations doesn't make any difference to the object size. So you can intersperse the bools with the ints and the object size doesn't change. The Java compiler must order the fields to minimise the space required. That's fine because (not being C) you can't address the object's fields by pointer so the ordering is not visible to the programmer. Cheers, Mark