Proxy.isProxyClass scalability (original) (raw)

Vitaly Davidovich vitalyd at gmail.com
Fri Jan 25 16:04:52 UTC 2013


That's unfortunate. Can you steal a bit in one of the int fields? E.g. lastAnnotationsRedefinedCount surely doesn't need the full range right? :)

Sent from my phone On Jan 25, 2013 11:02 AM, "Peter Levart" <peter.levart at gmail.com> wrote:

On 01/25/2013 06:35 AM, David Holmes wrote:

On 25/01/2013 2:36 AM, Peter Levart wrote:

On 01/24/2013 04:45 PM, Peter Levart wrote:

Is there really no existing alignment gap in j.l.Class layout that a boolean can slide into? There might be, I will check. All instance fields in j.l.Class are either references or ints. Instance are also 8-byte aligned though so does that leave any slop where an extra field would not make an actual difference. (I should know the answer to that after the ReflectionData changes but don't recall.) Note: I have not looked at this, just considering the "add a field" aspect of it. David Here's what the Unsafe reports about current layout of j.l.Class (ReflectionData changes already taken into account): 32 bit pointers: 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 int classRedefinedCount 80 int lastAnnotationsRedefinedCount 84 java.lang.String static field offsets: Field Type Field Name Offset ---------- ---------- ------ ObjectStreamField[] serialPersistentFields 96 Comparator CASEINSENSITIVEORDER 100 long serialVersionUID 104 int HASHINGSEED 112 64 bit pointers: 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 int classRedefinedCount 128 int lastAnnotationsRedefinedCount 132 java.lang.String static field offsets: Field Type Field Name Offset ---------- ---------- ------ ObjectStreamField[] serialPersistentFields 144 Comparator CASEINSENSITIVEORDER 152 long serialVersionUID 160 int HASHINGSEED 168 If I add a boolean instance field "isProxy" to j.l.Class the report changes to: 32 bit pointers: 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 int classRedefinedCount 80 int lastAnnotationsRedefinedCount 84 boolean isProxy 96 java.lang.String static field offsets: Field Type Field Name Offset ---------- ---------- ------ ObjectStreamField[] serialPersistentFields 104 Comparator CASEINSENSITIVEORDER 108 long serialVersionUID 112 int HASHINGSEED 120 64 bit pointers: 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 int classRedefinedCount 128 int lastAnnotationsRedefinedCount 132 boolean isProxy 144 java.lang.String static field offsets: Field Type Field Name Offset ---------- ---------- ------ ObjectStreamField[] serialPersistentFields 152 Comparator CASEINSENSITIVEORDER 160 long serialVersionUID 168 int HASHINGSEED 176 ...so it seems that in both cases, adding a boolean to j.l.Class wastes 8 bytes per Class object :-( Regards, Peter



More information about the core-libs-dev mailing list