修改 rt.jar 的限制

发布于 2024-08-06 02:58:10 字数 293 浏览 1 评论 0原文

修改 rt.jar 中的类时有哪些限制?我意识到这通常特定于 JRE 的版本和供应商。例如,我发现 Sun 1.6 VM 中的 Hotspot 不喜欢向 java.lang.Object 添加字段,因为它对对象的大小有硬编码的假设。但是,如果我修改 rt.jar 中类的重要部分,我会在运行时针对肯定在我的 jar 中的类得到虚假的 ClassNotFoundErrors。我尝试就地修改 rt.jar 并用各种 -Xbootclasspath 参数取代它。

我真的不知道在哪里可以找到有关此类事情的文档,例如,我在 OpenJDK 文档中找不到任何内容。

What are the limitations when modifying classes in rt.jar. I realize this is generally specific to the version and vendor of the JRE. I've found that Hotspot in the Sun 1.6 VM, for instance, doesn't like if you add fields to java.lang.Object as it has hard-coded assumptions about the size of Object. However, if I modify significant portions of the classes in rt.jar, I get spurious ClassNotFoundErrors at runtime for classes that are definitely in my jar. I've tried modifying rt.jar in place as well as superseding it with the various -Xbootclasspath parameters.

I don't really know where to look for documentation on this sort of thing, I can't find anything in the OpenJDK docs, for instance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼藏柔 2024-08-13 02:58:10

您是否考虑过使用字节码检测库来实现您想要的目标?您可以使用 ASM + java.lang.instrument,适用于 JDK 大于或等于 5.0

Have you considered using a byte code instrumentation library to achieve what you want? You could use ASM + java.lang.instrument, for JDK's greater than or equal to 5.0

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文