Reputation: 53
For the context, I am serializing some class A in JSON, but it has one private member (Instant creationTime).
In all JUnit tests, the serialization is working with no issue. In production, I end up with:
Failed making field 'java.time.Instant#seconds' accessible; either increase its visibility or write a custom TypeAdapter for its declaring type.
When debugging both at the same place and evaluating the following code, creating a simple object of class A, and then serializing, this difference is reproduced:
A a = new A();
new GsonBuilder().create().toJson(a);
I know I can work something out using Adapters, or simply modifying the fields, but I would like my tests to reflect as precisely as possible a real environment, to be aware of such issues earlier.
Upvotes: 0
Views: 67