How does a class/instance object actually access methods from the memory's Text/Method Segment in Java/Objective C? -


as far understand (please correct me if i'm wrong), methods classes stored in code/text segment of memory in c/objective c. in java, methods stored in method area (equivalent code/test segment). methods allocated @ compiled-time. believe each object, whether class or instance, not instantiated method codes every single time. instead, methods created once in code/text segment. object instances, located in heap segment, have somehow access/relate these methods.

1) objects store memory address of methods in data?

2) inheritance, objects somehow (through keywords such "extends") store memory address of superclass' methods?

normally code of program stored in code segment called text segment. for more information on different segments:

http://www.beingdeveloper.com/memory-layout-of-a-program/

basically code segment has field called "offset", offset address @ instructions available.

as example, suppose program (binary) loads @ memory location 0x802...

and code segment have entries this:

offset       info                 type   sym.value  sym. name 0000002d  00000501 r_386_32 00000000   .rodata 00000032  00000a02 r_386_pc32      00000000   printf 00000044  00000501 r_386_32 00000000   .rodata 00000049  00000a02 r_386_pc32      00000000   printf 

the actual memory location @ code loaded : offset + program (binary) load location.

detailed explanation:

http://www.tenouk.com/modulew.html


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -