JetBrains/intellij-community · warning · ConfigurationException
dialog.message.valid.identifier
Error message
dialog.message.valid.identifier
What it means
Thrown by RenameJavaImplicitClassProcessor's handler canRun() (RenameJavaImplicitClassProcessor.java:60) when renaming a Java implicit class (JEP 445+/java 21 preview feature) and the new name is not a legal identifier per PsiNameHelper. It also throws a silent ConfigurationException(null) when the new name equals the implicit class's current qualified name (no-op rename). Uses LangBundle ('dialog.message.valid.identifier') because the check is language-agnostic.
Source
Thrown at java/java-impl-refactorings/src/com/intellij/refactoring/rename/RenameJavaImplicitClassProcessor.java:60
private final @Nullable String myExtension;
private RenameJavaImplicitClassRenameDialog(@NotNull Project project, @NotNull PsiElement element, PsiElement nameSuggestionContext, Editor editor) {
super(project, element, nameSuggestionContext, editor);
myExtension = Optional.ofNullable(((PsiJavaFile)element).getVirtualFile())
.map(file -> file.getExtension())
.orElse(null);
}
public PsiImplicitClass getImplicitClass() {
return Objects.requireNonNull(JavaImplicitClassUtil.getImplicitClassFor(getPsiElement()));
}
@Override
protected void canRun() throws ConfigurationException {
String name = super.getNewName();
if (Comparing.strEqual(name, getImplicitClass().getQualifiedName())) throw new ConfigurationException(null);
if (!PsiNameHelper.getInstance(getProject()).isIdentifier(name)) {
throw new ConfigurationException(LangBundle.message("dialog.message.valid.identifier", getNewName()));
}
}
@Override
protected String getFullName() {
PsiImplicitClass implicitClass = getImplicitClass();
String name = DescriptiveNameUtil.getDescriptiveName(implicitClass);
String type = UsageViewUtil.getType(implicitClass);
return StringUtil.isEmpty(name) ? type : type + " '" + name + "'";
}
@Override
public String[] getSuggestedNames() {
String name = getImplicitClass().getQualifiedName();
if (name != null) {
return new String[]{name};
}
return super.getSuggestedNames();View on GitHub (pinned to be881553f2)
Solutions
- Type a valid Java identifier as the new name.
- If the name is unchanged, actually modify it — equal-name renames are blocked by design (message-less ConfigurationException).
- Check the project language level supports implicit classes so the element resolves as one at all.
Example fix
// before // Rename implicit class 'Hello' to 'hello-world' -> invalid identifier error // after // Rename implicit class 'Hello' to 'HelloWorld' -> valid, proceeds
Defensive patterns
Strategy: validation
Validate before calling
String newName = getNewName();
if (Comparing.strEqual(newName, implicitClass.getQualifiedName())) return; // no-op blocked silently
if (!PsiNameHelper.getInstance(project).isIdentifier(newName)) {
// show inline error before invoking Rename
} Prevention
- In batch rename tooling, skip entries whose new name equals the current qualified name.
- Run PsiNameHelper.isIdentifier on all generated names.
When it happens
Trigger: Rename (Shift+F6) on a Java implicit class (the class synthesized around the main method of a single-file program) with the new-name field containing a keyword, digit-leading token, or illegal characters. Renaming to the identical qualified name is silently blocked with a null message.
Common situations: Trying to rename the implicit class of a java 21+ single-file source to match the file name, but typing a keyword or a name with '-'/' '; or accepting the dialog without changing the name.
Related errors
- ''{0}'' is invalid extracted class name
- ''{0}'' is invalid field name for delegation
- ''{0}'' is invalid parameter name
- ''{0}'' is invalid inner class name
- ''{0}'' is invalid parameter class name
AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14).
Data as JSON: /api/errors/e3ad90feca1e91bb.
Report an issue: GitHub.