Message12532

Author filip.drozdowski
Recipients filip.drozdowski
Date 2019-05-23.22:25:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1558650303.62.0.189317118173.issue2776@roundup.psfhosted.org>
In-reply-to
Content
PySystemState extends PyObject and PyObject implements Serializable, which suggested me that I would be able to serialize PySystemState. Here's a sample code I've used:

    PythonInterpreter interpreter = new PythonInterpreter();
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(bos);
    out.writeObject(interpreter.getSystemState());

The code above triggers the following exception:

java.io.NotSerializableException: java.lang.reflect.Field

	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
	at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
	at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
	at java.util.concurrent.ConcurrentHashMap.writeObject(ConcurrentHashMap.java:1413)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1140)
	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)
	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
	at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
	at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
	at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)


I stopped the program right before it threw NotSerializableException and it looks like the offending object was "public org.python.core.PyObject org.python.core.PySystemState.__name__", which is of type "java.lang.reflect.Field".
History
Date User Action Args
2019-05-23 22:25:03filip.drozdowskisetrecipients: + filip.drozdowski
2019-05-23 22:25:03filip.drozdowskisetmessageid: <1558650303.62.0.189317118173.issue2776@roundup.psfhosted.org>
2019-05-23 22:25:03filip.drozdowskilinkissue2776 messages
2019-05-23 22:25:03filip.drozdowskicreate