Skip to content

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

@KafkaProServerless

Description

@KafkaProServerless

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions