{"record":{"id":"dc062dd7434dd047","repo":"quarkusio/quarkus","slug":"failed-to-read-or-parse-module-info-class","errorCode":null,"errorMessage":"Failed to read or parse module-info.class","messagePattern":"Failed to read or parse module-info\\.class","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/app-model/src/main/java/io/quarkus/maven/dependency/ResolvedDependency.java","lineNumber":105,"sourceCode":"            return isJar() ? PathTree.ofDirectoryOrArchive(p, pathFilter) : PathTree.ofDirectoryOrFile(p, pathFilter);\n        }\n        final PathTree[] trees = new PathTree[paths.size()];\n        int i = 0;\n        for (Path p : paths) {\n            trees[i++] = PathTree.ofDirectoryOrArchive(p, pathFilter);\n        }\n        return new MultiRootPathTree(trees);\n    }\n\n    static String computeModuleName(ResolvedDependency dep) {\n        // first, see if there is a descriptor\n        PathTree contentTree = dep.getContentTree();\n        if (contentTree.contains(\"module-info.class\")) {\n            ClassModel cm = contentTree.apply(\"module-info.class\", pv -> {\n                try {\n                    return ClassFile.of().parse(Files.readAllBytes(pv.getPath()));\n                } catch (IOException e) {\n                    throw new IllegalStateException(\"Failed to read or parse module-info.class\", e);\n                }\n            });\n            Optional<ModuleAttribute> optModAttr = cm.findAttribute(Attributes.module());\n            if (optModAttr.isPresent()) {\n                return optModAttr.get().moduleName().name().stringValue();\n            }\n        }\n        // next, see if there is an explicit automatic module name in the manifest\n        ManifestAttributes ma = contentTree.getManifestAttributes();\n        if (ma != null) {\n            String moduleName = ma.automaticModuleName();\n            if (moduleName != null) {\n                return moduleName;\n            }\n        }\n        // next, see if we have a (temporary) policy-defined module name for this artifact\n        String groupId = dep.getGroupId();\n        String artifactId = dep.getArtifactId();","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/maven/dependency/ResolvedDependency.java#L87-L123","documentation":"ResolvedDependency.computeModuleName inspects a dependency's content tree for module-info.class to determine its JPMS module name. If the file exists but cannot be read (I/O error) or parsed (invalid class file), IllegalStateException is thrown wrapping the underlying cause.","triggerScenarios":"Calling computeModuleName() on a ResolvedDependency whose content tree contains module-info.class but where Files.readAllBytes fails (I/O error, deleted/corrupt artifact) or ClassFile.of().parse rejects the bytes (corrupt or non-class-file content).","commonSituations":"Corrupted Maven repository cache (~/.m2) after interrupted downloads; truncated jar files; artifacts whose module-info.class is malformed; filesystem errors on networked or read-only mounts.","solutions":["Delete the affected artifact from the local Maven repository and re-download (mvn -U or clean the ~/.m2/repository entry)","Verify the jar is not truncated: unzip -t path/to.jar to test archive integrity","Check disk space and filesystem health on the machine/repo mount","Open the wrapped cause (e.getCause()) in logs to distinguish read failure vs parse failure"],"exampleFix":"// before\nString name = dep.computeModuleName(); // throws if artifact is corrupt\n// after\nif (dep.getContentTree().contains(\"module-info.class\")) {\n    try {\n        String name = dep.computeModuleName();\n    } catch (IllegalStateException e) {\n        throw new RuntimeException(\"Re-download artifact \" + dep.getGroupId() + \":\" + dep.getArtifactId(), e);\n    }\n}","handlingStrategy":"try-catch","validationCode":"// pre-check artifact integrity before resolution\nPath jar = Path.of(repoDir, \"io/quarkus/quarkus-core/.../quarkus-core.jar\");\nboolean looksOk = Files.exists(jar) && Files.size(jar) > 0; // full zip test: ZipUtils.openReadOnly(jar).close()","typeGuard":null,"tryCatchPattern":"try {\n    String name = dep.computeModuleName();\n} catch (IllegalStateException e) {\n    throw new IllegalStateException(\"Artifact corrupt; delete it from the local repo and re-resolve\", e);\n}","preventionTips":["Clear corrupted entries from ~/.m2/repository and re-run with -U","Test jar integrity (unzip -t) after suspicious downloads","Watch disk space on machines running builds","Log the wrapped cause to distinguish read vs parse failures"],"tags":["classpath","jpms","corrupt-artifact","io"],"backgroundTag":"corrupt-artifact-cache","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"}