JetBrains/intellij-community · error · ConfigurationException

move.classes.destination.class.not.found.message

Error message

move.classes.destination.class.not.found.message

What it means

Thrown by MoveClassesOrPackagesDialog.canRun() (MoveClassesOrPackagesDialog.java:556) when the move target is an inner class and findTargetClass() returns null — the typed/selected destination class cannot be resolved. The refactoring needs a concrete containing class to move members into; an unresolvable destination blocks it. Distinct from the package-name grammar check in the same method.

Source

Thrown at java/java-impl-refactorings/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesDialog.java:556

      }
    }
  }

  protected final boolean isSearchInComments() {
    return myCbSearchInComments.isSelected();
  }

  @Override
  protected void canRun() throws ConfigurationException {
    if (isMoveToPackage()) {
      String name = getTargetPackage().trim();
      if (!name.isEmpty() && !PsiNameHelper.getInstance(myManager.getProject()).isQualifiedName(name)) {
        throw new ConfigurationException(JavaBundle.message("move.classes.invalid.destination.package.name.message", name));
      }
    }
    else {
      if (findTargetClass() == null) {
        throw new ConfigurationException(
          JavaBundle.message("move.classes.destination.class.not.found.message"));
      }
      final String validationError = verifyInnerClassDestination();
      if (validationError != null) throw new ConfigurationException(validationError);
    }
  }

  @Override
  protected void validateButtons() {
    validateButtonsAsync(ModalityState.stateForComponent(myMainPanel));
  }

  private @Nullable PsiClass findTargetClass() {
    String name = myInnerClassChooser.getText().trim();
    return JavaPsiFacade.getInstance(myManager.getProject()).findClass(name, ProjectScope.getProjectScope(myProject));
  }

  protected boolean isMoveToPackage() {

View on GitHub (pinned to be881553f2)

Solutions

  1. Re-pick the destination class via the class browser (...) so the field holds a resolvable FQN.
  2. Ensure the destination class's module/library is a dependency of the current module.
  3. Let indexing finish or File | Invalidate Caches and restart, then retry the move.
  4. If the class was renamed/deleted, choose the new destination explicitly.

Example fix

// before
// destination: com.acme.Utlis  (typo) -> findTargetClass() == null -> ConfigurationException

// after
// destination: com.acme.Utils   -> resolves, move proceeds
Defensive patterns

Strategy: validation

Validate before calling

// before confirming a move-to-inner-class, ensure the destination resolves
PsiClass target = findTargetClass(); // JavaPsiFacade.findClass(fqn, scope)
if (target == null) {
  // fix name/dependencies instead of letting canRun() throw
}

Prevention

When it happens

Trigger: Move (F6) with 'To inner class' semantics: the destination class field holds a qualified name that does not resolve in the project scope — wrong package, class in a non-dependent module, or a typo. Also fires when the field references a class deleted while the dialog was open.

Common situations: Moving utility methods into a class from another module not on the dependencies list; destination class renamed by a teammate mid-session; target exists only in test sources; index not yet updated after branch switch.

Related errors


AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14). Data as JSON: /api/errors/1f9e6c57f3a8ee38. Report an issue: GitHub.