Buggy code:
public class CopyResourceElementsOperation extends MultiOperation implements SuffixConstants { protected ArrayList fRenamedCompilationUnits = null ; protected Map fDeltasPerProject = new HashMap ( 1 ) ; protected DOMFactory fFactory ; protected ArrayList fCreatedElements ; public CopyResourceElementsOperation ( IJavaElement [ ] resourcesToCopy , IJavaElement [ ] destContainers , boolean force ) { } public CopyResourceElementsOperation ( IJavaElement [ ] resourcesToCopy , IJavaElement destContainer , boolean force ) { } private IResource [ ] collectResourcesOfInterest ( IPackageFragment source ) throws JavaModelException { } private void createNeededPackageFragments ( IContainer sourceFolder , IPackageFragmentRoot root , String newFragName , boolean moveFolder ) throws JavaModelException { } private JavaElementDelta getDeltaFor ( IJavaProject javaProject ) { } protected String getMainTaskName ( ) { } protected void prepareDeltas ( IJavaElement sourceElement , IJavaElement destinationElement , boolean isMove ) { } private void processCompilationUnitResource ( ICompilationUnit source , IPackageFragment dest ) throws JavaModelException { String newCUName = getNewNameFor ( source ) ; String destName = ( newCUName != null ) ? newCUName : source . getElementName ( ) ; String newContent = updatedContent ( source , dest , newCUName ) ; <START_BUG> IFile sourceResource = ( ( IFile ) ( ( source . isWorkingCopy ( ) ? source . getOriginalElement ( ) : source ) . getResource ( ) ) ) ; <END_BUG> IContainer destFolder = ( ( IContainer ) ( dest . getResource ( ) ) ) ; IFile destFile = destFolder . getFile ( new Path ( destName ) ) ; if ( ! ( destFile . equals ( sourceResource ) ) ) { try { if ( destFile . exists ( ) ) { if ( fForce ) { deleteResource ( destFile , IResource . KEEP_HISTORY ) ; } else { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . NAME_COLLISION , org . eclipse . jdt . internal . compiler . util . Util . bind ( "status.nameCollision" , destFile . getFullPath ( ) . toString ( ) ) ) ) ; } } int flags = ( fForce ) ? IResource . FORCE : IResource . NONE ; if ( this . isMove ( ) ) { flags |= IResource . KEEP_HISTORY ; sourceResource . move ( destFile . getFullPath ( ) , flags , getSubProgressMonitor ( 1 ) ) ; } else { if ( newContent != null ) flags |= IResource . KEEP_HISTORY ; sourceResource . copy ( destFile . getFullPath ( ) , flags , getSubProgressMonitor ( 1 ) ) ; } this . setAttribute ( JavaModelOperation . HAS_MODIFIED_RESOURCE_ATTR , JavaModelOperation . TRUE ) ; } catch ( JavaModelException e ) { throw e ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } try { if ( newContent != null ) { String encoding = source . getJavaProject ( ) . getOption ( JavaCore . CORE_ENCODING , true ) ; destFile . setContents ( new ByteArrayInputStream ( ( encoding == null ? newContent . getBytes ( ) : newContent . getBytes ( encoding ) ) ) , ( fForce ? ( IResource . FORCE ) | ( IResource . KEEP_HISTORY ) : IResource . KEEP_HISTORY ) , getSubProgressMonitor ( 1 ) ) ; } } catch ( IOException e ) { throw new JavaModelException ( e , IJavaModelStatusConstants . IO_EXCEPTION ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } ICompilationUnit destCU = dest . getCompilationUnit ( destName ) ; prepareDeltas ( source , destCU , isMove ( ) ) ; if ( newCUName != null ) { String oldName = source . getElementName ( ) ; oldName = oldName . substring ( 0 , ( ( oldName . length ( ) ) - 5 ) ) ; String newName = newCUName ; newName = newName . substring ( 0 , ( ( newName . length ( ) ) - 5 ) ) ; prepareDeltas ( source . getType ( oldName ) , destCU . getType ( newName ) , isMove ( ) ) ; } } else { if ( ! ( fForce ) ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . NAME_COLLISION , org . eclipse . jdt . internal . compiler . util . Util . bind ( "status.nameCollision" , destFile . getFullPath ( ) . toString ( ) ) ) ) ; } try { if ( newContent != null ) { String encoding = source . getJavaProject ( ) . getOption ( JavaCore . CORE_ENCODING , true ) ; destFile . setContents ( new ByteArrayInputStream ( ( encoding == null ? newContent . getBytes ( ) : newContent . getBytes ( encoding ) ) ) , ( fForce ? ( IResource . FORCE ) | ( IResource . KEEP_HISTORY ) : IResource . KEEP_HISTORY ) , getSubProgressMonitor ( 1 ) ) ; } } catch ( IOException e ) { throw new JavaModelException ( e , IJavaModelStatusConstants . IO_EXCEPTION ) ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } } } protected void processDeltas ( ) { } protected void processElement ( IJavaElement element ) throws JavaModelException { } protected void processElements ( ) throws JavaModelException { } private void processPackageFragmentResource ( IPackageFragment source , IPackageFragmentRoot root , String newName ) throws JavaModelException { } private String updatedContent ( ICompilationUnit cu , IPackageFragment dest , String newName ) throws JavaModelException { } private void updatePackageStatement ( IDOMCompilationUnit domCU , String pkgName ) throws JavaModelException { } private void updateTypeName ( ICompilationUnit cu , IDOMCompilationUnit domCU , String oldName , String newName ) throws JavaModelException { } protected IJavaModelStatus verify ( ) { } protected void verify ( IJavaElement element ) throws JavaModelException { } }

Fix:
IFile sourceResource = ( ( IFile ) ( source . getResource ( ) ) ) ;