[Demonstration 1]

[Buggy Method]
public static void prettyPrintHTML(Searcher searcher, ScoreDoc[] hits, int start, int end, Writer out, Context sourceContext, HistoryContext historyContext, Summarizer summer, String context, String srcRoot, String dataRoot, EftarFileReader desc) throws HistoryException, IOException, ClassNotFoundException {
    char[] content = new char[1024 * 8];
    String xrefPrefix = context + Constants.xrefP;
    String morePrefix = context + Constants.moreP;
    LinkedHashMap<String, ArrayList<Document>> dirHash = new LinkedHashMap<String, ArrayList<Document>>();
    for (int i = start; i < end; i++) {
        int docId = hits[i].doc;
        Document doc = searcher.doc(docId);
        String rpath = doc.get("path");
        String parent = rpath.substring(0, rpath.lastIndexOf('/'));
        ArrayList<Document> dirDocs = dirHash.get(parent);
        if (dirDocs == null) {
            dirDocs = new ArrayList<Document>();
            dirHash.put(parent, dirDocs);
        }
        dirDocs.add(doc);
    }
    for (Map.Entry<String, ArrayList<Document>> entry : dirHash.entrySet()) {
        String parent = entry.getKey();
        String tag = (desc == null) ? "" : " - <i>" + desc.get(parent) + "</i>";
        out.write("<tr class=\"dir\"><td colspan=\"3\">&nbsp;&nbsp;<a href=\"");
        out.write(Util.URIEncodePath(xrefPrefix + parent));
        out.write("/\">" + parent + "/</a>" + tag + "</td></tr>");
        boolean alt = false;
        for (Document doc : entry.getValue()) {
            String rpath = doc.get("path");
            String self = rpath.substring(rpath.lastIndexOf('/') + 1, rpath.length());
            String selfUrl = Util.URIEncodePath(xrefPrefix + rpath);
            out.write("<tr ");
            if (alt) {
                out.write(" class=\"alt\"");
            }
            alt ^= true;
            out.write(">");
            out.write("<td class=\"q\"><a href=\"" + context + Constants.histL + rpath + "\" title=\"History\">H</a> <a href=\"" + context + Constants.xrefP + rpath + "?a=true\" title=\"Annotate\">A</a> <a href=\"" + context + Constants.rawP + rpath + "\" title=\"Download\">D</a>");
            out.write("</td>");
            out.write("<td class=\"f\"><a href=\"" + selfUrl + "\">" + self + "</a>&nbsp;</td><td><tt class=\"con\">");
            if (sourceContext != null) {
                String genre = doc.get("t");
                Definitions tags = null;
                Fieldable tagsField = doc.getFieldable("tags");
                if (tagsField != null) {
                    tags = Definitions.deserialize(tagsField.getBinaryValue());
                }
                try {
                    if ("p".equals(genre) && srcRoot != null) {
                        sourceContext.getContext(new FileReader(srcRoot + rpath), out, xrefPrefix, morePrefix, rpath, tags, true, null);
                    } else if ("x".equals(genre) && dataRoot != null && summer != null) {
                        Reader r = null;
                        if (RuntimeEnvironment.getInstance().isCompressXref()) {
                            r = new TagFilter(new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(dataRoot + Constants.xrefP + rpath + ".gz")))));
                        } else {
                            r = new TagFilter(new BufferedReader(new FileReader(dataRoot + Constants.xrefP + rpath)));
                        }
                        int len = r.read(content);
                        //FIXME use Highlighter from lucene contrib here, instead of summarizer, we'd also get rid of apache lucene in whole source ...
                        out.write(summer.getSummary(new String(content, 0, len)).toString());
                        r.close();
                    } else if ("h".equals(genre) && srcRoot != null && summer != null) {
                        Reader r = new TagFilter(new BufferedReader(new FileReader(srcRoot + rpath)));
                        int len = r.read(content);
                        out.write(summer.getSummary(new String(content, 0, len)).toString());
                        r.close();
                    } else {
                        sourceContext.getContext(null, out, xrefPrefix, morePrefix, rpath, tags, true, null);
                    }
                } catch (IOException e) {
                    OpenGrokLogger.getLogger().log(Level.WARNING, "An error occured while creating summary of " + rpath, e);
                }
                //out.write("Genre = " + genre);
            }
            if (historyContext != null) {
                historyContext.getContext(srcRoot + parent, self, rpath, out, context);
            }
            out.write("</tt></td></tr>\n");
        }
    }
}

