Proxy.isProxyClass scalability

Peter Levart peter.levart at gmail.com
Fri Jan 25 17:32:34 UTC 2013


Hi David,

I think I already have a kind of answer. You wrote it in "RFR: 8005232 
(JEP-149) Class Instance size reduction":

On 01/06/2013 11:46 PM, David Holmes wrote:
> In Java 8, using a 32-bit example, a java.lang.Class instance is 112 
> bytes consisting of:
>
> - 8 byte object header
> - 20 declared fields (mostly references, some int)
> *- 5 injected fields (3 references, 2 ints) *
>
> That gives: 8 + (20*4) +(5*4) = 108 bytes. But as we need 8-byte 
> alignment that increases to 112 bytes. 

Regards, Peter


On 01/25/2013 05:34 PM, Peter Levart wrote:
> 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
>




More information about the core-libs-dev mailing list