javafx 中使用了什么 javascript 引擎?
What javascript engine used inside javafx?
WebView 具有内置的 javascript 引擎。它使用什么引擎? openjdk和oraclejdk是一样的吗?可以和WebView分开使用,就像JSR 223引擎一样吗?
更新
由于OP更关心JavaFX WebView,所以使用JavaScriptCore
. Please read 更好理解
JavaFX Webkit does not use Nashorn, it uses JavaScriptCore
Oracle Nashorn
是Java8中的Java脚本引擎,直到Java7,使用的Java脚本引擎是基于Mozilla Rhino
.
是的,Oracle JDK 和 OpenJDK 是一样的。
您可以在 Oracle Site.
上找到有关 Nashorn 的更多信息
JavaOracle JRE 中的脚本运行时
完整的 Oracle Java Runtime 8 附带两个 Java脚本引擎:
- Nashorn: "Nashorn's goal is to implement a lightweight high-performance JavaScript runtime in Java with a native JVM. This Project intends to enable Java developers embedding of JavaScript in Java applications via JSR-223 and to develop free standing JavaScript applications using the jrunscript command-line tool."
- JavaScriptCore: The JavaScript engine built into the WebKit implementation wrapped by WebView 组成 JavaFX 系统。
JavaWebView 和 JavaFX 应用程序使用的脚本运行时
JavaFX Webkit 不使用 Nashorn,它使用 JavaScriptCore.
您可以使用 Nashorn to program JavaFX applications and APIs (as an alternative to programming in Java) 并且可以将 Nashorn 用作 JavaFX FXML 文档的 JavaFX 脚本引擎,但不能将 Nashorn 用作 Java WebView 中的脚本引擎。
背景源信息
JavaFX 邮件列表中的 JavaFX 开发人员提供了一些 information on the JavaScript implementation in WebView。引用 Oracle JavaFX 开发人员 Richard Bair(他反过来引用 WebKit 开发人员 Olivier Hunt)的话:
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
免责声明
此答案仅与 Oracle Java 8 个版本相关;备用和未来 JavaFX 和 Java 实现可能具有不同的内部实现。
May it be used separately from WebView, just as JSR 223 engine?
JavaWebView 中的ScriptCore 不能作为JSR 223 引擎(据我所知)与WebView 分开使用。
我认为最好将支持 WebView 的 JavaScriptCore 实现视为 WebView 组件的内部实现细节,而不是将 JavaScript 实现视为通用目的 Java在别处使用的脚本运行时。除了在 WebView 中的特定用途之外,它不是官方支持的组件,并且当在那里使用时,public WebView API 使您免受它使用的 JavaScript 运行时的实现细节的影响: 这样一来,Java脚本运行时实际上用于在 WebView 组件内执行 Java脚本的用户故意不透明。
WebView 具有内置的 javascript 引擎。它使用什么引擎? openjdk和oraclejdk是一样的吗?可以和WebView分开使用,就像JSR 223引擎一样吗?
更新
由于OP更关心JavaFX WebView,所以使用JavaScriptCore
. Please read
JavaFX Webkit does not use Nashorn, it uses JavaScriptCore
Oracle Nashorn
是Java8中的Java脚本引擎,直到Java7,使用的Java脚本引擎是基于Mozilla Rhino
.
是的,Oracle JDK 和 OpenJDK 是一样的。
您可以在 Oracle Site.
上找到有关 Nashorn 的更多信息JavaOracle JRE 中的脚本运行时
完整的 Oracle Java Runtime 8 附带两个 Java脚本引擎:
- Nashorn: "Nashorn's goal is to implement a lightweight high-performance JavaScript runtime in Java with a native JVM. This Project intends to enable Java developers embedding of JavaScript in Java applications via JSR-223 and to develop free standing JavaScript applications using the jrunscript command-line tool."
- JavaScriptCore: The JavaScript engine built into the WebKit implementation wrapped by WebView 组成 JavaFX 系统。
JavaWebView 和 JavaFX 应用程序使用的脚本运行时
JavaFX Webkit 不使用 Nashorn,它使用 JavaScriptCore.
您可以使用 Nashorn to program JavaFX applications and APIs (as an alternative to programming in Java) 并且可以将 Nashorn 用作 JavaFX FXML 文档的 JavaFX 脚本引擎,但不能将 Nashorn 用作 Java WebView 中的脚本引擎。
背景源信息
JavaFX 邮件列表中的 JavaFX 开发人员提供了一些 information on the JavaScript implementation in WebView。引用 Oracle JavaFX 开发人员 Richard Bair(他反过来引用 WebKit 开发人员 Olivier Hunt)的话:
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
免责声明
此答案仅与 Oracle Java 8 个版本相关;备用和未来 JavaFX 和 Java 实现可能具有不同的内部实现。
May it be used separately from WebView, just as JSR 223 engine?
JavaWebView 中的ScriptCore 不能作为JSR 223 引擎(据我所知)与WebView 分开使用。
我认为最好将支持 WebView 的 JavaScriptCore 实现视为 WebView 组件的内部实现细节,而不是将 JavaScript 实现视为通用目的 Java在别处使用的脚本运行时。除了在 WebView 中的特定用途之外,它不是官方支持的组件,并且当在那里使用时,public WebView API 使您免受它使用的 JavaScript 运行时的实现细节的影响: 这样一来,Java脚本运行时实际上用于在 WebView 组件内执行 Java脚本的用户故意不透明。