On Wed, 3 Dec 2025 10:05:51 GMT, Prasanta Sadhukhan <[email protected]> 
wrote:

> Issue is when JTable is in editing mode, it is not Serializable as it gives 
> exception
> 
> java.io.NotSerializableException: java.lang.reflect.Constructor
>         at 
> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1149) at 
> java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1502)
>         at 
> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1467)
>         at 
> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1385)
>         at 
> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1143) at 
> java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1502)
> .......
> 
> 
> It is caused by creation of `GenericEditor` class which uses a 
> non-serializable Constructor field.
> This is fixed by making the field transient..
> Also, `editorRemover` field is made transient as it is object of 
> `CellEditorRemover` class which is not Serializable..

Firstly, `cancelCellEditing()` is dependant on CellEditor being non-null since 
everywhere it is called via `getCellEditor().cancelCellEditing()` and 
`cellEditor` is transient which does not participate in serialization 
https://github.com/openjdk/jdk/blob/5f083abafc7abfaa46ddd053668cdfbfd2ad8a87/src/java.desktop/share/classes/javax/swing/JTable.java#L408
and 
secondly, `editorRemover` is  PropertyChangeListener object and in other places 
in jdk like
https://github.com/openjdk/jdk/blob/5f083abafc7abfaa46ddd053668cdfbfd2ad8a87/src/java.desktop/share/classes/java/beans/beancontext/BeanContextSupport.java#L1436
https://github.com/openjdk/jdk/blob/5f083abafc7abfaa46ddd053668cdfbfd2ad8a87/src/java.desktop/share/classes/javax/swing/JFileChooser.java#L281
it also doesn't participate in serialization so have done the same

-------------

PR Comment: https://git.openjdk.org/jdk/pull/28627#issuecomment-3621727944

Reply via email to