修改 rt.jar 的限制
修改 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否考虑过使用字节码检测库来实现您想要的目标?您可以使用 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