[Demonstration 1]

[Buggy Method]
private boolean processImpl(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    if ((roundEnv.processingOver())) {
        LOGGER.info("Skip the process because the processing is over");
        return false;
    }
    if (annotations.isEmpty()) {
        LOGGER.info("Skip the process because there is no annotations");
        return false;
    }
    Map<String, MetaClass> metaClasses = new HashMap<>();
    for (Element element : roundEnv.getRootElements()) {
        if (containsAnyAnnotation(element, Entity.class, Embeddable.class, MappedSuperclass.class)) {
            TypeElement typeElement = (TypeElement) element;
            if (typeElement.getEnclosingElement().getKind() != ElementKind.PACKAGE) {
                throw new IllegalProgramException("Entity, Embeddable, MappedSuperClass can not be nested class.");
            }
            MetaClass entity = new MetaClass(typeElement, this.anyAnnotationType);
            metaClasses.put(entity.getName(), entity);
        }
    }
    if (metaClasses.isEmpty()) {
        LOGGER.info("Skip the process because there is no class that is marked by \"@" + Entity.class.getName() + ", " + Embeddable.class.getName() + "\" and \"@" + MappedSuperclass.class.getName() + "\"");
        return false;
    }
    for (MetaClass entity : metaClasses.values()) {
        entity.secondaryPass(metaClasses);
    }
    for (MetaClass entity : metaClasses.values()) {
        try {
            this.generate(entity);
        } catch (Throwable ex) {
            throw new IllegalProgramException("Failed to generate the fetch model for \"" + entity.getName() + "\"", ex);
        }
    }
    return false;
}

[Buggy Hunk]
this.generate(entity);

[Patch]
this.generate(entity, metaClasses.values());

[Demonstration 2]

[Buggy Method]
private LineSegment[] mySegmentsToLineSegments(MySegment[] mySegments, int endIndex) {
    if (endIndex == -1) {
        return new LineSegment[0];
    }
    java.util.Arrays.sort(mySegments, 0, endIndex, new MySegmentComparator());
    int index = 0;
    MySegment[] destinationArray = new MySegment[2];
    for (int i = 0; i <= endIndex; i++) {
        if (i == endIndex || mySegments[i].compareTo(mySegments[i + 1]) != 0) {
            destinationArray = addElementToArray(destinationArray, mySegments[i], index++);
        }
    }
    LineSegment[] returnSegments = new LineSegment[index];
    for (int i = 0; i < index; i++) {
        returnSegments[i] = destinationArray[i].toLineSegment();
    }
    return returnSegments;
}

[Buggy Hunk]
java.util.Arrays.sort(mySegments, 0, endIndex, new MySegmentComparator());

[Patch]
java.util.Arrays.sort(mySegments, 0, endIndex + 1, new MySegmentComparator());

[Demonstration 3]

[Buggy Method]
@Override
@SuppressWarnings("unchecked")
public Collection<ClientDetailsEntityId> getAllClientIds() {
    Query query = manager.createNamedQuery("ClientDetailsEntity.stats.findAllIds");
    Collection<Object[]> result = query.getResultList();
    Collection<ClientDetailsEntityId> retList = new ArrayList<>();
    for (Object[] row : result) {
        retList.add(new ClientDetailsEntityId((Long) row[0], (String) row[1]));
    }
    return retList;
}

[Buggy Hunk]
Collection<ClientDetailsEntityId> retList = new ArrayList<>();

[Patch]
Collection<ClientDetailsEntityId> retList = new ArrayList<ClientDetailsEntityId>();