quarkusio/quarkus · error · IllegalArgumentException
${name} is not a valid class name
Error message
${name} is not a valid class name What it means
checkClassName validates a proposed class name using javax.lang.model.SourceVersion.isName, which rejects invalid identifiers and Java keywords. If the name is not a syntactically valid (possibly qualified) Java name, an IllegalArgumentException with this message is thrown before project generation proceeds.
Source
Thrown at independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/CreateProjectHelper.java:132
}
return catalog;
}
private static boolean isFullArtifactCoords(String s) {
if (s == null) {
return false;
}
var firstColon = s.indexOf(':');
if (firstColon > 0) {
var lastColon = s.lastIndexOf(':');
return lastColon > 0 && firstColon != lastColon;
}
return false;
}
public static String checkClassName(String name) {
if (!SourceVersion.isName(name)) { // checks for valid identifiers & use of keywords
throw new IllegalArgumentException(name + " is not a valid class name");
}
return name;
}
public static String checkPackageName(String name) {
if (!SourceVersion.isName(name)) { // checks for valid identifiers & use of keywords
throw new IllegalArgumentException(name + " is not a valid package name");
}
return name;
}
public static Path checkProjectRootPath(Path outputPath, String name) {
requireNonNull(name, "Must specify project name");
requireNonNull(outputPath, "Must specify output path");
Path projectRootPath = outputPath.resolve(name);
if (projectRootPath.toFile().exists()) {
throw new IllegalArgumentException(View on GitHub (pinned to e1c734241f)
Solutions
- Provide a valid Java class name (CamelCase identifier, not a keyword)
- Convert project-name style values: 'my-app' → 'MyApp'
- Pre-validate the class name with SourceVersion.isName before invoking
Example fix
// before
createProject.className("my-app")
// after
createProject.className("MyApp") Defensive patterns
Strategy: validation
Validate before calling
import javax.lang.model.SourceVersion; if (name == null || !SourceVersion.isName(name)) throw new IllegalArgumentException(name + " is not a valid class name");
Try / catch
try { helper.checkClassName(name); } catch (IllegalArgumentException e) { name = sanitizeToCamelCase(name); } Prevention
- Derive class names from project names with a camelCase conversion
- Reject names with hyphens, spaces, or leading digits at input time
- Check against Java reserved keywords before passing to the API
When it happens
Trigger: Calling CreateProject with a className value (or via checkClassName directly) that is not a valid Java identifier chain — e.g. starts with a digit, contains hyphens/spaces, or is a reserved keyword like 'class' or 'new'.
Common situations: Users passing the project name (e.g. 'my-app') as a class name; names with dashes from CLI conventions; keyword collisions; leading digits.
Related errors
- ${name} is not a valid package name
- The app name '%s' is not valid. The <appName> only allow alp
- Invalid global variable name found: %s - supplied by %s -
- The timestamp must be positive
- The timestamp must be positive
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/dded1b7d4e665d5e.
Report an issue: GitHub.