{"record":{"id":"1606acc4b9d913fd","repo":"quarkusio/quarkus","slug":"s-is-not-a-valid-resource-name-as-it-doesn-t-end","errorCode":null,"errorMessage":"%s is not a valid resource name as it doesn't end with .class","messagePattern":"(.+?) is not a valid resource name as it doesn't end with \\.class","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/classloader-commons/src/main/java/io/quarkus/commons/classloading/ClassLoaderHelper.java","lineNumber":36,"sourceCode":"     *\n     * @param className\n     * @return the name of the respective resource\n     */\n    public static String fromClassNameToResourceName(final String className) {\n        //Important: avoid indy!\n        return className.replace('.', '/').concat(CLASS_SUFFIX);\n    }\n\n    /**\n     * Helper method to convert a resource name into the corresponding class name:\n     * replace all \"/\" with \".\" and remove the \".class\" postfix.\n     *\n     * @param resourceName\n     * @return the name of the respective class\n     */\n    public static String fromResourceNameToClassName(final String resourceName) {\n        if (!resourceName.endsWith(CLASS_SUFFIX)) {\n            throw new IllegalArgumentException(\n                    String.format(\"%s is not a valid resource name as it doesn't end with .class\", resourceName));\n        }\n\n        return resourceName.substring(0, resourceName.length() - CLASS_SUFFIX.length()).replace('/', '.');\n    }\n\n    public static boolean isInJdkPackage(String name) {\n        return name.startsWith(JAVA) || name.startsWith(JDK_INTERNAL) || name.startsWith(SUN_MISC);\n    }\n\n    /**\n     * Returns {@code true} if the resource name represents a regular class file,\n     * excluding {@code module-info.class} and {@code package-info.class}.\n     *\n     * @param resourceName the JAR entry path, e.g. {@code com/example/Foo.class}\n     */\n    public static boolean isClassEntry(String resourceName) {\n        return resourceName.endsWith(CLASS_SUFFIX)","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/classloader-commons/src/main/java/io/quarkus/commons/classloading/ClassLoaderHelper.java#L18-L54","documentation":"ClassLoaderHelper.fromResourceNameToClassName() converts a class-file resource name (e.g. 'com/acme/Foo.class') into a class name ('com.acme.Foo') and refuses any resource that doesn't end with the '.class' suffix, throwing IllegalArgumentException. This guards against silently producing garbage class names from non-class resources.","triggerScenarios":"Calling ClassLoaderHelper.fromResourceNameToClassName() with paths like 'com/acme/Foo', 'META-INF/beans.xml', 'com/acme/Foo.class/', or any resource not ending exactly in '.class'.","commonSituations":"Scanning classloader resources and passing every entry to the converter without filtering by suffix; index entries for nested class sources or generated resources mixed in with class files; off-by-one slicing that dropped '.class' before the call.","solutions":["Filter resource names with name.endsWith(\".class\") before calling the method","Strip query/trailing characters (like '/' or '!/...') from resource URLs so the name really ends in '.class'","If the resource is not a class, do not convert it — handle it in a separate code path"],"exampleFix":"// before\nString cn = ClassLoaderHelper.fromResourceNameToClassName(\"META-INF/beans.xml\");\n// after\nif (resource.endsWith(\".class\")) {\n    String cn = ClassLoaderHelper.fromResourceNameToClassName(resource);\n}","handlingStrategy":"validation","validationCode":"String toClassName(String resource) {\n    if (!resource.endsWith(\".class\")) {\n        return null; // not a class resource; skip\n    }\n    return ClassLoaderHelper.fromResourceNameToClassName(resource);\n}","typeGuard":"boolean isClassResource(String name) {\n    return name != null && name.endsWith(\".class\") && !name.endsWith(\".class/\");\n}","tryCatchPattern":"try {\n    return ClassLoaderHelper.fromResourceNameToClassName(resourceName);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().endsWith(\"doesn't end with .class\")) {\n        log.debugf(\"Skipping non-class resource: %s\", resourceName);\n        return null;\n    }\n    throw e;\n}","preventionTips":["Filter scanner/index results with endsWith(\".class\") before conversion","Clean resource URLs of suffixes like '!/...' or trailing '/' before passing them in","Keep non-class resources on a separate processing path"],"tags":["classloading","validation","resources"],"backgroundTag":"invalid-class-resource-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"}