[Demonstration 1]

[Buggy Method]
protected Object createEjbProxy(final EjbJndiIdentifier identifier) throws NamingException {
    final Class<?> viewClass;
    try {
        viewClass = Class.forName(identifier.getViewName(), false, SecurityActions.getContextClassLoader());
    } catch (ClassNotFoundException e) {
        NamingException naming = new NamingException("Could not load ejb proxy class " + identifier.getViewName());
        naming.setRootCause(e);
        throw naming;
    }
    try {
        return doCreateProxy(viewClass, identifier);
    } catch (Exception e) {
        NamingException ne = new NamingException("Failed to create proxy");
        ne.initCause(e);
        throw ne;
    }
}

[Buggy Hunk]
return doCreateProxy(viewClass, identifier);

[Patch]
return EJBHome.class.isAssignableFrom(viewClass) ? doCreateHomeProxy(viewClass.asSubclass(EJBHome.class), identifier) : doCreateProxy(viewClass, identifier);

[Demonstration 2]

[Buggy Method]
@Override
public void process(Element element, HasOptionsMenu holder) {
    String fieldName = element.getSimpleName().toString();
    JBlock body = holder.getOnCreateOptionsMenuMethodBody();
    JVar menuParam = holder.getOnCreateOptionsMenuMenuParam();
    JFieldRef idsRef = annotationHelper.extractOneAnnotationFieldRef(processHolder, element, IRClass.Res.ID, true);
    body.assign(ref(fieldName), menuParam.invoke("findItem").arg(idsRef));
}

[Buggy Hunk]
body.assign(ref(fieldName), menuParam.invoke("findItem").arg(idsRef));

[Patch]
body.assign(_this().ref(fieldName), menuParam.invoke("findItem").arg(idsRef));

[Demonstration 3]

[Buggy Method]
public static void main(String[] args) {
    System.out.println("Java Tutorial");
    for (String arg : args) {
        if (arg.equals("--date")) {
            BasicTutorial basicTutorial = new BasicTutorial();
            basicTutorial.printDate();
            basicTutorial.readDate("1974/06/13");
        } else if (arg.equals("--time")) {
            BasicTutorial basicTutorial = new BasicTutorial();
            basicTutorial.measureTime(1000);
        } else if (arg.equals("--regex")) {
            RegularExpression regex = new RegularExpression();
            regex.match("\\w+", "foobar");
            regex.match("\\W+", "foo-bar");
            regex.matchDate("1974/06/13");
            regex.replace("foooo-bar", "oo", "o");
        } else if (arg.equals("--file")) {
            final String path = "/tmp/java_byte_stream_tutorial.txt";
            FileIo file = new FileIo(path);
            file.write("foo\n");
            file.write("bar\n");
            file.read();
        } else if (arg.equals("--text-file")) {
            final String path = "/tmp/java_text_file_tutorial.txt";
            TextFileIo file = new TextFileIo(path);
            file.write("foo\n");
            file.write("bar\n");
            file.read();
        } else if (arg.equals("--console-in")) {
            ConsoleInput console = new ConsoleInput();
            console.read();
        } else if (arg.equals("--file-system")) {
            Files files = new Files();
            files.makeDir("/tmp/java/tutorial");
            files.list("/tmp");
        } else if (arg.equals("--try-with-res")) {
            TryWithResources tryWithhResources = new TryWithResources();
            tryWithhResources.run();
        } else if (arg.equals("--nested-classes")) {
            NestedClasses nestedClasses = new NestedClasses();
            nestedClasses.printInner();
            nestedClasses.printMethod();
            nestedClasses.printAnonymous();
            nestedClasses.printAnonymous(new NestedClasses.AnonymousClass() {

                public void print() {
                    System.out.println("NestedClasses external anonymous class");
                }
            });
            NestedClasses.StaticClass staticNestedClass = new NestedClasses.StaticClass();
            staticNestedClass.print();
        } else if (arg.equals("--generic-method")) {
            GenericMethod genericMethod = new GenericMethod();
            genericMethod.print(new String("blah"));
            genericMethod.print(new Integer(5));
            genericMethod.print(new Float(3.0f));
            genericMethod.compare(3, 5);
        } else if (arg.equals("--generic-class")) {
            GenericClass genericClass = new GenericClass(5);
            genericClass.print();
        } else {
            System.out.println("Unknown option");
        }
    }
}

[Buggy Hunk]
GenericClass genericClass = new GenericClass(5);

[Patch]
GenericClass<Integer> genericClass = new GenericClass<Integer>(5);