{"record":{"id":"da73d42a384ab5b0","repo":"quarkusio/quarkus","slug":"name-cannot-start-with-name","errorCode":null,"errorMessage":"Name cannot start with '/':${name}","messagePattern":"Name cannot start with '/':(.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/deployment/src/main/java/io/quarkus/deployment/builditem/GeneratedClassBuildItem.java","lineNumber":34,"sourceCode":" * These generated classes are typically added to the application's class path or packaged into the final artifact.\n */\npublic final class GeneratedClassBuildItem extends MultiBuildItem {\n\n    final boolean applicationClass;\n    final String name;\n    String binaryName;\n    String internalName;\n    String packageName;\n    final byte[] classData;\n    final String source;\n\n    public GeneratedClassBuildItem(boolean applicationClass, String name, byte[] classData) {\n        this(applicationClass, name, classData, null);\n    }\n\n    public GeneratedClassBuildItem(boolean applicationClass, String name, byte[] classData, String source) {\n        if (name.startsWith(\"/\")) {\n            throw new IllegalArgumentException(\"Name cannot start with '/':\" + name);\n        }\n        this.applicationClass = applicationClass;\n        this.name = name;\n        this.classData = classData;\n        this.source = source;\n    }\n\n    public boolean isApplicationClass() {\n        return applicationClass;\n    }\n\n    /**\n     * {@return the <em>binary name</em> of the class, which is delimited by <code>.</code> characters}\n     */\n    public String binaryName() {\n        String binaryName = this.binaryName;\n        if (binaryName == null) {\n            binaryName = this.binaryName = name.replace('/', '.');","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/deployment/src/main/java/io/quarkus/deployment/builditem/GeneratedClassBuildItem.java#L16-L52","documentation":"GeneratedClassBuildItem represents a class generated at build time. Names must be resource-relative (e.g. \"com/acme/Foo.class\") because the item is later stored in the application's generated classes output; a leading '/' would produce a wrong path. The constructor rejects any name starting with '/' with IllegalArgumentException.","triggerScenarios":"Constructing new GeneratedClassBuildItem(applicationClass, \"/com/acme/Foo.class\", classData) in a build step — i.e. passing a name that begins with a forward slash.","commonSituations":"Extension authors who previously produced byte-code via a resource-style API (where '/path' is conventional) and reused that path string; string concatenation of '/' + name from class-name-to-path conversion code.","solutions":["Strip the leading '/' before constructing the item: name.startsWith(\"/\") ? name.substring(1) : name.","Build the name from the class binary name, e.g. className.replace('.', '/') + \".class\", which never yields a leading slash.","If you control a shared helper that emits resource names, normalize it there so all callers benefit."],"exampleFix":"// before\nString name = \"/\" + className.replace('.', '/') + \".class\";\noutputProducer.produce(new GeneratedClassBuildItem(true, name, bytes));\n// after\nString name = className.replace('.', '/') + \".class\";\noutputProducer.produce(new GeneratedClassBuildItem(true, name, bytes));","handlingStrategy":"validation","validationCode":"String toGeneratedClassName(String className) {\n    String name = className.replace('.', '/') + \".class\";\n    if (name.startsWith(\"/\")) throw new IllegalArgumentException(name);\n    return name;\n}","typeGuard":"boolean isValidGeneratedClassName(String name) {\n    return name != null && !name.isEmpty() && !name.startsWith(\"/\") && name.endsWith(\".class\");\n}","tryCatchPattern":"try {\n    produce(new GeneratedClassBuildItem(true, name, classData));\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Name cannot start with '/'\")) {\n        produce(new GeneratedClassBuildItem(true, name.substring(1), classData));\n        return;\n    }\n    throw e;\n}","preventionTips":["Derive generated class names from binary names via replace('.', '/') + \".class\"","Never concatenate '/' onto resource-style names when switching APIs","Assert in tests that produced names do not start with '/'"],"tags":["quarkus","build-time","bytecode-generation","illegal-argument"],"backgroundTag":"invalid-resource-path","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}