quarkusio/quarkus · error · IllegalStateException

Failed to read or parse module-info.class

Error message

Failed to read or parse module-info.class

What it means

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.

Source

Thrown at independent-projects/bootstrap/app-model/src/main/java/io/quarkus/maven/dependency/ResolvedDependency.java:105

            return isJar() ? PathTree.ofDirectoryOrArchive(p, pathFilter) : PathTree.ofDirectoryOrFile(p, pathFilter);
        }
        final PathTree[] trees = new PathTree[paths.size()];
        int i = 0;
        for (Path p : paths) {
            trees[i++] = PathTree.ofDirectoryOrArchive(p, pathFilter);
        }
        return new MultiRootPathTree(trees);
    }

    static String computeModuleName(ResolvedDependency dep) {
        // first, see if there is a descriptor
        PathTree contentTree = dep.getContentTree();
        if (contentTree.contains("module-info.class")) {
            ClassModel cm = contentTree.apply("module-info.class", pv -> {
                try {
                    return ClassFile.of().parse(Files.readAllBytes(pv.getPath()));
                } catch (IOException e) {
                    throw new IllegalStateException("Failed to read or parse module-info.class", e);
                }
            });
            Optional<ModuleAttribute> optModAttr = cm.findAttribute(Attributes.module());
            if (optModAttr.isPresent()) {
                return optModAttr.get().moduleName().name().stringValue();
            }
        }
        // next, see if there is an explicit automatic module name in the manifest
        ManifestAttributes ma = contentTree.getManifestAttributes();
        if (ma != null) {
            String moduleName = ma.automaticModuleName();
            if (moduleName != null) {
                return moduleName;
            }
        }
        // next, see if we have a (temporary) policy-defined module name for this artifact
        String groupId = dep.getGroupId();
        String artifactId = dep.getArtifactId();

View on GitHub (pinned to e1c734241f)

Solutions

  1. Delete the affected artifact from the local Maven repository and re-download (mvn -U or clean the ~/.m2/repository entry)
  2. Verify the jar is not truncated: unzip -t path/to.jar to test archive integrity
  3. Check disk space and filesystem health on the machine/repo mount
  4. Open the wrapped cause (e.getCause()) in logs to distinguish read failure vs parse failure

Example fix

// before
String name = dep.computeModuleName(); // throws if artifact is corrupt
// after
if (dep.getContentTree().contains("module-info.class")) {
    try {
        String name = dep.computeModuleName();
    } catch (IllegalStateException e) {
        throw new RuntimeException("Re-download artifact " + dep.getGroupId() + ":" + dep.getArtifactId(), e);
    }
}
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-check artifact integrity before resolution
Path jar = Path.of(repoDir, "io/quarkus/quarkus-core/.../quarkus-core.jar");
boolean looksOk = Files.exists(jar) && Files.size(jar) > 0; // full zip test: ZipUtils.openReadOnly(jar).close()

Try / catch

try {
    String name = dep.computeModuleName();
} catch (IllegalStateException e) {
    throw new IllegalStateException("Artifact corrupt; delete it from the local repo and re-resolve", e);
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


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