I may be very wrong here, but the JVM byte code’s method structure
explicitly has a stack size and local array max size property, both calculated at compile time. Are they using some heuristic here?
I'd bet that the stack size you refer to doesn't include callees (i.e., the stack used by procedures called by the method in question).
Oh you are right, Java has two stacks, an operational and a method/function stack. Only the former is calculated ahead of time (and the latter is configurable at runtime).