[Demonstration 1]

[Buggy Method]
public boolean start(Writer writer) {
    //Create an iterator status if the status attribute was set.
    if (statusAttr != null) {
        statusState = new IteratorStatus.StatusState();
        status = new IteratorStatus(statusState);
    }
    if (beginStr != null)
        begin = (Integer) findValue(beginStr, Integer.class);
    if (endStr != null)
        end = (Integer) findValue(endStr, Integer.class);
    if (stepStr != null)
        step = (Integer) findValue(stepStr, Integer.class);
    ValueStack stack = getStack();
    if (value == null && begin == null && end == null) {
        value = "top";
    }
    Object iteratorTarget = findValue(value);
    iterator = MakeIterator.convert(iteratorTarget);
    if (begin != null) {
        //default step to 1
        if (step == null)
            step = 1;
        if (iterator == null) {
            //classic for loop from 'begin' to 'end'
            iterator = new CounterIterator(begin, end, step, null);
        } else {
            //only arrays and lists are supported
            if (iteratorTarget.getClass().isArray()) {
                Object[] values = (Object[]) iteratorTarget;
                if (end == null)
                    end = step > 0 ? values.length - 1 : 0;
                iterator = new CounterIterator(begin, end, step, Arrays.asList(values));
            } else if (iteratorTarget instanceof List) {
                List values = (List) iteratorTarget;
                if (end == null)
                    end = step > 0 ? values.size() - 1 : 0;
                iterator = new CounterIterator(begin, end, step, values);
            } else {
                //so the iterator is not based on an array or a list
                LOG.error("Incorrect use of the iterator tag. When 'begin' is set, 'value' must be" + " an Array or a List, or not set at all. 'begin', 'end' and 'step' will be ignored");
            }
        }
    }
    // get the first
    if ((iterator != null) && iterator.hasNext()) {
        Object currentValue = iterator.next();
        stack.push(currentValue);
        String var = getVar();
        if ((var != null) && (currentValue != null)) {
            putInContext(currentValue);
        }
        // Status object
        if (statusAttr != null) {
            statusState.setLast(!iterator.hasNext());
            oldStatus = stack.getContext().get(statusAttr);
            stack.getContext().put(statusAttr, status);
        }
        return true;
    } else {
        super.end(writer, "");
        return false;
    }
}

[Buggy Hunk]
if ((var != null) && (currentValue != null)) {

[Patch]
if ((var != null)) {

[Demonstration 2]

[Buggy Method]
public List<GeoCoordinate> getCoordinates() {
    return coordinates;
}

[Buggy Hunk]
public List<GeoCoordinate> getCoordinates() {

[Patch]
public List<List<Double>> getCoordinates() {

[Demonstration 3]

[Buggy Method]
public ExcerptLocation findExcerptLocation(List<String> referenceContent, List<String> excerpt) {
    // ---- Find Excerpt Start Point ----
    int startLine = -1;
    int numSelectedLines = excerpt.size();
    boolean completed = false;
    String firstSelectedLine = excerpt.get(0);
    Integer startChar = null;
    int endChar = -1;
    //  startChar is set on each iteration (outer loop) where a successful match start
    //            is found.  (if the algorithm completes successfully, e.g. completed==true
    //            then startChar will be the starting character of the START LINE)
    //
    //  endChar is set on each iteration (both inner & outer loop) and if completed==true
    //            then endChar will be the last character of the END LINE.
    while (!completed && (startLine + 1) < referenceContent.size()) {
        String referenceLine = referenceContent.get(++startLine);
        LexanStringMatcher matcher = new LexanStringMatcher(referenceLine, firstSelectedLine);
        if (!matcher.matchFound()) {
            continue;
        }
        // Set exactly once the first time through.
        if (startChar == null) {
            int diff = matcher.getFullMatchStartS2() - matcher.getMatchStartInS2();
            startChar = (diff == 0) ? matcher.getMatchStartInS1() : matcher.getFullMatchStartS1();
        }
        boolean passedAll = true;
        LexanStringMatcher goodMatch = null;
        int offset = 0;
        for (offset = 1; offset < numSelectedLines && startLine + offset < referenceContent.size(); offset++) {
            String refLine = referenceContent.get(startLine + offset);
            String checkLine = excerpt.get(offset);
            matcher = new LexanStringMatcher(refLine, checkLine);
            if (!matcher.matchFound()) {
                passedAll = false;
                break;
            }
            goodMatch = matcher;
        }
        if (startLine + offset == referenceContent.size()) {
            passedAll = false;
        }
        completed = passedAll;
        // If we matched more than one line, use the last successfully matched
        // line as the last line.
        if (goodMatch != null) {
            matcher = goodMatch;
        }
        //End char is the END as it was !!found!! in S1
        // regardless of where it was in S2.
        // However if s2 ended with "extra" insignificant characters
        // we take that answer for S1 too.
        int diff = matcher.getFullMatchEndS2() - matcher.getMatchEndInS2();
        endChar = (diff == 0) ? matcher.getMatchEndInS1() : matcher.getFullMatchEndS1();
    }
    if (!completed) {
        return new ExcerptLocation(-1, -1, -1, -1);
    }
    int endLine = startLine + excerpt.size() - 1;
    return new ExcerptLocation(startLine, startChar, endLine, endChar);
}

[Buggy Hunk]
if (startLine + offset == referenceContent.size()) {

[Patch]
if (offset < numSelectedLines && startLine + offset == referenceContent.size()) {