[Demonstration 1]

[Buggy Method]
private void createVisitorTraversalMethod(Unions unions, Unions unions_beforeEdit, String union_name, Traversal t) throws JavaModelException {
    FormatVisitorTraversalMethod fvtm = new FormatVisitorTraversalMethod(unions, t, union_name + "Interpreter");
    String className = fvtm.getClassName();
    // create java file
    ICompilationUnit iUnit = fragment.getCompilationUnit(className + ".java");
    if (iUnit.exists()) {
        System.out.printf("file %s already exists...keep the file as is\n", className + ".java");
    } else {
        Formatter packageHeading = new Formatter();
        packageHeading.format("package %s;\n", fragment.getElementName());
        packageHeading.format("import %s.%s.*;\n", fragment.getElementName(), UNION_UNITHEADER + unions.getName());
        String classContent = packageHeading.toString() + fvtm.toString();
        packageHeading.close();
        fragment.createCompilationUnit(className + ".java", classContent, false, null);
    }
}

[Buggy Hunk]
FormatVisitorTraversalMethod fvtm = new FormatVisitorTraversalMethod(unions, t, union_name+"Interpreter");

[Patch]
FormatVisitorTraversalMethod fvtm = new FormatVisitorTraversalMethod(unions, t);

[Demonstration 2]

[Buggy Method]
private boolean resolveAliasFromModule(ClassNode type) {
    // In case of getting a ConstructedClassWithPackage here we do not do checks for partial
    // matches with imported classes. The ConstructedClassWithPackage is already a constructed
    // node and any subclass resolving will then take place elsewhere
    if (type instanceof ConstructedClassWithPackage)
        return false;
    ModuleNode module = currentClass.getModule();
    if (module == null)
        return false;
    String name = type.getName();
    // check module node imports aliases
    // the while loop enables a check for inner classes which are not fully imported,
    // but visible as the surrounding class is imported and the inner class is public/protected static
    String pname = name;
    int index = name.length();
    /*
         * we have a name foo.bar and an import foo.foo. This means foo.bar is possibly
         * foo.foo.bar rather than foo.bar. This means to cut at the dot in foo.bar and
         * foo for import
         */
    while (true) {
        pname = name.substring(0, index);
        ClassNode aliasedNode = null;
        ImportNode importNode = module.getImport(pname);
        if (importNode != null && importNode != currImportNode) {
            aliasedNode = importNode.getType();
        }
        if (aliasedNode == null) {
            importNode = module.getStaticImports().get(pname);
            if (importNode != null && importNode != currImportNode) {
                // static alias only for inner classes and must be at end of chain
                ClassNode tmp = ClassHelper.make(importNode.getType().getName() + "$" + importNode.getFieldName());
                if (resolve(tmp, false, false, true)) {
                    if ((tmp.getModifiers() & Opcodes.ACC_STATIC) != 0) {
                        type.setRedirect(tmp.redirect());
                        return true;
                    }
                }
            }
        }
        if (aliasedNode != null) {
            if (pname.length() == name.length()) {
                // full match
                // We can compare here by length, because pname is always
                // a substring of name, so same length means they are equal.
                type.setRedirect(aliasedNode);
                return true;
            } else {
                //partial match
                // At this point we know that we have a match for pname. This may
                // mean, that name[pname.length()..<-1] is a static inner class.
                // For this the rest of the name does not need any dots in its name.
                // It is either completely a inner static class or it is not.
                // Since we do not want to have useless lookups we create the name
                // completely and use a ConstructedClassWithPackage to prevent lookups against the package.
                String className = aliasedNode.getNameWithoutPackage() + '$' + name.substring(pname.length() + 1).replace('.', '$');
                ConstructedClassWithPackage tmp = new ConstructedClassWithPackage(aliasedNode.getPackageName() + ".", className);
                if (resolve(tmp, true, true, false)) {
                    type.setRedirect(tmp.redirect());
                    return true;
                }
            }
        }
        index = pname.lastIndexOf('.');
        if (index == -1)
            break;
    }
    return false;
}

[Buggy Hunk]
ClassNode tmp = ClassHelper.make(importNode.getType().getName() + "$" + importNode.getFieldName());

[Patch]
ClassNode tmp = new ConstructedNestedClass(importNode.getType(), importNode.getFieldName());

[Demonstration 3]

[Buggy Method]
@Override
public Resource<MatchReservationModel> toResource(Match arg0) {
    MatchReservationModel model = matchReservationTranslator.translate(arg0);
    Resource<MatchReservationModel> resource = new Resource<MatchReservationModel>(model);
    List<Link> links = new ArrayList<>();
    links.add(new Link("/matches/client/" + model.getEligibleClients().getClientId() + "/status").withRel("history"));
    if (model.getEligibleClients().getLink() != null)
        links.add(new Link("client", model.getEligibleClients().getLink()));
    //			resource.add(new Link("/matches/client/"+model.getEligibleClients().getClientId()+"/status").withRel("history"));
    //if(model.getEligibleClients().getLink()!=null)
    //				resource.add(new Link(model.getEligibleClients().getLink()).withRel("client"));
    resource.add(links);
    return resource;
}

[Buggy Hunk]
links.add(new Link("client",model.getEligibleClients().getLink()));

[Patch]
links.add(new Link(model.getEligibleClients().getLink()).withRel("client"));