quarkusio/quarkus · error · UncheckedIOException

Failed to read bytecode ${path}

Error message

Failed to read bytecode ${path}

What it means

The tree-shaking input supplier lazily reads a class file's bytecode from the jar being analyzed (with filtered output). If Files.newInputStream throws an IOException (file missing, unreadable, corrupt), it wraps it in UncheckedIOException with the path, aborting the jar tree-shaking step.

Source

Thrown at core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/JarTreeShakeInput.java:708

        final long size;

        BytecodeSupplier(Path path) {
            this.path = path;
            long s = 0;
            try {
                s = Files.size(path);
            } catch (IOException e) {
                // ignore, size is only used for reporting
            }
            this.size = s;
        }

        @Override
        public byte[] get() {
            try (InputStream is = Files.newInputStream(path)) {
                return is.readAllBytes();
            } catch (IOException e) {
                throw new UncheckedIOException("Failed to read bytecode " + path, e);
            }
        }
    }
}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Run mvn clean install (or clean package) to rebuild the exploded jar from scratch.
  2. Check permissions/read-only flags on the target build directory.
  3. Delete the affected dependency from ~/.m2 and re-resolve (mvn -U) if the source jar is corrupt.
  4. Exclude the build directory from antivirus real-time scanning.
  5. Avoid running two builds concurrently on the same project.

Example fix

# before
$ mvn package
# after
$ mvn clean package  # regenerates the exploded jar the tree-shaker reads
Defensive patterns

Strategy: try-catch

Validate before calling

import java.nio.file.*;
Path path = Path.of("target/...");
if (!Files.isReadable(path)) throw new IllegalStateException("Bytecode file not readable: " + path);
if (Files.size(path) == 0) throw new IllegalStateException("Bytecode file empty: " + path);

Try / catch

try {
    // tree-shaking-enabled build
} catch (UncheckedIOException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("Failed to read bytecode")) {
        log.error("Corrupt/missing exploded jar, clean rebuild recommended", e);
    } else throw e;
}

Prevention

When it happens

Trigger: JarTreeShakeInput's BytecodeSupplier.get() is invoked (typically by the bytecode analysis consumer) and the class file path inside the exploded/temp jar cannot be opened: deleted temp files, permission errors, or a truncated jar extraction.

Common situations: Antivirus or another process deleting temp files mid-build; read-only build directories; corrupted dependency jars in ~/.m2; partially cleaned target directories during concurrent builds.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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