views:

124

answers:

1

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.

+1  A: 

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

Amir Afghani
That is exactly what I'm doing, in fact. The problem is that I can't get at certain core classes with this technique because they are already loaded by the time I get to run my instrumentation code. My fall back is to modify these classes (or the entire rt.jar) a priori and this is where I'm running into trouble.
Adam Lewis