tornadofx - GraalVM 与 TornadoFX CSS URL 协议的兼容性
问题描述
我正在尝试使用 GraalVM Native Image 工具创建一个无需安装 java 即可运行的可执行文件。我还希望避免我的程序也需要安装程序,因此我找到了 GraalVM Native Image。但是,当我尝试运行我的程序时,我收到了这个错误:
Jun 26, 2021 4:56:42 PM tornadofx.Stylesheet$Companion detectAndInstallUrlHandler
INFO: Installing CSS url handler, since it was not picked up automatically
Jun 26, 2021 4:56:42 PM tornadofx.Stylesheet$Companion detectAndInstallUrlHandler
WARNING: Unable to install CSS url handler, type safe stylesheets might not work
java.net.MalformedURLException: Accessing an URL protocol that was not enabled. The URL protocol css is not tested and might not work as expected. It can be enabled by adding the --enable-url-protocols=css option to the native-image command.
at com.oracle.svm.core.jdk.JavaNetSubstitutions.unsupported(JavaNetSubstitutions.java:222)
at com.oracle.svm.core.jdk.JavaNetSubstitutions.getURLStreamHandler(JavaNetSubstitutions.java:177)
at java.net.URL.getURLStreamHandler(URL.java:72)
at java.net.URL.<init>(URL.java:651)
at java.net.URL.<init>(URL.java:541)
at java.net.URL.<init>(URL.java:488)
at tornadofx.Stylesheet$Companion.detectAndInstallUrlHandler(CSS.kt:469)
at tornadofx.Stylesheet$Companion.access$detectAndInstallUrlHandler(CSS.kt:97)
at tornadofx.Stylesheet.<clinit>(CSS.kt:448)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375)
at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295)
at tornadofx.App.<init>(App.kt:73)
at me.dkim19375.project.Project.<init>(Project.kt:25)
at java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:802)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.security.AccessController.doPrivileged(AccessController.java:100)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VA_LIST:Ljava_lang_Runnable_2_0002erun_00028_00029V(JNIJavaCallWrappers.java:0)
at com.sun.glass.ui.win.WinApplication._runLoop(WinApplication.java)
at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.lang.Thread.run(Thread.java:829)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:553)
at com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine(WindowsJavaThreads.java:138)
Exception in Application start method
因此,正如错误提示的那样,我在 native-image 命令中添加了 --enable-url-protocols=css 选项。但是,我在运行本机图像命令时收到此警告:
The URL protocol css is not tested and might not work as expected.
Supported URL protocols enabled by default: file,resource. Supported URL protocols available on demand: http,https.
Registering the css URL protocol failed. It will not be available at runtime.
在运行程序时,我遇到了与以前相同的错误。
这是由类型安全的样式表引起的吗?如果是这样,有没有办法修复或禁用它?
注意:如果您查看堆栈跟踪,您会看到它指向我的代码 (Project.kt:25) - 这就是我调用 的构造函数的地方App(StartView::class)
,该行上的完整代码是
class Project : App(StartView::class)
解决方案
推荐阅读
- java - 来自嵌套 POJO 的比较器
- asp.net-core-webapi - request.IsPasswordGrantType() 在 ASP.NET Core 3.1 的 openiddict 中总是失败
- c# - 接受通过 ajax 在 Post 请求中发送的 Web API (C#) 中的 ArrayBuffer(不使用表单)
- html - 我可以使用 amp-state 设置简单的键值对吗?
- vue.js - 从组件发出侦听器后更改道具中使用的外部变量的值会禁用 Vue.js 中的 v-model 侦听器效果
- java - 使用 Java 8 流减小列表的大小
- python - 使用 Numpy Convolve 时幅度正在变化
- python - 在 sympy 或替代方案中导出点云方程
- batch-file - 仅移动第一个文件
- python-3.x - 尝试读取 proc.stdout.readline 中的所有行时陷入无限循环