Buggy code:
public class Copy extends Task { protected File file = null ; protected File destFile = null ; protected File destDir = null ; protected Vector filesets = new Vector ( ) ; private boolean enableMultipleMappings = false ; protected boolean filtering = false ; protected boolean preserveLastModified = false ; protected boolean forceOverwrite = false ; protected boolean flatten = false ; protected int verbosity = Project . MSG_VERBOSE ; protected boolean includeEmpty = true ; protected boolean failonerror = true ; protected Hashtable fileCopyMap = new Hashtable ( ) ; protected Hashtable dirCopyMap = new Hashtable ( ) ; protected Hashtable completeDirMap = new Hashtable ( ) ; protected Mapper mapperElement = null ; protected FileUtils fileUtils ; private Vector filterChains = new Vector ( ) ; private Vector filterSets = new Vector ( ) ; private String inputEncoding = null ; private String outputEncoding = null ; private long granularity = 0 ; public Copy ( ) { } protected FileUtils getFileUtils ( ) { } public void setFile ( File file ) { } public void setTofile ( File destFile ) { } public void setTodir ( File destDir ) { } public FilterChain createFilterChain ( ) { } public FilterSet createFilterSet ( ) { } public void setPreserveLastModified ( String preserve ) { } public void setPreserveLastModified ( boolean preserve ) { } public boolean getPreserveLastModified ( ) { } protected Vector getFilterSets ( ) { } protected Vector getFilterChains ( ) { } public void setFiltering ( boolean filtering ) { } public void setOverwrite ( boolean overwrite ) { } public void setFlatten ( boolean flatten ) { } public void setVerbose ( boolean verbose ) { } public void setIncludeEmptyDirs ( boolean includeEmpty ) { } public void setEnableMultipleMappings ( boolean enableMultipleMappings ) { } public boolean isEnableMultipleMapping ( ) { } public void setFailOnError ( boolean failonerror ) { } public void addFileset ( FileSet set ) { } public Mapper createMapper ( ) throws BuildException { } public void add ( FileNameMapper fileNameMapper ) { } public void setEncoding ( String encoding ) { } public String getEncoding ( ) { } public void setOutputEncoding ( String encoding ) { } public String getOutputEncoding ( ) { } public void setGranularity ( long granularity ) { } public void execute ( ) throws BuildException { } protected void validateAttributes ( ) throws BuildException { if ( ( ( file ) == null ) && ( ( filesets . size ( ) ) == 0 ) ) { throw new BuildException ( ( "Specify<seq2seq4repair_space>at<seq2seq4repair_space>least<seq2seq4repair_space>one<seq2seq4repair_space>source<seq2seq4repair_space>" + "-<seq2seq4repair_space>a<seq2seq4repair_space>file<seq2seq4repair_space>or<seq2seq4repair_space>a<seq2seq4repair_space>fileset." ) ) ; } if ( ( ( destFile ) != null ) && ( ( destDir ) != null ) ) { throw new BuildException ( ( "Only<seq2seq4repair_space>one<seq2seq4repair_space>of<seq2seq4repair_space>tofile<seq2seq4repair_space>and<seq2seq4repair_space>todir<seq2seq4repair_space>" + "may<seq2seq4repair_space>be<seq2seq4repair_space>set." ) ) ; } if ( ( ( destFile ) == null ) && ( ( destDir ) == null ) ) { throw new BuildException ( "One<seq2seq4repair_space>of<seq2seq4repair_space>tofile<seq2seq4repair_space>or<seq2seq4repair_space>todir<seq2seq4repair_space>must<seq2seq4repair_space>be<seq2seq4repair_space>set." ) ; } if ( ( ( file ) != null ) && ( file . isDirectory ( ) ) ) { throw new BuildException ( "Use<seq2seq4repair_space>a<seq2seq4repair_space>fileset<seq2seq4repair_space>to<seq2seq4repair_space>copy<seq2seq4repair_space>directories." ) ; } if ( ( ( destFile ) != null ) && ( ( filesets . size ( ) ) > 0 ) ) { if ( ( filesets . size ( ) ) > 1 ) { throw new BuildException ( "Cannot<seq2seq4repair_space>concatenate<seq2seq4repair_space>multiple<seq2seq4repair_space>files<seq2seq4repair_space>into<seq2seq4repair_space>a<seq2seq4repair_space>single<seq2seq4repair_space>file." ) ; } else { FileSet fs = ( ( FileSet ) ( filesets . elementAt ( 0 ) ) ) ; DirectoryScanner ds = fs . getDirectoryScanner ( getProject ( ) ) ; String [ ] srcFiles = ds . getIncludedFiles ( ) ; if ( ( srcFiles . length ) == 0 ) { throw new BuildException ( "Cannot<seq2seq4repair_space>perform<seq2seq4repair_space>operation<seq2seq4repair_space>from<seq2seq4repair_space>directory<seq2seq4repair_space>to<seq2seq4repair_space>file." ) ; } else if ( ( srcFiles . length ) == 1 ) { if ( ( file ) == null ) { file = new File ( ds . getBasedir ( ) , srcFiles [ 0 ] ) ; filesets . removeElementAt ( 0 ) ; } else { throw new BuildException ( ( "Cannot<seq2seq4repair_space>concatenate<seq2seq4repair_space>multiple<seq2seq4repair_space>" + "files<seq2seq4repair_space>into<seq2seq4repair_space>a<seq2seq4repair_space>single<seq2seq4repair_space>file." ) ) ; } } else { throw new BuildException ( ( "Cannot<seq2seq4repair_space>concatenate<seq2seq4repair_space>multiple<seq2seq4repair_space>" + "files<seq2seq4repair_space>into<seq2seq4repair_space>a<seq2seq4repair_space>single<seq2seq4repair_space>file." ) ) ; } } } if ( ( destFile ) != null ) { <START_BUG> destDir = fileUtils . getParentFile ( destFile ) ; <END_BUG> } } protected void scan ( File fromDir , File toDir , String [ ] files , String [ ] dirs ) { } protected void buildMap ( File fromDir , File toDir , String [ ] names , FileNameMapper mapper , Hashtable map ) { } protected void doFileOperations ( ) { } }

Fix:
destDir = destFile . getParentFile ( ) ;