[Demonstration 1]

[Buggy Method]
public static void execute(File idlFile, String packageName, File targetDirectory, List<File> includePath) throws IOException {
    String idlFilename = idlFile.getAbsolutePath();
    Field field;
    try {
        field = TemplateManager.class.getDeclaredField("m_loaderDirectories");
        field.setAccessible(true);
        field.set(null, "us/ihmc/idl/templates");
    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
        throw new RuntimeException("API changed, fixme", e);
    }
    String onlyFileName = Util.getIDLFileNameOnly(idlFilename);
    Context ctx = new Context(onlyFileName, idlFilename, new ArrayList<>());
    ctx.setPackage(packageName);
    TypeCode.javapackage = ctx.isIsPackageEmpty() ? "" : (ctx.getPackage() + ".");
    // Create default @Key annotation.
    AnnotationDeclaration keyann = ctx.createAnnotationDeclaration("Key", null);
    keyann.addMember(new AnnotationMember("value", new PrimitiveTypeCode(TypeCode.KIND_BOOLEAN), "true"));
    // Create default @Topic annotation.
    AnnotationDeclaration topicann = ctx.createAnnotationDeclaration("Topic", null);
    topicann.addMember(new AnnotationMember("value", new PrimitiveTypeCode(TypeCode.KIND_BOOLEAN), "true"));
    // Create template manager
    TemplateManager tmanager = new TemplateManager("FastCdrCommon:Common");
    // Create main template
    TemplateGroup maintemplates = tmanager.createTemplateGroup("main");
    maintemplates.setAttribute("ctx", ctx);
    if (idlFile.exists()) {
        Reader reader = createPreProcessedInputStream(idlFile, includePath);
        ANTLRInputStream input = new ANTLRInputStream(reader);
        IDLLexer lexer = new IDLLexer(input);
        lexer.setContext(ctx);
        CommonTokenStream tokens = new CommonTokenStream(lexer);
        IDLParser parser = new IDLParser(tokens);
        // Pass the filename without the extension
        parser.specification(ctx, tmanager, maintemplates);
        File packageDir = new File(targetDirectory, ctx.getPackageDir());
        if (packageDir.isDirectory() || packageDir.mkdirs()) {
            TypesGenerator gen = new TypesGenerator(tmanager, true);
            if (!gen.generate(ctx, packageDir.getPath() + "/", ctx.getPackage(), null)) {
                throw new IOException("Cannot create Java files");
            }
        } else {
            throw new IOException("Cannot create output dir " + packageDir);
        }
    } else {
        throw new IOException("The File " + idlFilename + " was not found.");
    }
}

[Buggy Hunk]
Context ctx = new Context(onlyFileName, idlFilename, new ArrayList<>());

[Patch]
MyContext ctx = new MyContext(onlyFileName, idlFilename, new ArrayList<>());

[Demonstration 2]

[Buggy Method]
public void copyAttachedDatabase(Context context, String databaseName) {
    final File dbPath = context.getDatabasePath(databaseName);
    // If the database already exists, return
    if (dbPath.exists()) {
        return;
    }
    // Make sure we have a path to the file
    dbPath.getParentFile().mkdirs();
    // Try to copy database file
    try {
        final InputStream inputStream = context.getAssets().open(databaseName);
        final OutputStream output = new FileOutputStream(dbPath);
        byte[] buffer = new byte[8192];
        int length;
        while ((length = inputStream.read(buffer, 0, 8192)) > 0) {
            output.write(buffer, 0, length);
        }
        output.flush();
        output.close();
        inputStream.close();
    } catch (IOException e) {
        ProactiveLog.e("Failed to open file", e);
    }
}

[Buggy Hunk]
final File dbPath = context.getDatabasePath(databaseName);

[Patch]
final File dbPath = new File(context.getApplicationContext().getFilesDir(), databaseName);

[Demonstration 3]

[Buggy Method]
private void joinServer() {
    onLeaving();
    ClientGame.instance().joinServer(Options.instance().clientUsername, Options.instance().clientPassword);
}

[Buggy Hunk]
ClientGame.instance().joinServer(Options.instance().clientUsername, Options.instance().clientPassword);

[Patch]
ClientGame.instance().joinServer(Options.instance().clientIP, Options.instance().clientPort, Options.instance().clientUsername, Options.instance().clientPassword);