The Java Virtual Machine is an abstraction, a model that describes the execution of Java programs. Actual JVM implementations, such as the Oracle JDK JSM HotSpot, can allocate the Java stack stack anywhere or anywhere.
eg. in the JIT-compiled method, some operands can be stored in CPU registers or even processed as immediate constants, and not occupy the real stack space. Moreover, the built-in methods do not have their own stack frame; they share the parent frame.
So no, this is not a waste, because the specification does not impede the implementation of the optimized presentation JVM. Although JVMs are not usually taken care of: stack space is usually not a limiting factor - the stack contains mostly a small amount of temporary values, while the actual data is in the Java Heap.
source share