eclipse-ee4j / eclipse-ee4j/yasson
Deceptive exception: Cannot serialize java.time.Instant, IllegalAccessException: class is not public
- Dominant language
- Java
- Stars
- 218
- Forks
- 109
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 9
Description
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
Contributor guide
Research direction
Reproduce the failure with Java 17.0.5 and Yasson 3.0.2, then inspect org.eclipse.yasson.internal.model.PropertyModel.createReadHandle at the stack-trace location. Compare the reported declaring class with the Instant field and determine the intended correction; done when the misleading failure is addressed and the serialization case is covered by the project's existing tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100