@@ -83,6 +83,7 @@ UnaryOperator<ProcessBuilder> tweaks =
83
83
redirectError ? p -> p.redirectErrorStream(true) : UnaryOperator.identity();
84
84
85
85
import static java.nio.file.Files.createTempFile;
86
+ import static java.nio.file.Files.walk;
86
87
import static java.nio.file.Files.write;
87
88
import java.nio.file.Path;
88
89
import static java.nio.file.Paths.get;
@@ -114,16 +115,28 @@ import com.sun.net.httpserver.HttpServer;
114
115
if ( Boolean.getBoolean("extractFiles") )
115
116
Node.main(new String[0]); // extract the files
116
117
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
+ }
120
133
121
134
Path libjvm = (
122
135
"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))
125
138
.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")
127
140
);
128
141
129
142
// Use deprecated major() here because feature() first appears in Java 10
@@ -347,7 +360,7 @@ try (
347
360
" END"
348
361
);
349
362
350
- tryForbiddenRead.setString(1, javaHome);
363
+ tryForbiddenRead.setString(1, javaHome.toString() );
351
364
352
365
succeeding &= stateMachine(
353
366
"try to read a forbidden property",
0 commit comments