To explain things briefly, I have a Task
object I want to convert to a JSON string using the GSON library. The object itself has String and int attributes, which I can convert to JSON just fine, however when I add a CheckBox attribute to the class, this error message appears
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private javafx.beans.property.BooleanProperty javafx.scene.control.CheckBox.indeterminate accessible: module javafx.controls does not "opens javafx.scene.control" to module gson at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:349) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:289) at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:174) at java.base/java.lang.reflect.Field.setAccessible(Field.java:168) at gson@2.8.2/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:157) at gson@2.8.2/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:100) at gson@2.8.2/com.google.gson.Gson.getAdapter(Gson.java:423) at gson@2.8.2/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:115) at gson@2.8.2/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:164) at gson@2.8.2/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:100) at gson@2.8.2/com.google.gson.Gson.getAdapter(Gson.java:423) at gson@2.8.2/com.google.gson.Gson.toJson(Gson.java:661) at gson@2.8.2/com.google.gson.Gson.toJson(Gson.java:648) at gson@2.8.2/com.google.gson.Gson.toJson(Gson.java:603) at gson@2.8.2/com.google.gson.Gson.toJson(Gson.java:583) at IAssessment/application.AddTaskController.addTask(AddTaskController.java:45)
I had something similar beforehand and I asked about it here (the error message was ending in does not export to gson) and the solution was to create a class module-info that looks like this
exports snippet;
exports application;
requires gson;
requires java.sql;
requires javafx.base;
requires javafx.controls;
requires javafx.fxml;
requires javafx.graphics;
opens application to gson, javafx.fxml;
This solved my previous problem but this seems to be a similar problem for which I don't know what to do. So is there a way to solve it? I appreciate any and all help.
1条答案
按热度按时间6kkfgxo01#
我想出来了