Thanks, Lars!
I started looking into this, and even set up a sample PAC script and proxy
server to test it (pasted below for future reference). This is on Java 17,
Windows 11, and a custom build of NetBeans Platform 13.0.
In my NetBeans Platform app, I added a dependency on a new JAR wrapper module,
which in turn contains dependencies on org.graalvm.js:js and
org.graalvm.js:js-scriptengine. This makes the NetBeans proxy server code work
on Java 17, using GraalVM.
(It's a 22MB dependency to parse a 12-line configuration file, but it works! :-)
So my conclusion is that the NetBeans proxy server detection code in NetBeans
13 works perfectly on Java 17, so long as GraalVM is included. On the IDE
distribution, this seems to work as well (confirmed with
-J-Dorg.netbeans.core.network.proxy.level=FINEST as suggested), with the
org.netbeans.libs.graaljs module providing the same dependenices.
One question: I see that the org.netbeans.libs.graaljs module also includes
dependencies on js-launcher, regex, graal-sdk, truffle-api, launcher-common,
and icu4j. Do you think I need any of these if I just want my NetBeans Platform
app to be able to parse PAC scripts? (I didn't see any errors from omitting
them.)
Thank you very much to Lars, Jaroslav, and others who were involved with
keeping this code up to date and working!
-- Eirik
=================== Example PAC File =========================
function FindProxyForURL(url, host) {
if (isInNet(host, '127.0.0.1', '255.255.255.255')) {
return "DIRECT";
}
if (dnsDomainIs(host, "slashdot.org")) {
return "SOCKS localhost:1081"; // Will fail.
} else {
// Do some arithmetic to confirm that a JavaScript interpreter is really
running.
return "SOCKS localhost:" + (1000 + 80);
}
}
==== Example SSH Command to Set Up A Proxy Server ==============
ssh -ND 1080 some_server_you_can_ssh_into.com
==== Dependencies in pom.xml =================== ==============
<dependencies>
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js</artifactId>
<version>22.1.0</version>
</dependency>
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js-scriptengine</artifactId>
<version>22.1.0</version>
</dependency>
</dependencies>
===========================================================
-----Original Message-----
From: Lars Bruun-Hansen <[email protected]>
Sent: Saturday, May 14, 2022 3:38 AM
To: [email protected]
Subject: Re: State of proxy server auto-detection in NetBeans? (PAC scripts,
Nashorn/Rhino/GraalVM etc.)
Hi Eirik
From memory: It was only like 6 months after my Rhino-->Nashorn update/rewrite
was integrated into the NB code base that Oracle announced that Nashorn would
eventually be removed from the JDK.
Jarouslav Tulach kindly took upon him to make sure NB would use a more robust
approach where Graal's Javascript engine is used if available and Nashorn is
the fallback.
Have a look:
https://github.com/apache/netbeans/blob/master/platform/core.network/src/org/netbeans/core/network/proxy/pac/impl/NbPacScriptEvaluator.java#L348
With a log level of FINE you should be able to see exactly which Javascript
engine is in use in your own case:
https://github.com/apache/netbeans/blob/master/platform/core.network/src/org/netbeans/core/network/proxy/pac/impl/NbPacScriptEvaluator.java#L284
So you can start your IDE with something like this:
-J-Dorg.netbeans.core.network.proxy.level=FINEST
to see what is in effect. However, you'll not see anything related to PAC
evaluation unless NetBeans actually discovers a PAC file in the network.
Kind regards
Lars
On Mon, May 9, 2022 at 10:42 PM Eirik Bakke <[email protected]> wrote:
>
> Hi, NetBeans friends.
>
>
>
> Back in NetBeans 9.0, Lars Bruun-Hansen integrated a brand new proxy
> server auto-detection system [1], based on the earlier netbeansproxy2
> project(?)
>
>
>
> Does this still work in Java 17?
>
> In NetBeans Platform applications, are there dependencies that need to be
> bundled beyond OpenJDK, in order for this to work?
>
>
>
> I have heard about Nashorn, Rhino, and GraalVM, one of which seem to have
> been required to execute proxy server PAC configuration scripts (which are
> apparently pieces of JavaScript). Which of these three are we using these
> days? Is the JavaScript engine a part of OpenJDK, or must it be bundled
> externally?
>
>
>
> -- Eirik
>
> [1] https://issues.apache.org/jira/browse/NETBEANS-96
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists