package org.javacs;

import java.io.File;
import java.lang.System;
import java.util.Optional;
import java.nio.file.*;

class Lib {
    static Optional<Path> srcZipPath() {
        return Optional.ofNullable(System.getenv("JAVA_HOME"))
            .flatMap(home -> Optional.of(Paths.get(home).resolve("lib/src.zip")))
            .flatMap(path -> {
                if (path.toFile().exists()) {
                    return Optional.of(path);
                } else {
                    return Optional.empty();
                }
            });
    }

    static final Optional<Path> SRC_ZIP = srcZipPath();
}

package org.javacs;

import java.io.File;
import java.lang.System;
import java.util.Optional;
import java.util.Arrays;
import java.nio.file.*;

class Lib {
    static Optional<Path> srcZipPath() {
        return Optional.ofNullable(System.getenv("JAVA_HOME"))
            .map(home -> {
                return Arrays.asList(new Path[]{
                    Paths.get(home).resolve("lib/src.zip"),
                    Paths.get(home).resolve("src.zip"),
                });
            })
            .flatMap(paths -> {
                for (Path path : paths) {
                    if (path.toFile().exists()) {
                        return Optional.of(path);
                    }
                }
                return Optional.empty();
            });
    }

    static final Optional<Path> SRC_ZIP = srcZipPath();
}

Support other locations for finding src.zip
Support other locations for finding src.zip

What
===
Support other locations for finding src.zip so that it is found it if
lives at either:
 - JAVA_HOME/lib/src.zip
 - JAVA_HOME/src.zip

Why
===
I've observed in testing that some installations of JVMs include src.zip
in the root, others in a lib/src.zip.
