WebView has built-in javascript engine. What engine is used for it? Is it the same for openjdk and oracle jdk? May it be used separately from WebView, just as JSR 223 engine
Update
Since OP is more concerned about JavaFX WebView, it uses JavaScriptCore. Please read JewelSea's answer for a better understanding.
JavaFX Webkit does not use Nashorn, it uses JavaScriptCore
Oracle Nashorn
is the JavaScript engine in Java 8. Until Java 7, the JavaScript engine used was based on Mozilla Rhino
.
Yes, it is same for Oracle JDK and OpenJDK.
You can find more information on Nashorn on the Oracle Site.
JavaScript Runtimes in the Oracle JRE
The full Oracle Java Runtime 8 ships with two JavaScript engines:
JavaScript Runtime Used by WebView and JavaFX applications
JavaFX Webkit does not use Nashorn, it uses JavaScriptCore.
You can use Nashorn to program JavaFX applications and APIs (as an alternative to programming in Java) and you can use Nashorn as a JavaFX script engine for JavaFX FXML documents, but you cannot use Nashorn as the JavaScript engine within WebView.
Background Source Information
There is some information on the JavaScript implementation in WebView provided by the JavaFX developers on the JavaFX mailing list. Quoting Richard Bair, an Oracle JavaFX developer (who in turn quotes Olivier Hunt, a WebKit Developer):
Well…. it goes like this. WebKit comes with JavaScriptCore by default, and this is the JS engine that we use. It is pretty good. My understanding is that JavaScriptCore (aka SquirrelFish aka Nitro) is the same JS engine used by Safari. When Chrome and Apple were both part of WebKit, one of the abstraction layers that Google had put into WebKit was the ability to swap out the JavaScript engine. When Google forked WebKit into Blink, the need for the WebKit project to have an abstraction for a different JS VM disappeared. As a consequence, the WebKit guys have been talking about removing those abstractions such that you won't be able to swap out the JS engine, [further info]. If/When that happens, it will be hard (or impossible) for us to switch over to Nashorn for WebView. We aren't going to fork WebKit, so we sort of have to follow along with what WebKit does.
"Supporting V8 places a considerable burden on webkit, there are a number of large, cumbersome and expensive abstractions required for to support multiple JS engines (see the original discussions on the topic from many years ago).
Additionally we will only be supporting JSC in WebKit2, so I don't think anything could convince me at least that maintaining support for multiple JS engines is good for the project." - Oliver Hunt
Disclaimer
This answer is related to Oracle Java 8 releases only; alternate and future JavaFX and Java implementations may have different internal implementations.
May it be used separately from WebView, just as JSR 223 engine?
JavaScriptCore in WebView cannot be used separately from WebView as a JSR 223 engine (as far as I know).
I think it is best to treat the JavaScriptCore implementation shipped to support WebView as an internal implementation detail of the WebView component and not treat the JavaScript implementation as a general purpose JavaScript Runtime to be used elsewhere. It is not an officially supported component outside of its specific use within WebView, and, when used there, the public WebView API shields you from the implementation details of the JavaScript runtime it uses: Such that it is deliberately opaque to users which JavaScript runtime is actually used to execute JavaScript within the WebView component.