Buggy code:
public abstract class PartStack extends LayoutPart implements ILayoutContainer { private List children = new ArrayList ( 3 ) ; private int appearance = PresentationFactoryUtil . ROLE_VIEW ; private LayoutPart current ; private boolean ignoreSelectionChanges = false ; private IMemento savedPresentationState = null ; private DefaultStackPresentationSite presentationSite = new DefaultStackPresentationSite ( ) { public void close ( IPresentablePart part ) { } public void close ( IPresentablePart [ ] parts ) { } public void dragStart ( IPresentablePart beingDragged , Point initialLocation , boolean keyboard ) { } public void dragStart ( Point initialLocation , boolean keyboard ) { } public boolean isCloseable ( IPresentablePart part ) { } public boolean isPartMoveable ( IPresentablePart part ) { } public void selectPart ( IPresentablePart toSelect ) { } public boolean supportsState ( int state ) { } public void setState ( int newState ) { } public IPresentablePart getSelectedPart ( ) { } public void addSystemActions ( IMenuManager menuManager ) { } public boolean isStackMoveable ( ) { } } ; protected abstract boolean isMoveable ( IPresentablePart part ) { } protected abstract boolean isCloseable ( IPresentablePart part ) { } protected abstract void addSystemActions ( IMenuManager menuManager ) { } protected abstract boolean supportsState ( int newState ) { } protected abstract boolean canMoveFolder ( ) { } protected abstract void derefPart ( LayoutPart toDeref ) { } protected abstract boolean allowsDrop ( PartPane part ) { } protected static void appendToGroupIfPossible ( IMenuManager m , String groupId , ContributionItem item ) { } public PartStack ( int appearance ) { } protected IPresentablePart getSelectedPart ( ) { } protected IStackPresentationSite getPresentationSite ( ) { } public void testInvariants ( ) { } public void describeLayout ( StringBuffer buf ) { } public void add ( LayoutPart child ) { } protected void add ( LayoutPart newChild , Object cookie ) { } public boolean allowsAutoFocus ( ) { } protected void close ( IPresentablePart [ ] parts ) { } protected void close ( IPresentablePart part ) { } public boolean isDisposed ( ) { } private AbstractPresentationFactory getFactory ( ) { } public void createControl ( Composite parent ) { } public void createControl ( Composite parent , StackPresentation presentation ) { } private void savePresentationState ( ) { } public void dispose ( ) { } public void findSashes ( LayoutPart part , PartPane . Sashes sashes ) { } private void forceLayout ( ) { } public Rectangle getBounds ( ) { } public LayoutPart [ ] getChildren ( ) { } public Control getControl ( ) { } public int getItemCount ( ) { } public int getMinimumHeight ( ) { } protected LayoutPart getPaneFor ( IPresentablePart part ) { } public Composite getParent ( ) { } private IPresentablePart getPresentablePartAtIndex ( int idx ) { } private List getPresentableParts ( ) { } protected StackPresentation getPresentation ( ) { } public PartPane getVisiblePart ( ) { } private void presentationSelectionChanged ( IPresentablePart newSelection ) { } public void remove ( LayoutPart child ) { } public void reparent ( Composite newParent ) { } public void replace ( LayoutPart oldChild , LayoutPart newChild ) { IPresentablePart oldPart = oldChild . getPresentablePart ( ) ; IPresentablePart newPart = newChild . getPresentablePart ( ) ; int idx = children . indexOf ( oldChild ) ; children . add ( idx , newChild ) ; showPart ( newChild , oldPart ) ; <START_BUG> if ( oldChild == ( current ) ) { <END_BUG> setSelection ( newChild ) ; } remove ( oldChild ) ; } public boolean resizesVertically ( ) { } public IStatus restoreState ( IMemento memento ) { } public IStatus saveState ( IMemento memento ) { } protected WorkbenchPage getPage ( ) { } public void setActive ( int activeState ) { } public int getActive ( ) { } public void setBounds ( Rectangle r ) { } public void setSelection ( LayoutPart part ) { } protected void updateActions ( ) { } private void refreshPresentationSelection ( ) { } private void setState ( int newState ) { } public void setZoomed ( boolean isZoomed ) { } private void showPart ( LayoutPart part , Object cookie ) { } private void updateContainerVisibleTab ( ) { } private void updateControlBounds ( ) { } public void showSystemMenu ( ) { } public void showPaneMenu ( ) { } public void showPartList ( ) { } public Control [ ] getTabList ( LayoutPart part ) { } public void dragStart ( IPresentablePart beingDragged , Point initialLocation , boolean keyboard ) { } }

Fix:
if ( ( oldChild == ( current ) ) && ( ! ( newChild instanceof PartPlaceholder ) ) ) {