private Map loadCache()

in src/main/java/org/apache/maven/plugin/compiler/IncrementalBuild.java [434:472]


    private Map<Path, SourceInfo> loadCache() throws IOException {
        final Map<Path, SourceInfo> previousBuild;
        try (DataInputStream in = new DataInputStream(
                new BufferedInputStream(Files.newInputStream(cacheFile, StandardOpenOption.READ)))) {
            if (in.readLong() != MAGIC_NUMBER) {
                throw new IOException("Invalid cache file.");
            }
            previousBuildTime = in.readLong();
            previousOptionsHash = in.readInt();
            int remaining = in.readInt();
            previousBuild = new HashMap<>(remaining + remaining / 3);
            Path srcDir = null;
            Path tgtDir = null;
            Path srcFile = null;
            while (--remaining >= 0) {
                final byte flags = in.readByte();
                if ((flags & ~ALL_FLAGS) != 0) {
                    throw new IOException("Invalid cache file.");
                }
                boolean newSrcDir = (flags & NEW_SOURCE_DIRECTORY) != 0;
                boolean newTgtDir = (flags & NEW_TARGET_DIRECTORY) != 0;
                boolean newOutput = (flags & EXPLICIT_OUTPUT_FILE) != 0;
                boolean omitted = (flags & OMITTED_OUTPUT_FILE) != 0;
                Path output = null;
                if (newSrcDir) srcDir = Path.of(in.readUTF());
                if (newTgtDir) tgtDir = Path.of(in.readUTF());
                if (newOutput) output = Path.of(in.readUTF());
                String path = in.readUTF();
                srcFile = newSrcDir ? srcDir.resolve(path) : srcFile.resolveSibling(path);
                srcFile = srcFile.normalize();
                var info = new SourceInfo(srcDir, tgtDir, output, omitted, in.readLong());
                if (previousBuild.put(srcFile, info) != null) {
                    throw new IOException("Duplicated source file declared in the cache: " + srcFile);
                }
            }
        }
        cacheLoaded = true;
        return previousBuild;
    }