RFC (round 1), JEP draft: Low-level Object layout introspection methods
Peter Levart
peter.levart at gmail.com
Wed Aug 19 13:08:13 UTC 2020
On 8/11/20 12:22 PM, Aleksey Shipilev wrote:
> ...and it is not clear what is your position on:
> public static long fieldSizeOf(Field field);
Perhaps an alternative. Each Field has a type (represented by: Class<?>
Field.getType()). So adding a method to Class would also be possible. Like:
long getFieldSizeInBytes(); // how many bytes does value of that type
take when placed on heap (for identity classes, this would be the number
of bytes a pointer takes - compressed taken into account, for inline
classes this would give the footprint of the fields of that inline class
with all gaps included).
Alternatively the API could be specified somewhere else as a static method:
long getSizeInBytesForFieldOfType(Class<?> fieldType);
This assumes that fields of the same type always take the same size in
the same VM.
Regards, Peter
More information about the jdk-dev
mailing list