Added Checks for IndexOutOfBoundsException when population table:

- I'm not sure exactly why we were always looking for ArrayIndexOutOfBoundsException and not IndexOutOfBoundsException.
 - The swing worker was hiding this error and resulted in a failure to load the table.
This commit is contained in:
Scotthew 2013-07-09 23:08:52 -07:00
parent 1632fbd5be
commit 55bd417dd2
7 changed files with 19 additions and 7 deletions

View File

@ -164,6 +164,17 @@ public class Rom extends DefaultMutableTreeNode implements Serializable {
" type " + table.getType() + " start " +
table.getStorageAddress() + " " + binData.length + " filesize", ex);
// table storage address extends beyond end of file
JOptionPane.showMessageDialog(SwingUtilities.windowForComponent(table), "Storage address for table \"" + table.getName() +
"\" is out of bounds.\nPlease check ECU definition file.", "ECU Definition Error", JOptionPane.ERROR_MESSAGE);
tableNodes.removeElementAt(i);
i--;
} catch (IndexOutOfBoundsException iex) {
LOGGER.error(table.getName() +
" type " + table.getType() + " start " +
table.getStorageAddress() + " " + binData.length + " filesize", iex);
// table storage address extends beyond end of file
JOptionPane.showMessageDialog(SwingUtilities.windowForComponent(table), "Storage address for table \"" + table.getName() +
"\" is out of bounds.\nPlease check ECU definition file.", "ECU Definition Error", JOptionPane.ERROR_MESSAGE);

View File

@ -414,7 +414,7 @@ public abstract class Table extends JPanel implements Serializable {
this.data = data;
}
public void populateTable(byte[] input, int ramOffset) throws ArrayIndexOutOfBoundsException {
public void populateTable(byte[] input, int ramOffset) throws ArrayIndexOutOfBoundsException, IndexOutOfBoundsException {
// temporarily remove lock
boolean tempLock = locked;
locked = false;

View File

@ -52,7 +52,7 @@ public class Table1D extends Table {
}
@Override
public void populateTable(byte[] input, int ramOffset) {
public void populateTable(byte[] input, int ramOffset) throws ArrayIndexOutOfBoundsException, IndexOutOfBoundsException {
loaded = false;
centerLayout.setRows(1);
centerLayout.setColumns(this.getDataSize());

View File

@ -126,7 +126,7 @@ public class Table2D extends Table {
}
@Override
public void populateTable(byte[] input, int ramOffset) throws ArrayIndexOutOfBoundsException {
public void populateTable(byte[] input, int ramOffset) throws ArrayIndexOutOfBoundsException, IndexOutOfBoundsException {
centerLayout.setRows(2);
centerLayout.setColumns(this.getDataSize());

View File

@ -157,7 +157,7 @@ public class Table3D extends Table {
}
@Override
public void populateTable(byte[] input, int ramOffset) throws NullPointerException, ArrayIndexOutOfBoundsException {
public void populateTable(byte[] input, int ramOffset) throws NullPointerException, ArrayIndexOutOfBoundsException, IndexOutOfBoundsException {
loaded = false;
// fill first empty cell
centerPanel.add(new JLabel());

View File

@ -73,7 +73,7 @@ public class TableSwitch extends Table {
}
@Override
public void populateTable(byte[] input, int ramOffset) {
public void populateTable(byte[] input, int ramOffset) throws ArrayIndexOutOfBoundsException, IndexOutOfBoundsException {
JPanel radioPanel = new JPanel(new GridLayout(0, 1));
radioPanel.add(new JLabel(" " + name));
for (String stateName : switchStates.keySet()) {
@ -106,7 +106,8 @@ public class TableSwitch extends Table {
message,
"Warning - Checksum Status",
INFORMATION_MESSAGE);
getButtonByText(buttonGroup, "on").setSelected(true); }
getButtonByText(buttonGroup, "on").setSelected(true);
}
else {
getButtonByText(buttonGroup, "off").setSelected(true);
locked = false;

View File

@ -107,7 +107,7 @@ public final class RomAttributeParser {
}
}
public static long parseByteValue(byte[] input, int endian, int address, int length, boolean signed) throws ArrayIndexOutOfBoundsException {
public static long parseByteValue(byte[] input, int endian, int address, int length, boolean signed) throws ArrayIndexOutOfBoundsException, IndexOutOfBoundsException {
try {
long output = 0L;
ByteBuffer bb = ByteBuffer.wrap(input, address, length);