Buggy code:
public class Ant extends Task { private File dir = null ; private String antFile = null ; private String target = null ; private String output = null ; private boolean inheritAll = true ; private boolean inheritRefs = false ; private Vector properties = new Vector ( ) ; private Vector references = new Vector ( ) ; private Project newProject ; public void setInheritAll ( boolean value ) { } public void setInheritRefs ( boolean value ) { } public void init ( ) { } private void reinit ( ) { } private void initializeProject ( ) { Vector listeners = project . getBuildListeners ( ) ; <START_BUG> final int count = properties . size ( ) ; <END_BUG> for ( int i = 0 ; i < count ; i ++ ) { newProject . addBuildListener ( ( ( BuildListener ) ( listeners . elementAt ( i ) ) ) ) ; } if ( ( output ) != null ) { try { PrintStream out = new PrintStream ( new FileOutputStream ( output ) ) ; DefaultLogger logger = new DefaultLogger ( ) ; logger . setMessageOutputLevel ( MSG_INFO ) ; logger . setOutputPrintStream ( out ) ; logger . setErrorPrintStream ( out ) ; newProject . addBuildListener ( logger ) ; } catch ( IOException ex ) { log ( ( "Ant:<seq2seq4repair_space>Can't<seq2seq4repair_space>set<seq2seq4repair_space>output<seq2seq4repair_space>to<seq2seq4repair_space>" + ( output ) ) ) ; } } Hashtable taskdefs = project . getTaskDefinitions ( ) ; Enumeration et = taskdefs . keys ( ) ; while ( et . hasMoreElements ( ) ) { String taskName = ( ( String ) ( et . nextElement ( ) ) ) ; if ( taskName . equals ( "property" ) ) { continue ; } Class taskClass = ( ( Class ) ( taskdefs . get ( taskName ) ) ) ; newProject . addTaskDefinition ( taskName , taskClass ) ; } Hashtable typedefs = project . getDataTypeDefinitions ( ) ; Enumeration e = typedefs . keys ( ) ; while ( e . hasMoreElements ( ) ) { String typeName = ( ( String ) ( e . nextElement ( ) ) ) ; Class typeClass = ( ( Class ) ( typedefs . get ( typeName ) ) ) ; newProject . addDataTypeDefinition ( typeName , typeClass ) ; } Hashtable prop1 ; if ( inheritAll ) { prop1 = project . getProperties ( ) ; } else { prop1 = project . getUserProperties ( ) ; newProject . setSystemProperties ( ) ; } e = prop1 . keys ( ) ; while ( e . hasMoreElements ( ) ) { String arg = ( ( String ) ( e . nextElement ( ) ) ) ; if ( ( "basedir" . equals ( arg ) ) || ( "ant.file" . equals ( arg ) ) ) { continue ; } String value = ( ( String ) ( prop1 . get ( arg ) ) ) ; if ( inheritAll ) { newProject . setProperty ( arg , value ) ; } else { newProject . setUserProperty ( arg , value ) ; } } } protected void handleOutput ( String line ) { } protected void handleErrorOutput ( String line ) { } public void execute ( ) throws BuildException { } private void overrideProperties ( ) throws BuildException { } private void addReferences ( ) throws BuildException { } private void copyReference ( String oldKey , String newKey ) { } public void setDir ( File d ) { } public void setAntfile ( String s ) { } public void setTarget ( String s ) { } public void setOutput ( String s ) { } public Property createProperty ( ) { } public void addReference ( Ant . Reference r ) { } public static class Reference extends org . apache . tools . ant . types . Reference { public Reference ( ) { } private String targetid = null ; public void setToRefid ( String targetid ) { } public String getToRefid ( ) { } } }

Fix:
final int count = listeners . size ( ) ;