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?
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).