Buggy code:
protected abstract boolean isMoveable ( 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 ) { } public PartStack ( int appearance , AbstractPresentationFactory factory ) { } public void addListener ( IPropertyListener listener ) { } public void removeListener ( IPropertyListener listener ) { } protected final boolean isStandalone ( ) { } 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 allowsAdd ( LayoutPart toAdd ) { } public boolean allowsAutoFocus ( ) { } protected void close ( IPresentablePart [ ] parts ) { } protected void close ( IPresentablePart part ) { } public boolean isDisposed ( ) { } protected AbstractPresentationFactory getFactory ( ) { } public void createControl ( Composite parent ) { } public IDropTarget getDropTarget ( Object draggedObject , Point position ) { } public void setActive ( boolean isActive ) { } public void createControl ( Composite parent , StackPresentation presentation ) { } public IDropTarget createDropTarget ( PartPane pane , StackDropResult result ) { } protected void savePresentationState ( ) { } public void dispose ( ) { } public void findSashes ( LayoutPart part , PartPane . Sashes sashes ) { } public Rectangle getBounds ( ) { } public LayoutPart [ ] getChildren ( ) { } public Control getControl ( ) { } public int getItemCount ( ) { } protected LayoutPart getPaneFor ( IPresentablePart part ) { } public Composite getParent ( ) { } public List getPresentableParts ( ) { } private PresentablePart getPresentablePart ( LayoutPart pane ) { } protected StackPresentation getPresentation ( ) { } public PartPane getSelection ( ) { } private void presentationSelectionChanged ( IPresentablePart newSelection ) { } public void remove ( LayoutPart child ) { } public void reparent ( Composite newParent ) { } public void replace ( LayoutPart oldChild , LayoutPart newChild ) { } public int computePreferredSize ( boolean width , int availableParallel , int availablePerpendicular , int preferredParallel ) { } public int getSizeFlags ( boolean horizontal ) { } public IStatus restoreState ( IMemento memento ) { } public void setVisible ( boolean makeVisible ) { } 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 abstract void updateActions ( PresentablePart current ) { } protected void handleDeferredEvents ( ) { } private void refreshPresentationSelection ( ) { } public int getState ( ) { } public void setMinimized ( boolean minimized ) { } public boolean childObscuredByZoom ( LayoutPart toTest ) { } public void childRequestZoomIn ( LayoutPart toZoom ) { } public void childRequestZoomOut ( ) { } public boolean childIsZoomed ( LayoutPart toTest ) { } private boolean isIntroInStack ( ) { } private void smartZoom ( ) { } protected void smartUnzoom ( ) { } protected void setState ( final int newState ) { final int oldState = presentationSite . getState ( ) ; if ( ( ! ( supportsState ( newState ) ) ) || ( newState == oldState ) ) { return ; } final WorkbenchWindow wbw = ( ( WorkbenchWindow ) ( getPage ( ) . getWorkbenchWindow ( ) ) ) ; <START_BUG> if ( ( wbw == null ) || ( ( wbw . getShell ( ) ) == null ) ) <END_BUG> return ; boolean useNewMinMax = Perspective . useNewMinMax ( wbw . getActiveWorkbenchPage ( ) . getActivePerspective ( ) ) ; if ( newState == ( IStackPresentationSite . STATE_MAXIMIZED ) ) useNewMinMax = useNewMinMax && ( ! ( isIntroInStack ( ) ) ) ; else if ( newState == ( IStackPresentationSite . STATE_RESTORED ) ) useNewMinMax = useNewMinMax && ( smartZoomed ) ; if ( useNewMinMax ) { StartupThreading . runWithoutExceptions ( new StartupRunnable ( ) { public void runWithException ( ) throws Throwable { wbw . getPageComposite ( ) . setRedraw ( false ) ; try { if ( newState == ( IStackPresentationSite . STATE_MAXIMIZED ) ) { smartZoom ( ) ; } else if ( oldState == ( IStackPresentationSite . STATE_MAXIMIZED ) ) { smartUnzoom ( ) ; } if ( newState == ( IStackPresentationSite . STATE_MINIMIZED ) ) { setMinimized ( true ) ; } } finally { wbw . getPageComposite ( ) . setRedraw ( true ) ; wbw . getShell ( ) . redraw ( ) ; } setPresentationState ( newState ) ; } } ) ; } else { boolean minimized = newState == ( IStackPresentationSite . STATE_MINIMIZED ) ; setMinimized ( minimized ) ; if ( newState == ( IStackPresentationSite . STATE_MAXIMIZED ) ) { requestZoomIn ( ) ; } else if ( oldState == ( IStackPresentationSite . STATE_MAXIMIZED ) ) { requestZoomOut ( ) ; if ( newState == ( IStackPresentationSite . STATE_MINIMIZED ) ) setMinimized ( true ) ; } } } public void setZoomed ( boolean isZoomed ) { } public boolean isZoomed ( ) { } protected void refreshPresentationState ( ) { } private void showPart ( LayoutPart part , Object cookie ) { } private void updateContainerVisibleTab ( ) { } public void showSystemMenu ( ) { } public void showPaneMenu ( ) { }

Fix:
if ( ( ( wbw == null ) || ( ( wbw . getShell ( ) ) == null ) ) || ( ( wbw . getActiveWorkbenchPage ( ) ) == null ) )