On Fri, 24 Mar 2023 10:34:54 GMT, Prasanta Sadhukhan <[email protected]> wrote:
> The issue is observed on mouse right click on the table header to open a > pupup menu and then, do a mouse left click on the menu entry in which case we > get AIOOBE > This is because the columnIndex for popup menu is returned by > `viewIndexForColumn `as -1 seen here > https://github.com/openjdk/jdk/blob/941a7ac7dab243c6033a78880fd31faa803e62ab/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableHeaderUI.java#L745-L753 > which is then passed to DefaultTableColumnModel.getColumn(columnIndex) > causing it to throw AIOOBE as per the [DefaultTableColumnModel.getColumn > spec](https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/javax/swing/table/DefaultTableColumnModel.java#L293) > > So, inline with check done for `viewIndexForColumn ` > https://github.com/openjdk/jdk/blob/941a7ac7dab243c6033a78880fd31faa803e62ab/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableHeaderUI.java#L310-L312 > a similar check is added when `viewIndexForColumn `is called Please split the long line and update the copyright year. test/jdk/javax/swing/JTableHeader/JTableHeaderExceptionTest.java line 37: > 35: import java.awt.event.ActionEvent; > 36: import java.awt.event.InputEvent; > 37: import javax.swing.*; Wild import can be removed. test/jdk/javax/swing/JTableHeader/JTableHeaderExceptionTest.java line 91: > 89: > 90: Point loc; > 91: public DragTestTable(DragTestTableModel model){ Please add a space here `public DragTestTable(DragTestTableModel model) {` test/jdk/javax/swing/JTableHeader/JTableHeaderExceptionTest.java line 99: > 97: @Override > 98: public void actionPerformed(ActionEvent e) { > 99: //loc = menu.getLocationOnScreen(); Commented line can be removed. test/jdk/javax/swing/JTableHeader/JTableHeaderExceptionTest.java line 113: > 111: private Object columnNames[]; > 112: > 113: public DragTestTableModel(Object rowData[][], Object > columnNames[]){ Please add a space here `public DragTestTableModel(Object rowData[][], Object columnNames[]) {` ------------- PR Comment: https://git.openjdk.org/jdk/pull/13172#issuecomment-1495502429 PR Review Comment: https://git.openjdk.org/jdk/pull/13172#discussion_r1156819246 PR Review Comment: https://git.openjdk.org/jdk/pull/13172#discussion_r1156820545 PR Review Comment: https://git.openjdk.org/jdk/pull/13172#discussion_r1156821312 PR Review Comment: https://git.openjdk.org/jdk/pull/13172#discussion_r1156823739
