Hi David,

I was surprised to see Usafe report these offsets. See below:

java.lang.Class *instance* field offsets:

              Field Type                           Field Name Offset
              ---------- ---------- ------
             Constructor cachedConstructor     12
                   Class newInstanceCallerCache     16
                  String name     20
           SoftReference reflectionData     24
         ClassRepository genericInfo     28
                Object[] enumConstants     32
                     Map enumConstantDirectory     36
                     Map annotations     40
                     Map declaredAnnotations     44
          AnnotationType annotationType     48
           ClassValueMap classValueMap *52*


Why the *24 bytes* gap between /classValueMap/ and /classRedefinedCount/ fields?

                     int classRedefinedCount *80*
                     int lastAnnotationsRedefinedCount     84

java.lang.String *static* field offsets:

              Field Type                           Field Name Offset
              ---------- ---------- ------
     ObjectStreamField[] serialPersistentFields     96
              Comparator CASE_INSENSITIVE_ORDER    100
                    long serialVersionUID    104
                     int HASHING_SEED    112


The 64 bit pointers variant:

java.lang.Class instance field offsets:

              Field Type                           Field Name Offset
              ---------- ---------- ------
             Constructor cachedConstructor     16
                   Class newInstanceCallerCache     24
                  String name     32
           SoftReference reflectionData     40
         ClassRepository genericInfo     48
                Object[] enumConstants     56
                     Map enumConstantDirectory     64
                     Map annotations     72
                     Map declaredAnnotations     80
          AnnotationType annotationType     88
           ClassValueMap classValueMap *96*

*24 bytes* gap here too!

                     int classRedefinedCount *128*
                     int lastAnnotationsRedefinedCount    132

java.lang.String static field offsets:

              Field Type                           Field Name Offset
              ---------- ---------- ------
     ObjectStreamField[] serialPersistentFields    144
              Comparator CASE_INSENSITIVE_ORDER    152
                    long serialVersionUID    160
                     int HASHING_SEED    168


Might it be that the "classRedefinedCount" field offset is fixed somehow in VM, since the VM has to update it? Should there be VM changes also to accomodate ReflectionData changes? Are there VM fields inserted here that don't have a Java mapping?

Regards, Peter

Reply via email to