У нас есть большое количество файлов данных, созданных XStream за прошедшие годы.В Java 11 эти файлы больше не десериализованы.
Похоже, что проблема заключается в включении PropertChangeListener в качестве члена сериализованного экземпляра.
Я подозреваю, что это как-то связано с Java 9+ограничения модуля и т. д. Любое руководство о том, как мы можем заставить вещи работать должным образом в Java 11?
Вот пример XML:
<com.package.Config>
<changeSupport serialization="custom">
<java.beans.PropertyChangeSupport>
<default>
<source class="com.package.Config" reference="../../../.."/>
<propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
</default>
<null/>
</java.beans.PropertyChangeSupport>
</changeSupport>
<extractors resolves-to="com.package.textextraction.Extractors$Persit_1_0_0">
<myExtractors>
<entry>
<string>test</string>
<com.package.textextraction.RegExExtractor resolves-to="com.package.textextraction.RegExExtractor$Persist_1_0_0">
<name>test</name>
<strpattern>.*</strpattern>
<translateurl></translateurl>
<translatequery></translatequery>
<matchnum>1</matchnum>
<emptyStringIfNoMatch>false</emptyStringIfNoMatch>
</com.package.textextraction.RegExExtractor>
</entry>
</myExtractors>
</extractors>
<name>test</name>
<attributePatterns/>
</com.package.netdocspublisher2.NDAutoFilerConfig>
Вот трассировка стека (извините задлина, но я подозреваю, что все это может быть полезным):
com.thoughtworks.xstream.converters.ConversionException: Cannot create java.beans.PropertyChangeSupport by JDK serialization : null : Cannot create java.beans.PropertyChangeSupport by JDK serialization : null
---- Debugging information ----
message : Cannot create java.beans.PropertyChangeSupport by JDK serialization : null
cause-exception : com.thoughtworks.xstream.converters.reflection.ObjectAccessException
cause-message : Cannot create java.beans.PropertyChangeSupport by JDK serialization : null
class : java.beans.PropertyChangeSupport
required-type : java.beans.PropertyChangeSupport
converter-type : com.thoughtworks.xstream.converters.reflection.SerializableConverter
path : /com.package.NDAutoFilerConfig/changeSupport
line number : 2
class[1] : com.package.NDAutoFilerConfig
converter-type[1] : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
version : null
-------------------------------
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:355)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:306)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:234)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1052)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1036)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:921)
at com.package.appframeworkext.storage.XStreamPersistenceStrategy.deserialize(XStreamPersistenceStrategy.java:50)
... 10 more
Caused by: com.thoughtworks.xstream.converters.reflection.ObjectAccessException: Cannot create java.beans.PropertyChangeSupport by JDK serialization : null
at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.instantiateUsingSerialization(PureJavaReflectionProvider.java:119)
at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.newInstance(PureJavaReflectionProvider.java:69)
at com.thoughtworks.xstream.converters.reflection.ReflectionProviderWrapper.newInstance(ReflectionProviderWrapper.java:42)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.instantiateNewInstance(AbstractReflectionConverter.java:428)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:233)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
... 25 more
Caused by: java.io.OptionalDataException
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1555)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:430)
at java.desktop/java.beans.PropertyChangeSupport.readObject(PropertyChangeSupport.java:476)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.base/java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1160)
at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2216)
at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2087)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1594)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:430)
at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.instantiateUsingSerialization(PureJavaReflectionProvider.java:116)
... 30 more
Обновление: я пытался добавить --illegal-access = allow в аргументы JRE, никаких изменений в поведении,Если я установлю -illegal-access = deny, xstream завершится сбоем намного раньше, поэтому я вполне уверен, что --illegal-access = allow является активной настройкой.