[Demonstration 1]

[Buggy Method]
public static <K, V> Map<K, V> factory(Function<K, V> function) {
    Objects.requireNonNull(function);
    return new Map<K, V>() {

        final Function<K, V> f = lazy(function);

        Map<K, V> defined = new HashMap<>();

        boolean cleared;

        @Override
        public int size() {
            return cleared ? defined.size() : Integer.MAX_VALUE;
        }

        @Override
        public boolean isEmpty() {
            return cleared && defined.isEmpty();
        }

        @Override
        public boolean containsKey(Object key) {
            return !cleared || defined.containsKey(key);
        }

        @Override
        public boolean containsValue(Object value) {
            throw new UnsupportedOperationException();
        }

        @SuppressWarnings("unchecked")
        @Override
        public V get(Object key) {
            return cleared ? defined.get(key) : f.apply((K) key);
        }

        @Override
        public V put(K key, V value) {
            return fluent(defined.put(key, value)).d0(__ -> f.apply(key)).origin();
        }

        @SuppressWarnings("unchecked")
        @Override
        public V remove(Object key) {
            return defined.replace((K) key, null);
        }

        @Override
        public void putAll(Map<? extends K, ? extends V> map) {
            defined.putAll(map);
        }

        @Override
        public void clear() {
            cleared = true;
            defined.clear();
        }

        @Override
        public Set<K> keySet() {
            return all();
        }

        @Override
        public Collection<V> values() {
            throw new UnsupportedOperationException();
        }

        @Override
        public Set<java.util.Map.Entry<K, V>> entrySet() {
            throw new UnsupportedOperationException();
        }

        @Override
        public String toString() {
            return !cleared ? "{...}" : defined.toString();
        }
    };
}

[Buggy Hunk]
return all();

[Patch]
return !cleared ? all() : defined.keySet();

[Demonstration 2]

[Buggy Method]
@Override
public V get(Object key) {
    return m.get(key);
}

[Buggy Hunk]
public V get(Object key) {

[Patch]
public Collection<V> get(Object key) {

[Demonstration 3]

[Buggy Method]
@Override
boolean validate(Transaction transaction) {
    // This construction avoids multiple code-evaluations which are not really required
    if (validated)
        return isValid;
    validated = true;
    if (this.work_id == 0)
        return false;
    Work w = Work.getWork(this.work_id);
    if (w == null)
        return false;
    if (w.isClosed() == true)
        return false;
    // Now check for duplicate entry (hash already contains work_id, type and storage/multiplier)
    byte[] myHash = this.getHash();
    if (PowAndBounty.hasHash(myHash))
        return false;
    // Multiplier must be exact length
    if (this.is_proof_of_work && multiplier_or_storage.length != ComputationConstants.MULTIPLIER_LENGTH) {
        return false;
    }
    if (!this.is_proof_of_work && multiplier_or_storage.length > ComputationConstants.BOUNTY_STORAGE_INTS * 4) {
        return false;
    }
    if (!this.is_proof_of_work && multiplier_or_storage.length != w.getStorage_size()) {
        return false;
    }
    // todo: verify the storage length
    // Validate code-level
    if (this.is_proof_of_work && !validatePow()) {
        return false;
    }
    if (!this.is_proof_of_work && !validateBty()) {
        return false;
    }
    // more validation
    isValid = true;
    return true;
}

[Buggy Hunk]
if (!this.is_proof_of_work && multiplier_or_storage.length != w.getStorage_size()) {

[Patch]
if (!this.is_proof_of_work && multiplier_or_storage.length*4 != w.getStorage_size()) {