Adding fields to java.lang.Object
Hi,
Is anybody aware of any restriction that prevents me from adding a new field
to java.lang.Object? I tried both using JVMTI or adding the transformed class to rt.jar and all i get is this
java.lang.IllegalStateException
at java.lang.Throwable.initCause(Throwable.java:320)
at java.lang.ExceptionInInitializerError.<init>(ExceptionInInitializerError.java:62)
[403 byte] By [
genadya] at [2007-11-26 13:35:09]

# 4
I believe we have a number of classes where it would be problematic if you changed the ordering of fields (meaning it should be okay to add to the end but don't change the order of existing fields). These classes would be: java.lang.String, java.lang.Class, java.lang.Throwable, java.lang.ref.Reference, java.lang.ref.SoftReference, java.lang.ClassLoader, java.lang.System, and java.lang.StackTraceElement.
BTW: Instrumentation is usually used to inject hooks into existing byte codes - is there a reason why you want to add fields?
# 5
Thanks again!
I'm trying to do some experiments that require attaching an integer to each object and modifying it frequently as the program runs. I've read about tags, but if I understand it correctly, I can only use tags in the native code, which would be unreasonable performance hit.