新的 WebView() 导致 "java.lang.UnsupportedOperationException: not implemented"
new WebView() causes "java.lang.UnsupportedOperationException: not implemented"
我无法以编程方式创建新的 WebView。简单地调用 new WebView()
会导致以下异常:
java.lang.ExceptionInInitializerError
at javafx.web/javafx.scene.web.WebEngine.<clinit>(WebEngine.java:339)
at javafx.web/javafx.scene.web.WebView.<init>(WebView.java:260)
// omitting unrelated stacktraces
at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventFilterRecord.handleCapturingEvent(CompositeEventHandler.java:282)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchCapturingEvent(CompositeEventHandler.java:98)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:223)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:180)
at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchCapturingEvent(CompositeEventDispatcher.java:43)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:52)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics/javafx.scene.Scene$KeyHandler.process(Scene.java:4058)
at javafx.graphics/javafx.scene.Scene$KeyHandler.access00(Scene.java:4004)
at javafx.graphics/javafx.scene.Scene.processKeyEvent(Scene.java:2121)
at javafx.graphics/javafx.scene.Scene$ScenePeerListener.keyEvent(Scene.java:2595)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:217)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:149)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleKeyEvent(GlassViewEventHandler.java:248)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:390)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(GlassViewEventHandler.java:247)
at javafx.graphics/com.sun.glass.ui.View.handleKeyEvent(View.java:547)
at javafx.graphics/com.sun.glass.ui.View.notifyKey(View.java:971)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.UnsupportedOperationException: not implemented
at javafx.base/com.sun.javafx.logging.PlatformLogger.getName(PlatformLogger.java:121)
at javafx.web/com.sun.webkit.perf.PerfLogger.fullName(PerfLogger.java:155)
at javafx.web/com.sun.webkit.perf.PerfLogger.registerProbe(PerfLogger.java:201)
at javafx.web/com.sun.webkit.perf.PerfLogger.startCount(PerfLogger.java:227)
at javafx.web/com.sun.webkit.perf.PerfLogger.<init>(PerfLogger.java:90)
at javafx.web/com.sun.webkit.perf.PerfLogger.getLogger(PerfLogger.java:57)
at javafx.web/com.sun.webkit.perf.PerfLogger.getLogger(PerfLogger.java:84)
at javafx.web/com.sun.webkit.Invoker.<clinit>(Invoker.java:34)
... 37 more
这是一个错误吗?我正在使用 OpenJFX 11.0.1 和 OpenJDK 11.0.1。
更新:
如评论中所述,此错误将在 OpenJFX 12 中修复。
这是来自 com.sun.javafx.logging.PlatformLogger
的问题代码:
@Override
public String getName() {
throw new UnsupportedOperationException("not implemented");
}
如您所见,它除了抛出观察到的异常外什么都不做。所有 "implemented" java.lang.System.Logger
方法都是如此。
如果按照您提供的堆栈跟踪概述的代码进行操作,最终会调用 getName
方法,因为 com.sun.webkit.perf.PerfLogger
在初始化 WebEngine
的过程中被实例化并且,推而广之,com.sun.webkit.Invoker
类。但是,getName
仅在启用 PerfLogger
时调用。
粗略地看一下,PerfLogger
包裹了 com.sun.javafx.logging.PlatformLogger
,后者又包裹了 System.Logger
。如果 System.Logger
returns 在构造 PerfLogger
时 isLoggable(System.Logger.Level.FINE)
为真,则启用 PerfLogger
。
在这种情况下,此过程会导致创建一个名为 "com.sun.webkit.perf.Locks"
的 System.Logger
。这意味着如果您将此 System.Logger
配置为不在 Level.FINE
或 "lower" 处记录任何内容,则可以避免 UnsupportedOperationException
。这样做将使 PerfLogger
"disabled" 阻止 getName
被调用。
注:本文基于OpenJFX 11.0.1的源代码。提及的所有内容都是实施细节,如有更改,恕不另行通知。
我无法以编程方式创建新的 WebView。简单地调用 new WebView()
会导致以下异常:
java.lang.ExceptionInInitializerError
at javafx.web/javafx.scene.web.WebEngine.<clinit>(WebEngine.java:339)
at javafx.web/javafx.scene.web.WebView.<init>(WebView.java:260)
// omitting unrelated stacktraces
at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventFilterRecord.handleCapturingEvent(CompositeEventHandler.java:282)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchCapturingEvent(CompositeEventHandler.java:98)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:223)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:180)
at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchCapturingEvent(CompositeEventDispatcher.java:43)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:52)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics/javafx.scene.Scene$KeyHandler.process(Scene.java:4058)
at javafx.graphics/javafx.scene.Scene$KeyHandler.access00(Scene.java:4004)
at javafx.graphics/javafx.scene.Scene.processKeyEvent(Scene.java:2121)
at javafx.graphics/javafx.scene.Scene$ScenePeerListener.keyEvent(Scene.java:2595)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:217)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:149)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleKeyEvent(GlassViewEventHandler.java:248)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:390)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(GlassViewEventHandler.java:247)
at javafx.graphics/com.sun.glass.ui.View.handleKeyEvent(View.java:547)
at javafx.graphics/com.sun.glass.ui.View.notifyKey(View.java:971)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.UnsupportedOperationException: not implemented
at javafx.base/com.sun.javafx.logging.PlatformLogger.getName(PlatformLogger.java:121)
at javafx.web/com.sun.webkit.perf.PerfLogger.fullName(PerfLogger.java:155)
at javafx.web/com.sun.webkit.perf.PerfLogger.registerProbe(PerfLogger.java:201)
at javafx.web/com.sun.webkit.perf.PerfLogger.startCount(PerfLogger.java:227)
at javafx.web/com.sun.webkit.perf.PerfLogger.<init>(PerfLogger.java:90)
at javafx.web/com.sun.webkit.perf.PerfLogger.getLogger(PerfLogger.java:57)
at javafx.web/com.sun.webkit.perf.PerfLogger.getLogger(PerfLogger.java:84)
at javafx.web/com.sun.webkit.Invoker.<clinit>(Invoker.java:34)
... 37 more
这是一个错误吗?我正在使用 OpenJFX 11.0.1 和 OpenJDK 11.0.1。
更新:
如评论中所述,此错误将在 OpenJFX 12 中修复。
这是来自 com.sun.javafx.logging.PlatformLogger
的问题代码:
@Override
public String getName() {
throw new UnsupportedOperationException("not implemented");
}
如您所见,它除了抛出观察到的异常外什么都不做。所有 "implemented" java.lang.System.Logger
方法都是如此。
如果按照您提供的堆栈跟踪概述的代码进行操作,最终会调用 getName
方法,因为 com.sun.webkit.perf.PerfLogger
在初始化 WebEngine
的过程中被实例化并且,推而广之,com.sun.webkit.Invoker
类。但是,getName
仅在启用 PerfLogger
时调用。
粗略地看一下,PerfLogger
包裹了 com.sun.javafx.logging.PlatformLogger
,后者又包裹了 System.Logger
。如果 System.Logger
returns 在构造 PerfLogger
时 isLoggable(System.Logger.Level.FINE)
为真,则启用 PerfLogger
。
在这种情况下,此过程会导致创建一个名为 "com.sun.webkit.perf.Locks"
的 System.Logger
。这意味着如果您将此 System.Logger
配置为不在 Level.FINE
或 "lower" 处记录任何内容,则可以避免 UnsupportedOperationException
。这样做将使 PerfLogger
"disabled" 阻止 getName
被调用。
注:本文基于OpenJFX 11.0.1的源代码。提及的所有内容都是实施细节,如有更改,恕不另行通知。