Buggy code:
public class IncrementalImageBuilder extends AbstractImageBuilder { protected ArrayList sourceFiles ; protected ArrayList previousSourceFiles ; protected ArrayList qualifiedStrings ; protected ArrayList simpleStrings ; protected SimpleLookupTable secondaryTypesToRemove ; public static int MaxCompileLoop = 5 ; protected IncrementalImageBuilder ( JavaBuilder javaBuilder ) { } public boolean build ( SimpleLookupTable deltas ) { } protected void addAffectedSourceFiles ( ) { } protected void addDependentsOf ( IPath path , boolean hasStructuralChanges ) { } protected void cleanUp ( ) { } protected boolean findAffectedSourceFiles ( IResourceDelta delta , ClasspathLocation [ ] classFoldersAndJars ) { } protected void findAffectedSourceFiles ( IResourceDelta binaryDelta , int segmentCount ) { } protected boolean findSourceFiles ( IResourceDelta delta ) throws CoreException { } protected void findSourceFiles ( IResourceDelta sourceDelta , ClasspathMultiDirectory md , int segmentCount ) throws CoreException { IResource resource = sourceDelta . getResource ( ) ; if ( ( ( md . exclusionPatterns ) != null ) && ( Util . isExcluded ( resource , md . exclusionPatterns ) ) ) return ; switch ( resource . getType ( ) ) { case IResource . PROJECT : case IResource . FOLDER : switch ( sourceDelta . getKind ( ) ) { case IResourceDelta . ADDED : IPath addedPackagePath = resource . getFullPath ( ) . removeFirstSegments ( segmentCount ) ; createFolder ( addedPackagePath , md . binaryFolder ) ; if ( JavaBuilder . DEBUG ) System . out . println ( ( "Found<seq2seq4repair_space>added<seq2seq4repair_space>package<seq2seq4repair_space>" + addedPackagePath ) ) ; addDependentsOf ( addedPackagePath , true ) ; case IResourceDelta . CHANGED : IResourceDelta [ ] children = sourceDelta . getAffectedChildren ( ) ; for ( int i = 0 , l = children . length ; i < l ; i ++ ) findSourceFiles ( children [ i ] , md , segmentCount ) ; return ; case IResourceDelta . REMOVED : IPath removedPackagePath = resource . getFullPath ( ) . removeFirstSegments ( segmentCount ) ; if ( ( sourceLocations . length ) > 1 ) { for ( int i = 0 , l = sourceLocations . length ; i < l ; i ++ ) { if ( sourceLocations [ i ] . sourceFolder . getFolder ( removedPackagePath ) . exists ( ) ) { createFolder ( removedPackagePath , md . binaryFolder ) ; IResourceDelta [ ] removedChildren = sourceDelta . getAffectedChildren ( ) ; for ( int j = 0 , m = removedChildren . length ; j < m ; j ++ ) findSourceFiles ( removedChildren [ j ] , md , segmentCount ) ; return ; } } } IFolder removedPackageFolder = md . binaryFolder . getFolder ( removedPackagePath ) ; if ( removedPackageFolder . exists ( ) ) removedPackageFolder . delete ( IResource . FORCE , null ) ; if ( JavaBuilder . DEBUG ) System . out . println ( ( "Found<seq2seq4repair_space>removed<seq2seq4repair_space>package<seq2seq4repair_space>" + removedPackagePath ) ) ; addDependentsOf ( removedPackagePath , true ) ; newState . removePackage ( sourceDelta ) ; } return ; case IResource . FILE : <START_BUG> String filename = resource . getName ( ) ; <END_BUG> if ( Util . isJavaFileName ( resourceName ) ) { IPath typePath = resource . getFullPath ( ) . removeFirstSegments ( segmentCount ) . removeFileExtension ( ) ; String typeLocator = resource . getProjectRelativePath ( ) . toString ( ) ; switch ( sourceDelta . getKind ( ) ) { case IResourceDelta . ADDED : if ( JavaBuilder . DEBUG ) System . out . println ( ( "Compile<seq2seq4repair_space>this<seq2seq4repair_space>added<seq2seq4repair_space>source<seq2seq4repair_space>file<seq2seq4repair_space>" + typeLocator ) ) ; sourceFiles . add ( new SourceFile ( ( ( IFile ) ( resource ) ) , md , encoding ) ) ; String typeName = typePath . toString ( ) ; if ( ! ( newState . isDuplicateLocator ( typeName , typeLocator ) ) ) { if ( JavaBuilder . DEBUG ) System . out . println ( ( "Found<seq2seq4repair_space>added<seq2seq4repair_space>source<seq2seq4repair_space>file<seq2seq4repair_space>" + typeName ) ) ; addDependentsOf ( typePath , true ) ; } return ; case IResourceDelta . REMOVED : char [ ] [ ] definedTypeNames = newState . getDefinedTypeNamesFor ( typeLocator ) ; if ( definedTypeNames == null ) { removeClassFile ( typePath , md . binaryFolder ) ; if ( ( ( sourceDelta . getFlags ( ) ) & ( IResourceDelta . MOVED_TO ) ) != 0 ) { IResource movedFile = javaBuilder . workspaceRoot . getFile ( sourceDelta . getMovedToPath ( ) ) ; JavaBuilder . removeProblemsAndTasksFor ( movedFile ) ; } } else { if ( JavaBuilder . DEBUG ) System . out . println ( ( "Found<seq2seq4repair_space>removed<seq2seq4repair_space>source<seq2seq4repair_space>file<seq2seq4repair_space>" + ( typePath . toString ( ) ) ) ) ; addDependentsOf ( typePath , true ) ; if ( ( definedTypeNames . length ) > 0 ) { IPath packagePath = typePath . removeLastSegments ( 1 ) ; for ( int i = 0 , l = definedTypeNames . length ; i < l ; i ++ ) removeClassFile ( packagePath . append ( new String ( definedTypeNames [ i ] ) ) , md . binaryFolder ) ; } } newState . removeLocator ( typeLocator ) ; return ; case IResourceDelta . CHANGED : if ( ( ( sourceDelta . getFlags ( ) ) & ( IResourceDelta . CONTENT ) ) == 0 ) return ; if ( JavaBuilder . DEBUG ) System . out . println ( ( "Compile<seq2seq4repair_space>this<seq2seq4repair_space>changed<seq2seq4repair_space>source<seq2seq4repair_space>file<seq2seq4repair_space>" + typeLocator ) ) ; sourceFiles . add ( new SourceFile ( ( ( IFile ) ( resource ) ) , md , encoding ) ) ; } return ; } else if ( Util . isClassFileName ( resourceName ) ) { return ; } else if ( md . hasIndependentOutputFolder ) { if ( javaBuilder . filterExtraResource ( resource ) ) return ; IPath resourcePath = resource . getFullPath ( ) . removeFirstSegments ( segmentCount ) ; IResource outputFile = md . binaryFolder . getFile ( resourcePath ) ;

Fix:
String resourceName = resource . getName ( ) ;