H, Aftab
I think your question is over the Core section, but I glad to help you understand the mechanism of allocation of JVM.
JVM uses two seperate heaps to handle the memory allocation. One is responsible for
static allocation and another is for
dynamic allocation. when you define a final varible, it is allocated in to a heap which cannot clloected by gc. So it stays in memorey until the application is over. All class definitions, the Constant Pool, and method tables are kept in a nongarbage collected heap.
The second heap is split into two areas that grow in opposite directions. One area is used to hold object instances, and the other contains "handles" to those instances. The
runtime image of fields and variables in your
Java application that reference object instances do not actually contain pointers to those objects. They contain pointers to a special, fixed-size, heap-based memory object called a handle. The handle is a structure that contains two pointers: one to the object's method table and the other to the actual object instance. The advantage to this layout is that the handles never move in memory, so there is never a need to keep track of which variables point to which objects when updating pointers after compacting. You simply update the pointer value of the handle structure.
So , now, you can understand what is compil-time constant, what is runtime varible. In fact, in my understanding, the runtime varible is not a dynamic one since its handler can not be changed during the application lifecycle.
The above is just my view and just as reference, if there are wrong sections, plz point out.Thanks
regds
George