简体   繁体   中英

Limitations to modifying rt.jar

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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