[Fwd: JVM -instrumentanting the JDK classes]
Christian Wimmer
wimmer at ssw.jku.at
Mon Nov 17 09:00:50 PST 2008
Hi
>> In order for our system to work, we need to change the code of the
>> Java libraries - all of them. The changes imply adding a field
>> (potentially two), and adding some code to the beginning and end of
>> every method.
>> Using Soot, I got to add the field and methods to the classes.
>> However, there are exactly two classes (Object and String) that,
>> when added a field, make the JVM crash on startup. I'm starting the
>> Sun JVM with the parameter Xbootclasspath pointing to the
>> instrumented libraries.
The layout of some core classes is known by the HotSpot VM, for
example the class String. The reason is that HotSpot must allocate
String objects even from non-Java code, for example when a String
constant is loaded from a class file's constant pool. Other classes
are for example the weak references, which are specially handled in
the garbage collector.
When you add fields to Object, you implicitly add to all other
classes, so this also fails.
All known classes should be listed in the file src/share/vm/classfile/
javaClasses.hpp of the HotSpot source code, look for example at http://hg.openjdk.java.net/jdk7/jdk7/hotspot/file/42ca4002efc2/src/share/vm/classfile/javaClasses.hpp
Christian
More information about the hotspot-dev
mailing list