Buggy code:
public class PageLayout implements IPageLayout { private ArrayList actionSets = new ArrayList ( 3 ) ; private IPerspectiveDescriptor descriptor ; private LayoutPart editorFolder ; private boolean editorVisible = true ; private boolean fixed ; private ArrayList fastViews = new ArrayList ( 3 ) ; private Map mapIDtoFolder = new HashMap ( 10 ) ; private Map mapIDtoPart = new HashMap ( 10 ) ; private Map mapIDtoViewLayoutRec = new HashMap ( 10 ) ; private ArrayList newWizardShortcuts = new ArrayList ( 3 ) ; private ArrayList perspectiveShortcuts = new ArrayList ( 3 ) ; private ViewSashContainer rootLayoutContainer ; private ArrayList showInPartIds = new ArrayList ( 3 ) ; private ArrayList showViewShortcuts = new ArrayList ( 3 ) ; private ViewFactory viewFactory ; public PageLayout ( ) { } public PageLayout ( ViewSashContainer container , ViewFactory viewFactory , LayoutPart editorFolder , IPerspectiveDescriptor descriptor ) { } private void addEditorArea ( ) { } public void addActionSet ( String actionSetID ) { } public void addFastView ( String id ) { } public void addFastView ( String id , float ratio ) { } private boolean isFastViewId ( String partId ) { } ViewLayoutRec getViewLayoutRec ( String id , boolean create ) { } public void addNewWizardShortcut ( String id ) { } private void addPart ( LayoutPart newPart , String partId , int relationship , float ratio , String refId ) { } public void addPerspectiveShortcut ( String id ) { } public void addPlaceholder ( String viewId , int relationship , float ratio , String refId ) { } boolean checkValidPlaceholderId ( String id ) { } public void addShowInPart ( String id ) { } public void addShowViewShortcut ( String id ) { } public void addView ( String viewId , int relationship , float ratio , String refId ) { } private void addView ( String viewId , int relationship , float ratio , String refId , boolean standalone , boolean showTitle ) { } boolean checkPartInLayout ( String partId ) { } public IFolderLayout createFolder ( String folderId , int relationship , float ratio , String refId ) { } public IPlaceholderFolderLayout createPlaceholderFolder ( String folderId , int relationship , float ratio , String refId ) { } private LayoutPart createView ( String partID ) throws PartInitException { } public ArrayList getActionSets ( ) { } public IPerspectiveDescriptor getDescriptor ( ) { } public String getEditorArea ( ) { } public int getEditorReuseThreshold ( ) { } public ArrayList getFastViews ( ) { } private ViewStack getFolderPart ( String viewId ) { } public ArrayList getNewWizardShortcuts ( ) { } private int getPartSashConst ( int nRelationship ) { } public ArrayList getPerspectiveShortcuts ( ) { } LayoutPart getRefPart ( String partID ) { } public ViewSashContainer getRootLayoutContainer ( ) { } public ArrayList getShowInPartIds ( ) { } public ArrayList getShowViewShortcuts ( ) { } ViewFactory getViewFactory ( ) { } public boolean isEditorAreaVisible ( ) { } private float normalizeRatio ( float in ) { } private void prefill ( ) { } public void setEditorAreaVisible ( boolean showEditorArea ) { } public void setEditorReuseThreshold ( int openEditors ) { } public void setFixed ( boolean fixed ) { } public boolean isFixed ( ) { } void setFolderPart ( String viewId , ContainerPlaceholder container ) { } void setFolderPart ( String viewId , ViewStack folder ) { } void setRefPart ( String partID , LayoutPart part ) { } private void stackPart ( LayoutPart newPart , String viewId , String refId ) { setRefPart ( viewId , newPart ) ; getViewLayoutRec ( viewId , true ) ; ViewStack folder = getFolderPart ( refId ) ; if ( folder != null ) { folder . add ( newPart ) ; setFolderPart ( viewId , folder ) ; return ; } LayoutPart refPart = getRefPart ( refId ) ; <START_BUG> if ( refPart != null ) { <END_BUG> ViewStack newFolder = new ViewStack ( rootLayoutContainer . page ) ; rootLayoutContainer . replace ( refPart , newFolder ) ; newFolder . add ( refPart ) ; newFolder . add ( newPart ) ; setFolderPart ( refId , newFolder ) ; setFolderPart ( viewId , newFolder ) ; return ; } WorkbenchPlugin . log ( NLS . bind ( PageLayout_missingRefPart , refId ) ) ; rootLayoutContainer . add ( newPart ) ; } public void stackPlaceholder ( String viewId , String refId ) { } public void stackView ( String viewId , String refId ) { } public static int swtConstantToLayoutPosition ( int swtConstant ) { } public void addStandaloneView ( String viewId , boolean showTitle , int relationship , float ratio , String refId ) { } public void addStandaloneViewPlaceholder ( String viewId , int relationship , float ratio , String refId , boolean showTitle ) { } public IViewLayout getViewLayout ( String viewId ) { } public Map getIDtoViewLayoutRecMap ( ) { } public void removePlaceholder ( String id ) { } }

Fix:
if ( ( refPart != null ) && ( ( refPart instanceof PartPane ) || ( refPart instanceof PartPlaceholder ) ) ) {