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

  1. Provide a valid Java class name (CamelCase identifier, not a keyword)
  2. Convert project-name style values: 'my-app' → 'MyApp'
  3. 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

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


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/dded1b7d4e665d5e. Report an issue: GitHub.