ehcache / sizeof

Configurable sizeOf engine for Ehcache
Apache License 2.0
105 stars 43 forks source link

java.lang.UnsupportedOperationException: can't get field offset on a record class #72

Open KafkaProServerless opened 10 months ago

KafkaProServerless commented 10 months ago

Hello team,

I am using this dependency:

I am also using java 21.

I have a very straightforward object I would like to get the size of.

Please note, the object in question is a java record, which is something new from new java version.

public record MyPojo(@JsonProperty(value = "@timestamp") String timestamp

reproducible 100%, i am getting this error:

java.lang.UnsupportedOperationException: can't get field offset on a record class: private final java.lang.String com.MyPojo.timestamp
Caused by: java.lang.UnsupportedOperationException: can't get field offset on a record class: private final java.lang.String com.MyPojo.timestamp
    at jdk.unsupported/sun.misc.Unsafe.objectFieldOffset(Unsafe.java:655)
    at org.ehcache.sizeof.impl.UnsafeSizeOf.sizeOf(UnsafeSizeOf.java:120)
    at org.ehcache.sizeof.SizeOf$CachingSizeOfVisitor.visit(SizeOf.java:127)
    at org.ehcache.sizeof.ObjectGraphWalker.walk(ObjectGraphWalker.java:168)
    at org.ehcache.sizeof.SizeOf.deepSizeOf(SizeOf.java:74)

Could you please help support record?

Thank you