{"record":{"id":"dded1b7d4e665d5e","repo":"quarkusio/quarkus","slug":"name-is-not-a-valid-class-name","errorCode":null,"errorMessage":"${name} is not a valid class name","messagePattern":"(.+?) is not a valid class name","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/CreateProjectHelper.java","lineNumber":132,"sourceCode":"        }\n        return catalog;\n    }\n\n    private static boolean isFullArtifactCoords(String s) {\n        if (s == null) {\n            return false;\n        }\n        var firstColon = s.indexOf(':');\n        if (firstColon > 0) {\n            var lastColon = s.lastIndexOf(':');\n            return lastColon > 0 && firstColon != lastColon;\n        }\n        return false;\n    }\n\n    public static String checkClassName(String name) {\n        if (!SourceVersion.isName(name)) { // checks for valid identifiers & use of keywords\n            throw new IllegalArgumentException(name + \" is not a valid class name\");\n        }\n        return name;\n    }\n\n    public static String checkPackageName(String name) {\n        if (!SourceVersion.isName(name)) { // checks for valid identifiers & use of keywords\n            throw new IllegalArgumentException(name + \" is not a valid package name\");\n        }\n        return name;\n    }\n\n    public static Path checkProjectRootPath(Path outputPath, String name) {\n        requireNonNull(name, \"Must specify project name\");\n        requireNonNull(outputPath, \"Must specify output path\");\n\n        Path projectRootPath = outputPath.resolve(name);\n        if (projectRootPath.toFile().exists()) {\n            throw new IllegalArgumentException(","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/CreateProjectHelper.java#L114-L150","documentation":"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.","triggerScenarios":"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'.","commonSituations":"Users passing the project name (e.g. 'my-app') as a class name; names with dashes from CLI conventions; keyword collisions; leading digits.","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"],"exampleFix":"// before\ncreateProject.className(\"my-app\")\n// after\ncreateProject.className(\"MyApp\")","handlingStrategy":"validation","validationCode":"import javax.lang.model.SourceVersion;\nif (name == null || !SourceVersion.isName(name)) throw new IllegalArgumentException(name + \" is not a valid class name\");","typeGuard":null,"tryCatchPattern":"try { helper.checkClassName(name); } catch (IllegalArgumentException e) { name = sanitizeToCamelCase(name); }","preventionTips":["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"],"tags":["validation","naming","java"],"backgroundTag":"invalid-class-name","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}