[Buggy Hunk]
LinkedHashMap<String, ArrayList<Document>> dirHash = new LinkedHashMap<String, ArrayList<Document>>();

[Patch]
Map<String, ArrayList<Document>> dirHash = new HashMap<String, ArrayList<Document>>();

[Demonstration 2]

[Buggy Method]
public static boolean execute(final CommandSender commandSender, final Command command, final String label, final String[] arguments) {
    if (commandSender instanceof Player) {
        final Player player = (Player) commandSender;
        if (player.hasPermission("ffa.leave")) {
            if (Game.isInGame(player.getUniqueId())) {
                Object a = FileHandler.getTemp().get("inv.leave.inventory");
                Object b = FileHandler.getTemp().get("inv.leave.armor");
                if ((a == null) || (b == null)) {
                    player.sendMessage(FileHandler.getPrefixedMessage("notsetup"));
                    return true;
                }
                ItemStack[] inventory = null;
                ItemStack[] armor = null;
                if (a instanceof ItemStack[]) {
                    inventory = (ItemStack[]) a;
                } else if (a instanceof List) {
                    List lista = (List) a;
                    inventory = (ItemStack[]) lista.toArray(new ItemStack[0]);
                }
                if (b instanceof ItemStack[]) {
                    armor = (ItemStack[]) b;
                } else if (b instanceof List) {
                    List listb = (List) b;
                    armor = (ItemStack[]) listb.toArray(new ItemStack[0]);
                }
                player.getInventory().clear();
                player.getInventory().setContents(inventory);
                player.getInventory().setArmorContents(armor);
                int x = FileHandler.getTemp().getInt("leave.x");
                int y = FileHandler.getTemp().getInt("leave.y");
                int z = FileHandler.getTemp().getInt("leave.z");
                int yaw = FileHandler.getTemp().getInt("leave.yaw");
                int pitch = FileHandler.getTemp().getInt("leave.pitch");
                Location loc2 = new Location(Bukkit.getWorld(FileHandler.getTemp().getString("leave.world")), x + 0.5D, y + 0.5D, z + 0.5D, yaw, pitch);
                player.teleport(loc2);
                player.sendMessage(FileHandler.getPrefixedMessage("quit"));
                player.setGameMode(GameMode.ADVENTURE);
                Game.getIngameList().remove(player.getName());
            } else
                player.sendMessage(FileHandler.getPrefixedMessage("notin"));
        } else
            player.sendMessage(FileHandler.getPrefixedMessage("nopermission"));
    } else {
        // Commandsender is not a player (console or commandblock)
        // Let the player execute the command to leave
        if (arguments.length >= 2) {
            if (arguments[0].equalsIgnoreCase("leave")) {
                // Get player for name (argument 2)
                if (Bukkit.getOfflinePlayer(arguments[1]).isOnline())
                    execute(Bukkit.getPlayer(arguments[1]), command, label, new String[] { "leave" });
                else
                    commandSender.sendMessage(FileHandler.getPrefixedMessage("commands.quit.onlyonline"));
            }
        }
    }
    return true;
}

[Buggy Hunk]
Game.getIngameList().remove(player.getName());

[Patch]
Game.getIngameList().remove(player.getUniqueId());

[Demonstration 3]

[Buggy Method]
public static boolean isLibraryScope(Scope s) {
    if (s == null)
        return false;
    if (!(s instanceof Symbol))
        return false;
    Symbol sym = (Symbol) s;
    return (sym.getTarget() == SymbolTarget.LIBRARY);
}

[Buggy Hunk]
public static boolean isLibraryScope(Scope s){

[Patch]
private static boolean isLibraryScope(Scope s){