Use Graal JavaScript VM.

Nashorn was removed in JDK15, but the PAC proxy detection code depends on
having a JavaScript VM (what a twisty maze of passages). Rather than remove it
completely, I'll just keep the tests working so that people who use Getdown
with PAC proxies on JDK 14 or earlier can keep on trucking.

Perhaps the JavaScript code could be rewritten in Java and this weird massive
dependency could be eliminated?
This commit is contained in:
Michael Bayne
2021-04-04 12:22:15 -07:00
parent 3a52a42775
commit 1c0320b36d
2 changed files with 16 additions and 0 deletions
+12
View File
@@ -44,6 +44,18 @@
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js</artifactId>
<version>20.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js-scriptengine</artifactId>
<version>20.3.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
@@ -25,6 +25,10 @@ public class ProxyUtilTest {
}
@Test public void testPACProxy () throws Exception {
// we use the Graal JavaScrip VM for testing, because JDK15 no longer bundles Nashorn, but
// it does not support calling back into Java unless we set this compatibility property
System.setProperty("polyglot.js.nashorn-compat", "true");
String EXAMPLE0 =
"function FindProxyForURL(url, host) {\n" +
" if (shExpMatch(host, '*.example.com')) { return 'DIRECT'; }\n" +