Patching a bug in the JDK for an individual application

痞子三分冷 提交于 2019-12-12 03:48:13

问题


I have established through another question that the problem I'm having with my JavaFX program is due to a bug in the JDK that is not going to be fixed anytime soon. I was even informed that the bug is in PrismTextLayout.

So having found the source code for this, how would I implement some kind of patch which would allow me to fix this bug for my application only. Obviously if I did fix the problem, I would contribute it back to a future JDK, but for now I just want a quick fix.

I thought a simple google search for patching the JDK, etc would turn up heaps of information, but actually, virutally nothing.

Can someone, if not explain how to patch, at least point me in the right direction for some documentation on this subject.


回答1:


Patching a JavaFX class without actually building the whole JDK or JavaFX is quite easy. I did that for example for the class SVGPath some time ago.

  1. Extract the class source from the source zip which is distributed with the JDK and add it to your project in the correct folder according to its package name. In my case this would be javafx/scene/shape/SVGPath.java.
  2. Explicitly add ${JDK_HOME}/jre/lib/ext/jfxrt.jar to your classpath.
  3. Run your program with the java options "-Djava.ext.dirs=". This procedure is essential to be able to override the existing classes in jfxrt.jar.

That is it.



来源:https://stackoverflow.com/questions/41405290/patching-a-bug-in-the-jdk-for-an-individual-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!