On Fri, 12 Dec 2025 03:13:28 GMT, Prasanta Sadhukhan <[email protected]> 
wrote:

> So, as I see it is mentioned `an instance of a static nested class (which is 
> in this case GenericEditor) would be serialized along with the outer class 
> instance is if the outer class instance holds an explicit reference to an 
> instance of that static nested class as one of its fields`, but no such 
> explicit reference exists as far I can see. The stacktrace shows the 
> exception comes from `at 
> java.desktop/javax.swing.event.EventListenerList.writeObject(EventListenerList.java:286)`
>  but even making `EventListenerList `transient in `AbstractCellEditor `and 
> `RowSorter `which are referenced in JTable, doesn't help
> 
> Also, as per this stackoverflow 
> https://stackoverflow.com/questions/19282817/why-do-jtables-make-tablemodels-non-serializable-when-rendered
>  it is told "when you add a TableModelListener to an AbstractTableModel 
> implementation, another listener is added in addition to the one you added, 
> of type javax.swing.event.TableModelListener which isn't serializable" but I 
> could not see how and also following the same "workaround" of removing 
> TableModelListener before serialization and adding it back, doesn't help so 
> if anyone has any idea of how to find the reference which is causing 
> GenericEditor to be serialized, please let me know

It seems only if we make JComponent's EventListenerList transient


/** A list of event listeners for this component. */
    protected transient EventListenerList listenerList = new 
EventListenerList();

only then, the GenericEditor class is not getting serialized..

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

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

Reply via email to