In Java, where are the functions of a class placed in memory?

In java, where are the put class functions in memory?

+2


a source to share


2 answers


Depends on the implementation. Generally, you shouldn't worry about such things in Java. The whole concept of "VM" is an abstraction of things like this. Now, I would assume the functions are stored somewhere near bytecode, but if your VM is JIT capable, then they could be anywhere ....

I think we could say "heap" ... lol



To be honest, I can't think of a single reason why you would need to know this, and thinking about what you are trying to use for me scares me.

+3


a source


The JVM spec states that it is part of the heap:

3.5.4 Method Scope

The Java virtual machine has a scope method that is common to all Java virtual machine threads. The scope method is analogous to the storage area for compiled regular language code or a similar "text" segment in a UNIX process. It stores for class structures such as run-time persistent pool, method field and data, and method code and constructors, including special methods (§3.9) used in the class and instance initialization and interface type initialization. method area is created on virtual machine startup. Although the scope method is logically part of the heap, simple implementations may choose not to either garbage collection or compact it. This version of the Java Virtual Application Machine specification does not provide for the location of the method scope or policies used to control the compiled code.The method area can be of a fixed size or can be expanded according to the computation requirements and can be reduced if a larger method area becomes unnecessary. The memory for the method area does not have to be contiguous.



Reference: JavaTM Virtual Machine Specification

+3


a source







All Articles