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

Inaccessible field "java.util.Optional#value" in an object given to gson without a proper type adapter #222

Open
maximilianpilz opened this issue Nov 15, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@maximilianpilz
Copy link
Collaborator

I got the following exception, which is not expected, when running a test:

com.google.gson.JsonIOException: Failed making field 'java.util.Optional#value' accessible; either increase its visibility or write a custom TypeAdapter for its declaring type.
See https://github.com/google/gson/blob/main/Troubleshooting.md#reflection-inaccessible
at com.google.gson.internal.reflect.ReflectionHelper.makeAccessible(ReflectionHelper.java:76) ~[gson-2.11.0.jar:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:388) ~[gson-2.11.0.jar:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:161) ~[gson-2.11.0.jar:?]
at com.google.gson.Gson.getAdapter(Gson.java:628) ~[gson-2.11.0.jar:?]
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:57) ~[gson-2.11.0.jar:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$2.write(ReflectiveTypeAdapterFactory.java:247) ~[gson-2.11.0.jar:?]
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:490) ~[gson-2.11.0.jar:?]
at com.google.gson.Gson.toJson(Gson.java:944) ~[gson-2.11.0.jar:?]
at com.google.gson.Gson.toJson(Gson.java:899) ~[gson-2.11.0.jar:?]
at com.google.gson.Gson.toJson(Gson.java:848) ~[gson-2.11.0.jar:?]
at com.google.gson.Gson.toJson(Gson.java:825) ~[gson-2.11.0.jar:?]
at com.draeger.medical.sdccc.manipulation.GsonManipulationSerializer.serialize(GsonManipulationSerializer.kt:23) ~[classes/:?]
at com.draeger.medical.sdccc.manipulation.GRpcManipulations.performCallWrapper(GRpcManipulations.java:391) ~[classes/:?]
at com.draeger.medical.sdccc.manipulation.GRpcManipulations.createContextStateWithAssociation(GRpcManipulations.java:207) ~[classes/:?]

@maximilianpilz maximilianpilz added the bug Something isn't working label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant