Buggy code:
public class CopyResourceElementsOperation extends MultiOperation { 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 ( IPackageFragmentRoot root , String newFragName ) throws JavaModelException { } private JavaElementDelta getDeltaFor ( IJavaProject javaProject ) { } protected String getMainTaskName ( ) { } protected void prepareDeltas ( IJavaElement sourceElement , IJavaElement destinationElement ) { } 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 ) ; IFile sourceResource = ( ( IFile ) ( ( source . isWorkingCopy ( ) ? source . getOriginalElement ( ) : source ) . getCorrespondingResource ( ) ) ) ; IContainer destFolder = ( ( IContainer ) ( dest . getCorrespondingResource ( ) ) ) ; IFile destFile = destFolder . getFile ( new Path ( destName ) ) ; if ( ! ( destFile . equals ( sourceResource ) ) ) { try { if ( destFile . exists ( ) ) { if ( fForce ) { deleteResource ( destFile , false ) ; } else { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . NAME_COLLISION ) ) ; } } if ( this . isMove ( ) ) { sourceResource . move ( destFile . getFullPath ( ) , fForce , true , getSubProgressMonitor ( 1 ) ) ; } else { sourceResource . copy ( destFile . getFullPath ( ) , fForce , getSubProgressMonitor ( 1 ) ) ; } this . hasModifiedResource = true ; } catch ( JavaModelException e ) { throw e ; } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } try { <START_BUG> if ( newContent != null ) { <END_BUG> destFile . setContents ( new ByteArrayInputStream ( newContent . getBytes ( ) ) , fForce , true , getSubProgressMonitor ( 1 ) ) ; } } catch ( CoreException e ) { throw new JavaModelException ( e ) ; } ICompilationUnit destCU = dest . getCompilationUnit ( destName ) ; prepareDeltas ( source , destCU ) ; 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 ) ) ; } } else { if ( ! ( fForce ) ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . NAME_COLLISION ) ) ; } try { if ( newContent != null ) { destFile . setContents ( new ByteArrayInputStream ( newContent . getBytes ( ) ) , fForce , true , getSubProgressMonitor ( 1 ) ) ; } } 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:
if ( ( ! ( destFile . isReadOnly ( ) ) ) && ( newContent != null ) ) {