[Demonstration 1]

[Buggy Method]
private void initComponents() {
    int tableCount = Integer.parseInt(controller.countTables().getValueAt(0, 0).toString());
    row = tableCount / 4;
    if (tableCount % 4 > 0) {
        row++;
    }
    column = 4;
    panelOrderSlipView.setBorder(BorderFactory.createMatteBorder(1, 3, 1, 1, Color.gray));
    panelOrderSlipView.setPreferredSize(new Dimension(400, 0));
    buttonOrderSlip = new JButton[row][column];
    panelTable = new JPanel[row][column];
    panelTables.setLayout(new GridLayout(row, column, 10, 10));
    for (int i = 0; i < row; i++) {
        System.out.println("row: " + i);
        for (int j = 0; j < column; j++) {
            if (((i * column) + (j + 1)) <= tableCount) {
                System.out.println("column: " + j);
                // button name is table number.
                buttonOrderSlip[i][j] = new JButton(controller.refresh().getValueAt(((i * column) + j), 1).toString());
                // set table color.
                buttonOrderSlip[i][j].setBackground(determineTableColor(i, j));
                buttonOrderSlip[i][j].addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        System.out.println("I Came I Saw I Conquered");
                        Object[][] data = { { "foo", "baz" }, { "bar", "qux" } };
                        String[] columnNames = { "foobar", "bazbar" };
                        JTable table = new JTable(data, columnNames);
                        panelOrderSlipView.removeAll();
                        panelOrderSlipView.add(table);
                        panelOrderSlipView.revalidate();
                        panelOrderSlipView.repaint();
                    }
                });
                buttonClean = new JButton("Clean Table");
                buttonClean.addActionListener((ActionListener) this);
                buttonClean.setActionCommand("" + ((i * column) + (j + 1)));
                // buttonClean.setActionCommand("d" + i + "" + j);
                panelTable[i][j] = new JPanel();
                panelTable[i][j].setLayout(new BorderLayout(0, 0));
                panelTable[i][j].setPreferredSize(new Dimension(150, 150));
                panelTable[i][j].add(buttonOrderSlip[i][j], BorderLayout.CENTER);
                panelTable[i][j].add(buttonClean, BorderLayout.SOUTH);
                panelTables.add(panelTable[i][j]);
            } else {
                JLabel labelBlank = new JLabel();
                panelTables.add(labelBlank);
            }
        }
    }
    // for (int i = 0; i < row; i++) {
    // System.out.println("i:" + i);
    // for (int j = 0; j < column; j++) {
    // System.out.println("j:" + j);
    // buttonOrderSlip[i][j] = new JButton("Order Slip #"
    // + ((i * 3) + (j + 1)));
    //
    // buttonClean = new JButton("Clean Table");
    // buttonClean.addActionListener((ActionListener) this);
    // buttonClean.setActionCommand("d" + i + "" + j);
    //
    // panelTable[i][j] = new JPanel();
    // panelTable[i][j].setLayout(new BorderLayout(0, 0));
    // panelTable[i][j].setPreferredSize(new Dimension(150, 150));
    // panelTable[i][j]
    // .add(buttonOrderSlip[i][j], BorderLayout.CENTER);
    // panelTable[i][j].add(buttonClean, BorderLayout.SOUTH);
    //
    // panelTables.add(panelTable[i][j]);
    //
    // }
    // }
    scrollPaneTables = new JScrollPane(panelTables);
    setLayout(new BorderLayout());
    add(scrollPaneTables, BorderLayout.CENTER);
    add(panelOrderSlipView, BorderLayout.EAST);
    setResizable(false);
    setVisible(true);
}

[Buggy Hunk]
buttonClean.setActionCommand("" + ((i * column) + (j + 1)));

[Patch]
buttonClean.setActionCommand(controller.refresh().getValueAt(((i * column) + j), 1).toString());

[Demonstration 2]

[Buggy Method]
@SuppressWarnings("unchecked")
public synchronized static <T> T getService(Class<T> clazz) {
    if (clazz == null) {
        throw new ArgumentNullException("clazz");
    }
    Object result = initializedServices.get(clazz);
    if (result == null) {
        int index = services.indexOf(clazz);
        if (index > -1) {
            result = initializeService(services.get(index));
            initializedServices.put(clazz, result);
        }
    }
    if (result == null) {
        result = lookupCache.get(clazz);
    }
    if (result == null) {
        for (int i = 0; i < services.size(); i++) {
            Class<?> c = services.get(i);
            if (ReflectUtil.doesExtend(clazz, c)) {
                result = initializedServices.get(c);
                if (result == null) {
                    result = initializeService(c);
                    initializedServices.put(c, result);
                }
                lookupCache.put(clazz, result);
                break;
            }
        }
    }
    if (result == null) {
        return null;
    } else {
        return (T) result;
    }
}

[Buggy Hunk]
result = initializeService(services.get(index));

[Patch]
result = initializeService(clazz);

[Demonstration 3]

[Buggy Method]
private long add(long seconds) {
    if (seconds < 0)
        return 0;
    long dayChanges = seconds / Constants.SECONDS_IN_DAY;
    int _day = (int) (seconds % Constants.SECONDS_IN_DAY);
    // _day belongs to [0,86399] therefore no extra days
    int hours = _day / Constants.SECONDS_IN_HOUR;
    int _hour = _day % Constants.SECONDS_IN_HOUR;
    int minutes = _hour / Constants.SECONDS_IN_MINUTE;
    int _minute = _hour % Constants.SECONDS_IN_MINUTE;
    int $seconds = _minute % Constants.SECONDS_IN_MINUTE;
    int prevSec = this.second;
    int prevMin = this.minute;
    int prevHour = this.hour;
    this.second = (prevSec + $seconds) % Constants.SECONDS_IN_MINUTE;
    int extraMinute = (prevSec + $seconds) / Constants.SECONDS_IN_MINUTE;
    this.minute = (prevMin + minutes + extraMinute) % Constants.MINUTES_IN_HOUR;
    int extraHour = (prevMin + minutes + extraMinute) / Constants.MINUTES_IN_HOUR;
    this.hour = (prevHour + hours + extraHour) % Constants.HOURS_IN_DAY;
    // due to day change
    if (this.hour < prevHour)
        dayChanges++;
    else if (prevHour == this.hour && this.minute < prevMin)
        dayChanges++;
    else if (prevHour == this.hour && prevMin == this.minute && this.second < prevSec)
        dayChanges++;
    return dayChanges;
}

[Buggy Hunk]
private long add(long seconds) {

[Patch]
private long add(final long seconds) {