Buggy code:
ArrayList nonFileResources = new ArrayList ( ) ; for ( int i = 0 ; i < ( rcs . size ( ) ) ; i ++ ) { ResourceCollection rc = ( ( ResourceCollection ) ( rcs . elementAt ( i ) ) ) ; if ( ( rc instanceof FileSet ) && ( rc . isFilesystemOnly ( ) ) ) { FileSet fs = ( ( FileSet ) ( rc ) ) ; DirectoryScanner ds = null ; try { ds = fs . getDirectoryScanner ( getProject ( ) ) ; } catch ( BuildException e ) { if ( ( failonerror ) || ( ! ( e . getMessage ( ) . endsWith ( "<seq2seq4repair_space>not<seq2seq4repair_space>found." ) ) ) ) { throw e ; } else { log ( ( "Warning:<seq2seq4repair_space>" + ( e . getMessage ( ) ) ) ) ; continue ; } } File fromDir = fs . getDir ( getProject ( ) ) ; String [ ] srcFiles = ds . getIncludedFiles ( ) ; String [ ] srcDirs = ds . getIncludedDirectories ( ) ; if ( ( ( ( ! ( flatten ) ) && ( ( mapperElement ) == null ) ) && ( ds . isEverythingIncluded ( ) ) ) && ( ! ( fs . hasPatterns ( ) ) ) ) { completeDirMap . put ( fromDir , destDir ) ; } Copy . add ( fromDir , srcFiles , filesByBasedir ) ; Copy . add ( fromDir , srcDirs , dirsByBasedir ) ; baseDirs . add ( fromDir ) ; } else { if ( ( ! ( rc . isFilesystemOnly ( ) ) ) && ( ! ( supportsNonFileResources ( ) ) ) ) { throw new BuildException ( "Only<seq2seq4repair_space>FileSystem<seq2seq4repair_space>resources<seq2seq4repair_space>are<seq2seq4repair_space>supported." ) ; } Iterator resources = rc . iterator ( ) ; while ( resources . hasNext ( ) ) { Resource r = ( ( Resource ) ( resources . next ( ) ) ) ; if ( ! ( r . isExists ( ) ) ) { continue ; } File baseDir = Copy . NULL_FILE_PLACEHOLDER ; String name = r . getName ( ) ; if ( r instanceof FileResource ) { FileResource fr = ( ( FileResource ) ( r ) ) ; baseDir = Copy . getKeyFile ( fr . getBaseDir ( ) ) ; if ( ( fr . getBaseDir ( ) ) == null ) { name = fr . getFile ( ) . getAbsolutePath ( ) ; } } if ( ( r . isDirectory ( ) ) || ( r instanceof FileResource ) ) { Copy . add ( baseDir , name , ( r . isDirectory ( ) ? dirsByBasedir : filesByBasedir ) ) ; baseDirs . add ( baseDir ) ; } else { nonFileResources . add ( r ) ; } } } } Iterator iter = baseDirs . iterator ( ) ; while ( iter . hasNext ( ) ) { File f = ( ( File ) ( iter . next ( ) ) ) ; List files = ( ( List ) ( filesByBasedir . get ( f ) ) ) ; List dirs = ( ( List ) ( dirsByBasedir . get ( f ) ) ) ; String [ ] srcFiles = new String [ 0 ] ; if ( files != null ) { srcFiles = ( ( String [ ] ) ( files . toArray ( srcFiles ) ) ) ; } String [ ] srcDirs = new String [ 0 ] ; if ( dirs != null ) { srcDirs = ( ( String [ ] ) ( dirs . toArray ( srcDirs ) ) ) ; } scan ( ( f == ( Copy . NULL_FILE_PLACEHOLDER ) ? null : f ) , destDir , srcFiles , srcDirs ) ; } try { doFileOperations ( ) ; } catch ( BuildException e ) { if ( ! ( failonerror ) ) { log ( ( "Warning:<seq2seq4repair_space>" + ( e . getMessage ( ) ) ) , MSG_ERR ) ; } else { throw e ; } } if ( ( nonFileResources . size ( ) ) > 0 ) { <START_BUG> Resource [ ] nonFiles = ( ( Resource [ ] ) ( nonFileResources . toArray ( new Resource [ 0 ] ) ) ) ; <END_BUG> Map map = scan ( nonFiles , destDir ) ; try { doResourceOperations ( map ) ; } catch ( BuildException e ) { if ( ! ( failonerror ) ) { log ( ( "Warning:<seq2seq4repair_space>" + ( e . getMessage ( ) ) ) , MSG_ERR ) ; } else { throw e ; } } } } finally { file = savedFile ; destFile = savedDestFile ; destDir = savedDestDir ; if ( savedRc != null ) { rcs . insertElementAt ( savedRc , 0 ) ; } fileCopyMap . clear ( ) ; dirCopyMap . clear ( ) ; completeDirMap . clear ( ) ; } } protected void validateAttributes ( ) throws BuildException { } protected void scan ( File fromDir , File toDir , String [ ] files , String [ ] dirs ) { } protected Map scan ( Resource [ ] fromResources , File toDir ) { } protected void buildMap ( File fromDir , File toDir , String [ ] names , FileNameMapper mapper , Hashtable map ) { } protected Map buildMap ( Resource [ ] fromResources , final File toDir , FileNameMapper mapper ) { } protected void doFileOperations ( ) { } protected void doResourceOperations ( Map map ) { } protected boolean supportsNonFileResources ( ) { } private static void add ( File baseDir , String [ ] names , Map m ) { } private static void add ( File baseDir , String name , Map m ) { } private static File getKeyFile ( File f ) { }

Fix:
Resource [ ] nonFiles = ( ( Resource [ ] ) ( nonFileResources . toArray ( new Resource [ nonFileResources . size ( ) ] ) ) ) ;