@@ -83,6 +83,7 @@ UnaryOperator<ProcessBuilder> tweaks =
8383 redirectError ? p -> p.redirectErrorStream(true) : UnaryOperator.identity();
8484
8585import static java.nio.file.Files.createTempFile;
86+ import static java.nio.file.Files.walk;
8687import static java.nio.file.Files.write;
8788import java.nio.file.Path;
8889import static java.nio.file.Paths.get;
@@ -114,16 +115,28 @@ import com.sun.net.httpserver.HttpServer;
114115if ( Boolean.getBoolean("extractFiles") )
115116 Node.main(new String[0]); // extract the files
116117
117- String javaHome = System.getProperty("java.home");
118-
119- Path javaLibDir = get(javaHome, s_isWindows ? "bin" : "lib");
118+ Path javaHome = get(System.getProperty("java.home"));
119+
120+ Path libjvmHunt() { // on Windows, location seems to have been inconsistent
121+ Path target = get("jvm.dll");
122+ return
123+ Stream.of("bin", "lib").map(javaHome::resolve).flatMap(r -> {
124+ try {
125+ return walk(r, 2);
126+ }
127+ catch ( IOException e ) {
128+ throw new UncheckedIOException(e);
129+ }
130+ })
131+ .filter(p -> p.endsWith(target)).findFirst().get();
132+ }
120133
121134Path libjvm = (
122135 "Mac OS X".equals(System.getProperty("os.name"))
123- ? Stream.of("libjli.dylib", "jli/libjli.dylib")
124- .map(s -> javaLibDir .resolve(s))
136+ ? Stream.of("lib/ libjli.dylib", "lib/ jli/libjli.dylib")
137+ .map(s -> javaHome .resolve(s))
125138 .filter(Files::exists).findFirst().get()
126- : javaLibDir.resolve( s_isWindows ? "jvm.dll" : " server/libjvm.so")
139+ : s_isWindows ? libjvmHunt() : javaHome.resolve("lib/ server/libjvm.so")
127140);
128141
129142// Use deprecated major() here because feature() first appears in Java 10
@@ -347,7 +360,7 @@ try (
347360 " END"
348361 );
349362
350- tryForbiddenRead.setString(1, javaHome);
363+ tryForbiddenRead.setString(1, javaHome.toString() );
351364
352365 succeeding &= stateMachine(
353366 "try to read a forbidden property",
0 commit comments