{"record":{"id":"d83f991d771b8cd3","repo":"JetBrains/intellij-community","slug":"0-is-invalid-inner-class-name","errorCode":null,"errorMessage":"''{0}'' is invalid inner class name","messagePattern":"''(.+?)'' is invalid inner class name","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"warning","filePath":"java/java-impl-refactorings/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectDialog.java","lineNumber":479,"sourceCode":"        int oldParameterIndex = parameterList.getParameterIndex((PsiParameter)data.variable);\n        parameters.add(ParameterInfoImpl.create(oldParameterIndex).withName(data.name).withType(data.type));\n      }\n    }\n    final ParameterInfoImpl[] infos = parameters.toArray(new ParameterInfoImpl[0]);\n    return new JavaIntroduceParameterObjectClassDescriptor(className, packageName, moveDestination, useExistingClass, createInnerClass,\n                                                           newVisibility, infos, mySourceMethod,\n                                                           myGenerateAccessorsCheckBox.isSelected());\n  }\n\n  @Override\n  protected void canRun() throws ConfigurationException {\n    super.canRun();\n    final Project project = mySourceMethod.getProject();\n    final PsiNameHelper nameHelper = PsiNameHelper.getInstance(project);\n    if (myCreateInnerClassRadioButton.isSelected()) {\n      final String innerClassName = getInnerClassName();\n      if (!nameHelper.isIdentifier(innerClassName)) {\n        throw new ConfigurationException(\n          JavaRefactoringBundle.message(\"introduce.parameter.object.error.invalid.inner.class.name\", innerClassName));\n      }\n      if (mySourceMethod.getContainingClass().findInnerClassByName(innerClassName, false) != null) {\n        throw new ConfigurationException(\n          JavaRefactoringBundle.message(\"introduce.parameter.object.error.inner.class.already.exist\", innerClassName));\n      }\n    }\n    else if (!useExistingClass()) {\n      final String className = getClassName();\n      if (className.isEmpty() || !nameHelper.isIdentifier(className)) {\n        throw new ConfigurationException(\n          JavaRefactoringBundle.message(\"introduce.parameter.object.error.invalid.parameter.class.name\", className));\n      }\n      final String packageName = getPackageName();\n\n      if (packageName.isEmpty() || !nameHelper.isQualifiedName(packageName)) {\n        throw new ConfigurationException(\n          JavaRefactoringBundle.message(\"introduce.parameter.object.error.invalid.parameter.class.package.name\", packageName));","sourceCodeStart":461,"sourceCodeEnd":497,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/java-impl-refactorings/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectDialog.java#L461-L497","documentation":"Thrown by IntroduceParameterObjectDialog.canRun() (IntroduceParameterObjectDialog.java:479) when the 'Create inner class' option is selected and the typed inner class name fails PsiNameHelper.isIdentifier(). The Introduce Parameter Object refactoring will generate a wrapper class, and the dialog pre-validates that the generated class name is a legal Java identifier. The framework catches the ConfigurationException and highlights the message without closing the dialog.","triggerScenarios":"Refactoring | Introduce Parameter Object with the 'Create inner class' radio selected, and the inner class name field containing a keyword, a digit-leading name, an empty string, or other non-identifier text when OK is pressed.","commonSituations":"Typing a desired wrapper name like 'Request-Params' or '2Params', leaving the field blank after clearing a suggested name, or using a reserved word such as 'Record' at an older language level.","solutions":["Correct the inner class name field to a valid Java identifier and confirm the dialog again.","If the name looks legal, verify the module language level — PsiNameHelper rejects identifiers illegal at that level.","In plugins/tests driving this refactoring programmatically, pre-check with PsiNameHelper.getInstance(project).isIdentifier(innerClassName)."],"exampleFix":"// before\nString innerClassName = \"request-params\"; // user typed dashed name\n\n// after\nString innerClassName = \"requestParams\";\nassert PsiNameHelper.getInstance(project).isIdentifier(innerClassName);","handlingStrategy":"validation","validationCode":"PsiNameHelper helper = PsiNameHelper.getInstance(project);\nString innerClassName = myInnerClassNameTextField.getText().trim();\nif (!helper.isIdentifier(innerClassName)) {\n  Messages.showErrorDialog(project, \"Invalid inner class name: \" + innerClassName, \"Introduce Parameter Object\");\n  return; // do not open/confirm the dialog\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-fill the inner-class-name field with the suggested 'XxxParams' identifier so users rarely type from scratch.","Validate on focus-lost in custom UIs so the error surfaces before OK."],"tags":["intellij","refactoring","java","validation","identifier","inner-class"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}