修补或覆盖核心Java 10类的实现 [英] Patch or override an implementation of a core Java 10 class
问题描述
JFX中存在一个错误,通常在计算屏幕坐标时显示
https://bugs.openjdk.java.net/browse/JDK-8194727 和
https://bugs.openjdk.java.net/browse/JDK-8190400
There is a bug in JFX which often manifests when calculating screen co-ordinates https://bugs.openjdk.java.net/browse/JDK-8194727 and https://bugs.openjdk.java.net/browse/JDK-8190400
我已将问题追踪到GeneralTransform3D的实现,它是javajfx运行时的一部分。
I've tracked the problem down to the implementation of GeneralTransform3D, which is part of the javajfx runtime.
我已经向Oracle提交了一个错误报告,但是直到它被接受,修复并转到它一个版本,我需要一种方法来修复我的应用程序。
I've submitted a bug report to Oracle, but until it is accepted, fixed, and makes it to a release, I need a way of fixing my application.
在java 8中我能够创建一个包含该类的固定版本的jar并将其安装在lib中/ ext文件夹。这似乎有效,JFX实现使用了我自己的impl。
In java 8 i was able to create a jar containing a fixed version of the class and install it in the lib/ext folder. This seemed to work and the JFX implementation used my impl over its own.
在java 10中,删除了扩展机制。将补丁jar添加到类路径不起作用,因为它在类加载过程中为时已晚。
In java 10 the extension mechanism has been removed. Adding the patch jar to the classpath doesn't work as it is too late in the classloading process.
有没有办法覆盖/修补核心java的实现Java 10中的类?
Is there a way to override/patch an implementation of the core java classes in Java 10?
请注意,我没有直接使用这个类,它是由框架使用的
Note that i'm not using this class directly, it is used by the framework
推荐答案
Once again, Alan gives the best answer as a comment. :) Quote:
- patch-module javafx.runtime = patch.jar
是覆盖此模块中的类的正确方法
--patch-module javafx.runtime=patch.jar
is the right way to override classes in this module
如果需要覆盖平台模块中的类,请使用< a href =https://blog.codefx.org/java/five-command-line-options-to-hack-the-java-9-module-system/#Adding-Classes-To-Modules-With--补丁模块rel =nofollow noreferrer> - patch-module
来做到这一点。如果这拖入其他依赖项,请确保使用 - add-reads
。
If you need to "override" a class in a platform module, use --patch-module
to do that. If that drags in additional dependencies, make sure to make them readable with --add-reads
.
这篇关于修补或覆盖核心Java 10类的实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!