New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table row sizing bug #27

Open
ctrueden opened this Issue Aug 12, 2014 · 0 comments

Comments

Projects
None yet
1 participant
@ctrueden
Member

ctrueden commented Aug 12, 2014

There is a bug in the Table implementation, as illustrated by the following code:

import imagej.data.table.DefaultGenericTable;
import imagej.data.table.GenericTable;

public class TableBug {

    public static void main(final String[] args) throws Exception {
        final String first = "First";
        final String second = "Second";
        final int rowCount = 10;

        final GenericTable table = new DefaultGenericTable();
        table.setRowCount(rowCount);
        table.appendColumn(first);
        table.appendColumn(second);

        for (int row = 0; row < rowCount; row++) {
            table.set(first, row, "1st:" + row);
            table.set(second, row, "2nd:" + row);
        }

        System.out.println(table);
    }

}

It throws the following exception:

Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.RangeCheck(ArrayList.java:547)
    at java.util.ArrayList.set(ArrayList.java:337)
    at imagej.data.table.AbstractTable.set(AbstractTable.java:408)
    at TableBug.main(TableBug.java:18)

But if you move the setRowCount call after the two appendColumn calls, the code works.

Migrated-From: http://trac.imagej.net/ticket/1647

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment