JetBrains/intellij-community · warning · ConfigurationException
Not a valid java identifier part in prefix '{0}'
Error message
Not a valid java identifier part in prefix '{0}' What it means
setPrefixSuffix in the Java code-style generation settings validates the 'Name prefix'/'Name suffix' fields: after trimming, a non-empty value must be a full Java identifier (StringUtil.isJavaIdentifier). If it is not, a ConfigurationException is thrown with this message, so the Settings dialog reports the field in error and refuses to apply. The prefix/suffix is spliced into generated identifiers (e.g. 'my' prefix -> 'myField'), hence the identifier constraint.
Source
Thrown at java/java-impl/src/com/intellij/application/options/CodeStyleGenerationConfigurable.java:569
javaSettings.REPLACE_SUM = myReplaceSumCb.isSelected();
myCommenterForm.apply(settings);
javaSettings.setRepeatAnnotations(myRepeatAnnotationsModel.getItems());
for (Project project : ProjectManager.getInstance().getOpenProjects()) {
DaemonCodeAnalyzer.getInstance(project).settingsChanged();
}
}
private static String setPrefixSuffix(String text, boolean prefix) throws ConfigurationException {
text = text.trim();
if (text.isEmpty()) return text;
if (!StringUtil.isJavaIdentifier(text)) {
final @Nls String message = JavaBundle.message(prefix
? "code.style.generation.settings.error.not.valid.identifier.part.in.prefix"
: "code.style.generation.settings.error.not.valid.identifier.part.in.suffix", text);
throw new ConfigurationException(message);
}
return text;
}
@Override
public void apply() throws ConfigurationException {
apply(mySettings);
}
public boolean isModified(CodeStyleSettings settings) {
JavaCodeStyleSettings javaSettings = settings.getCustomSettings(JavaCodeStyleSettings.class);
boolean isModified = isCheckboxModified(myCbPreferLongerNames, javaSettings.PREFER_LONGER_NAMES);
isModified |= isFieldModified(myFieldPrefixField, javaSettings.FIELD_NAME_PREFIX);
isModified |= isFieldModified(myStaticFieldPrefixField, javaSettings.STATIC_FIELD_NAME_PREFIX);
isModified |= isFieldModified(myParameterPrefixField, javaSettings.PARAMETER_NAME_PREFIX);
isModified |= isFieldModified(myLocalVariablePrefixField, javaSettings.LOCAL_VARIABLE_NAME_PREFIX);
isModified |= isFieldModified(mySubclassPrefix, javaSettings.SUBCLASS_NAME_PREFIX);View on GitHub (pinned to be881553f2)
Solutions
- Enter only characters legal in a Java identifier: letters, digits (not first), '$' and '_' — e.g. 'my' or 'm'.
- Clear the field entirely if you do not want a prefix/suffix (empty is accepted after trim).
- Remember the value is prepended/appended verbatim to generated member names, so keep it a plain identifier fragment.
Example fix
// before (Settings input, rejected) name prefix: "my." // after name prefix: "my"
Defensive patterns
Strategy: validation
Validate before calling
// Before calling apply() programmatically or writing settings:
String prefix = myPrefixField.getText().trim();
if (!prefix.isEmpty() && !com.intellij.openapi.util.text.StringUtil.isJavaIdentifier(prefix)) {
Messages.showErrorDialog("Name prefix must be a valid Java identifier", "Invalid Input");
return;
} Try / catch
try { configurable.apply(); } catch (ConfigurationException e) { Messages.showErrorDialog(e.getMessage(), "Cannot Apply"); } Prevention
- Only letters, digits (not first), '_' and '$' in prefix/suffix fields
- Trim input before validating; empty is allowed
- Avoid dots/hyphen — they are never legal in generated identifiers
When it happens
Trigger: Typing a non-identifier value such as 'my.', 'a-b', '1x', or 'get()' into Settings | Editor | Code Style | Java | Code Generation name prefix/suffix fields and pressing Apply/OK.
Common situations: Trying to use a dotted or hyphenated prefix; pasting text with trailing punctuation; attempting to simulate a full naming scheme (e.g. 'mFoo') that is not a bare identifier.
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/be474ff0f16b1cc0.
Report an issue: GitHub.