Description
Hello, I was using GSON 2.8.6 to save some data received from a device over a TCP connection, using simply
Gson gson = new Gson() return gson.toJson(this);
to serialize my custom class (and then save it into a text file), and
gson.fromJson(input, Analysis.class);
to de-serialize the saved file, so no special configuration or custom serialization involved.
The issue appeared when I built a custom JRE9 using jdeps and jlink and ran my program using that JRE9: when deserializing, I got the exception
Caused by: java.lang.UnsupportedOperationException: Cannot allocate class LocalDateTime at com.google.gson.internal.UnsafeAllocator$4.newInstance(UnsafeAllocator.java:104) at com.google.gson.internal.ConstructorConstructor$14.construct(ConstructorConstructor.java:225) ... 88 common frames omitted
I implemented a custom de-serializer for the classes that caused the exception (just two, LocalDateTime and a custom class), and the issue was solved, but, as was pointed out here , seems that there's an undeclared dependence on the module 'jdk.unsupported' that throws this exception.
Probably it's not a major issue, but I thought you'd like to know. Let me know if you need more code or details