It is possible that a method gets called but no stack frame (activation record) gets allocated.


A method invocation does not necessarily allocate a stack frame


Here is what's right.

Every time a method is invoked, an activation record is allocated. That record contains the this variable (for instance methods and constructors), the formal parameters, and the local variables for that method invocation. The activation record is freed when that method invocation returns.

For the notional machine we teach, we assume that even in the special case where there are no formal parameters, no local variables, and the method is static (and thus has no this) an activation record is allocated. We assume that that activation record is empty (in reality, it would contain some meta information, e.g., the return address and a pointer to the caller’s activation record, but we ignore these aspects in our notional machine).

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.