ModernRouterNavigator implements RouterNavigator<StateT> { @SuppressWarnings("unchecked") @Override public void popState() { RouterAndState<StateT> fromState = null; if (currentTransientRouterAndState != null) { fromState = currentTransientRouterAndState; String fromRouterName = fromState.getRouter().getClass().getSimpleName(); currentTransientRouterAndState = null; log( String.format( Locale.getDefault(), "Preparing to pop existing transient state for router: %s", fromRouterName)); } else { if (!navigationStack.isEmpty()) { fromState = navigationStack.pop(); String fromRouterName = fromState.getRouter().getClass().getSimpleName(); log( String.format( Locale.getDefault(), "Preparing to pop existing state for router: %s", fromRouterName)); } } if (fromState != null) { RouterAndState<StateT> toState = null; if (!navigationStack.isEmpty()) { toState = navigationStack.peek(); } detachInternal(fromState, toState, false); if (toState != null) { attachInternal(fromState, toState, false); } } else { log("No state to pop. No action will be taken."); } } ModernRouterNavigator(Router<?, ?> hostRouter); @SuppressWarnings("unchecked") @Override void popState(); @Override void pushRetainedState(
      final StateT newState,
      final AttachTransition<R, StateT> attachTransition,
      @Nullable final DetachTransition<R, StateT> detachTransition); @Override void pushRetainedState(
      StateT newState, AttachTransition<R, StateT> attachTransition); @Override void pushTransientState(
      final StateT newState,
      final AttachTransition<R, StateT> attachTransition,
      @Nullable final DetachTransition<R, StateT> detachTransition); @Override void pushTransientState(
      StateT newState, AttachTransition<R, StateT> attachTransition); @Nullable @Override Router peekRouter(); @Nullable @Override StateT peekState(); @IntRange(from = 0) @Override int size(); @Override void hostWillDetach();  }
@Test public void pop_whenTheRouterNavigatorIsEmpty_shouldNotCrash() { routerNavigator.popState(); }