Open Jimw338 opened 1 year ago
Okay, it has something to do with the "FieldModelObserver observer" and "Range selection" which Gson doesn't seem to like.
I found this page: https://stackoverflow.com/questions/4802887/gson-how-to-exclude-specific-fields-from-serialization-without-annotations
about how to exclude fields.. But they all look terribly complicated.
The "transient" keyword I gather is supposed to exclude the fields from serialization, but doesn't seem to work Something Oracle changed in the latest Java ? I have Java 19.0.1 2022-10-18 and SE Runtime Environment build 19.0.1+10-21.
I'm getting an error when I try to paste a field that I just created and copied, somehow relating to improper permissions in the DefaultStyledDocument part of the FieldModel object, in member "sharedText/unsharedText" which are of type "Map<Integer, StyledDocument>". The exception occurs in the call to "Serializer.copy()" in CardPartTransferHandler:duplicatePart: PartModel copiedPartModel = Serializer.copy(original.getPartModel());"
and the exception trace print is below.
I had thought that this was some subtle bug introduced by my numerous modifications (I'm slowly working all of my original changes back into a copy of the current codebase, which looks like it's been refactored a bunch in places since I last worked on it 4 years ago. But I just noticed that this "field copy bug" happened even with source that I just downloaded, so it's not that.
How do you debug an error that originates from deep in the bowels of the API code itself?
Jim
com.defano.wyldcard.part.clipboard.CardPartTransferHandler: importData duplicatePart original = com.defano.wyldcard.part.field.FieldPart@4a202f04. original.getPartModel = com.defano.wyldcard.part.field.FieldModel@28c6bbe2. ..importData (EXCEPTION = {}) java.lang.reflect.InaccessibleObjectException: Unable to make field protected javax.swing.text.DefaultStyledDocument$ElementBuffer javax.swing.text.DefaultStyledDocument.buffer accessible: module java.desktop does not "opens javax.swing.text" to unnamed module @6ced7109 at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:387) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:363) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:311) at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:180) at java.base/java.lang.reflect.Field.setAccessible(Field.java:174) at com.google.gson.internal.reflect.UnsafeReflectionAccessor.makeAccessible(UnsafeReflectionAccessor.java:44) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:159) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102) at com.google.gson.Gson.getAdapter(Gson.java:489) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:56) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:127) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:245) at com.defano.wyldcard.serializer.PostConstructAdapterFactory$PostConstructAdapter.write(PostConstructAdapterFactory.java:79) at com.google.gson.Gson.toJson(Gson.java:735) at com.google.gson.Gson.toJson(Gson.java:714) at com.google.gson.Gson.toJson(Gson.java:669) at com.google.gson.Gson.toJson(Gson.java:649)