yasson
yasson copied to clipboard
Deceptive exception: Cannot serialize java.time.Instant, IllegalAccessException: class is not public
When serializing a class with an Instant field, I get an exception: Caused by: java.lang.IllegalAccessException: class is not public: .../java.time.Instant/getField, from public Lookup at java.base/java.lang.invoke.MemberName.makeAccessException(MemberName.java:955) at java.base/java.lang.invoke.MethodHandles$Lookup.checkAccess(MethodHandles.java:3882) at java.base/java.lang.invoke.MethodHandles$Lookup.checkField(MethodHandles.java:3832) at java.base/java.lang.invoke.MethodHandles$Lookup.getDirectFieldCommon(MethodHandles.java:4045) at java.base/java.lang.invoke.MethodHandles$Lookup.getDirectFieldNoSecurityManager(MethodHandles.java:4040) at java.base/java.lang.invoke.MethodHandles$Lookup.unreflectField(MethodHandles.java:3504) at java.base/java.lang.invoke.MethodHandles$Lookup.unreflectGetter(MethodHandles.java:3455) at org.eclipse.yasson.internal.model.PropertyModel.createReadHandle(PropertyModel.java:518) ... 35 common frames omitted
It is not that the Instant class is not public, neither the return value or parameter type of getField, but the class containing the Instant field.
System information:
- Java Version: 17.0.5
- Yasson Version: 3.0.2