public boolean mergeStack(Frame frame) {
        boolean changed = false;
        if (top != frame.top)
            throw new RuntimeException("Operand stacks could not be merged, they are different sizes!");

        for (int i = 0; i < top; i++) {
            if (stack[i] != null) {
                Type prev = stack[i];
                Type merged = prev.merge(frame.stack[i]);
                if (merged == Type.BOGUS)
                    throw new RuntimeException("Operand stacks could not be merged due to differing primitive types: pos = " + i);

                stack[i] = merged;
                // always replace the instance in case a multi-interface type changes to a normal Type
                if ((! merged.equals(prev)) || merged.popChanged()) {
                    changed = true;
                }
            }
        }

        return changed;
    }