<Swing Dev> [11] Review Request: JDK-6257207 : JTable.getDefaultEditor throws undocumented NullPointerException

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

<Swing Dev> [11] Review Request: JDK-6257207 : JTable.getDefaultEditor throws undocumented NullPointerException

Pankaj Bansal

Hi All,

 

Please review the fix for JDK 11.

 

Bug:

https://bugs.openjdk.java.net/browse/JDK-6257207

 

Webrev:

http://cr.openjdk.java.net/~pbansal/6257207/webrev.00/

 

Issue:

JTable.getDefaultEditor can throw a NullPointerException.

 

Fix:

While creating JTable, when data model is set by calling SetModel function, SetModel function throws TableChanged event. Now if client code has subclassed the JTable and is listening to TableChanged events, client can try to use DefaultEditor, which causes problem as it has not been initialized as of now. Moved the call to initializeLocalVars above setModel call.

 

Regards,

Pankaj Bansal

 

Reply | Threaded
Open this post in threaded view
|

Re: <Swing Dev> [11] Review Request: JDK-6257207 : JTable.getDefaultEditor throws undocumented NullPointerException

Andrej Golovnin-2
Hi Pankaj,

your change may break existing applications. Suppose that someone has
created a sub-class of JTable and has overridden the
#initializeLocalVars()-method and tries to access the table model in
this model. Before your change the application works and after your
change the application would throw NPE.

Best regards,
Andrej Golovnin

On Fri, Jan 5, 2018 at 1:16 PM, Pankaj Bansal
<[hidden email]> wrote:

> Hi All,
>
>
>
> Please review the fix for JDK 11.
>
>
>
> Bug:
>
> https://bugs.openjdk.java.net/browse/JDK-6257207
>
>
>
> Webrev:
>
> http://cr.openjdk.java.net/~pbansal/6257207/webrev.00/
>
>
>
> Issue:
>
> JTable.getDefaultEditor can throw a NullPointerException.
>
>
>
> Fix:
>
> While creating JTable, when data model is set by calling SetModel function,
> SetModel function throws TableChanged event. Now if client code has
> subclassed the JTable and is listening to TableChanged events, client can
> try to use DefaultEditor, which causes problem as it has not been
> initialized as of now. Moved the call to initializeLocalVars above setModel
> call.
>
>
>
> Regards,
>
> Pankaj Bansal
>
>