简体   繁体   English

修改rt.jar的限制

[英]Limitations to modifying rt.jar

What are the limitations when modifying classes in rt.jar. 在rt.jar中修改类时有什么限制。 I realize this is generally specific to the version and vendor of the JRE. 我意识到这通常特定于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. 例如,我发现Sun 1.6 VM中的Hotspot不喜欢向java.lang.Object添加字段,因为它有关于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. 但是,如果我在rt.jar中修改了类的重要部分,我会在运行时为我的jar中明确的类获得虚假的ClassNotFoundErrors。 I've tried modifying rt.jar in place as well as superseding it with the various -Xbootclasspath parameters. 我已经尝试修改rt.jar,并用各种-Xbootclasspath参数取代它。

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. 我真的不知道在哪里寻找关于此类文档的文档,例如,我在OpenJDK文档中找不到任何内容。

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 对于JDK大于或等于5.0,您可以使用ASM + java.lang.instrument

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM