Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
KafkaProServerless opened this issue Jan 30, 2024 · 0 comments

Comments

@KafkaProServerless
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant