From 08c64ab031d0c120eaa4d014c4f107f8a347d9c6 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch Date: Wed, 6 Mar 2019 07:09:59 +0000 Subject: 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. --- src/main/java/org/javacs/Lib.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/javacs/Lib.java b/src/main/java/org/javacs/Lib.java index 61c5bc4..083e69c 100644 --- a/src/main/java/org/javacs/Lib.java +++ b/src/main/java/org/javacs/Lib.java @@ -3,18 +3,25 @@ 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 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(); + .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(); }); } -- cgit v1.2.3