code: void validateState() {
          if (frames == null || coroutine == null) {
              throw new IllegalStateException("Bad state");
          }
  
          for (int i = 0; i < frames.length; i++) {
              if (frames[i] == null) {
                  throw new IllegalStateException("Bad state");
              }
              frames[i].validateState();
          }
      }
docs: method to do that.