Buggy code:
public abstract class AbstractImageBuilder implements ICompilerRequestor { protected JavaBuilder javaBuilder ; protected State newState ; protected NameEnvironment nameEnvironment ; protected ClasspathMultiDirectory [ ] sourceLocations ; protected BuildNotifier notifier ; protected String encoding ; protected Compiler compiler ; protected WorkQueue workQueue ; protected ArrayList problemSourceFiles ; protected boolean compiledAllAtOnce ; private boolean inCompiler ; public static int MAX_AT_ONCE = 1000 ; protected AbstractImageBuilder ( JavaBuilder javaBuilder ) { } public void acceptResult ( CompilationResult result ) { SourceFile compilationUnit = ( ( SourceFile ) ( result . getCompilationUnit ( ) ) ) ; if ( ! ( workQueue . isCompiled ( compilationUnit ) ) ) { workQueue . finished ( compilationUnit ) ; try { updateProblemsFor ( compilationUnit , result ) ; updateTasksFor ( compilationUnit , result ) ; } catch ( CoreException e ) { throw internalException ( e ) ; } String typeLocator = compilationUnit . typeLocator ( ) ; ClassFile [ ] classFiles = result . getClassFiles ( ) ; int length = classFiles . length ; ArrayList duplicateTypeNames = null ; ArrayList definedTypeNames = new ArrayList ( length ) ; for ( int i = 0 ; i < length ; i ++ ) { ClassFile classFile = classFiles [ i ] ; char [ ] [ ] compoundName = classFile . getCompoundName ( ) ; char [ ] typeName = compoundName [ ( ( compoundName . length ) - 1 ) ] ; <START_BUG> boolean isNestedType = CharOperation . contains ( '$' , typeName ) ; <END_BUG> if ( isNestedType ) { String qualifiedTypeName = new String ( classFile . outerMostEnclosingClassFile ( ) . fileName ( ) ) ; if ( newState . isDuplicateLocator ( qualifiedTypeName , typeLocator ) ) continue ; } else { String qualifiedTypeName = new String ( classFile . fileName ( ) ) ; if ( newState . isDuplicateLocator ( qualifiedTypeName , typeLocator ) ) { if ( duplicateTypeNames == null ) duplicateTypeNames = new ArrayList ( ) ; duplicateTypeNames . add ( compoundName ) ; createProblemFor ( compilationUnit . resource , Util . bind ( "build.duplicateClassFile" , new String ( typeName ) ) , JavaCore . ERROR ) ; continue ; } newState . recordLocatorForType ( qualifiedTypeName , typeLocator ) ; } try { definedTypeNames . add ( writeClassFile ( classFile , compilationUnit , ( ! isNestedType ) ) ) ; } catch ( CoreException e ) { Util . log ( e , "JavaBuilder<seq2seq4repair_space>handling<seq2seq4repair_space>CoreException" ) ; if ( ( e . getStatus ( ) . getCode ( ) ) == ( IResourceStatus . CASE_VARIANT_EXISTS ) ) createProblemFor ( compilationUnit . resource , Util . bind ( "build.classFileCollision" , e . getMessage ( ) ) , JavaCore . ERROR ) ; else createProblemFor ( compilationUnit . resource , Util . bind ( "build.inconsistentClassFile" ) , JavaCore . ERROR ) ; } } finishedWith ( typeLocator , result , compilationUnit . getMainTypeName ( ) , definedTypeNames , duplicateTypeNames ) ; notifier . compiled ( compilationUnit ) ; } } protected void cleanUp ( ) { } protected void compile ( SourceFile [ ] units ) { } void compile ( SourceFile [ ] units , SourceFile [ ] additionalUnits ) { } protected void createProblemFor ( IResource resource , String message , String problemSeverity ) { } protected void finishedWith ( String sourceLocator , CompilationResult result , char [ ] mainTypeName , ArrayList definedTypeNames , ArrayList duplicateTypeNames ) { } protected IContainer createFolder ( IPath packagePath , IContainer outputFolder ) throws CoreException { } protected RuntimeException internalException ( CoreException t ) { } protected Compiler newCompiler ( ) { } protected boolean isExcludedFromProject ( IPath childPath ) throws JavaModelException { } protected void storeProblemsFor ( SourceFile sourceFile , IProblem [ ] problems ) throws CoreException { } protected void storeTasksFor ( SourceFile sourceFile , IProblem [ ] tasks ) throws CoreException { } protected void updateProblemsFor ( SourceFile sourceFile , CompilationResult result ) throws CoreException { } protected void updateTasksFor ( SourceFile sourceFile , CompilationResult result ) throws CoreException { } protected char [ ] writeClassFile ( ClassFile classFile , SourceFile compilationUnit , boolean isSecondaryType ) throws CoreException { } protected void writeClassFileBytes ( byte [ ] bytes , IFile file , String qualifiedFileName , boolean isSecondaryType , boolean updateClassFile ) throws CoreException { } }

Fix:
boolean isNestedType = ( classFile . enclosingClassFile ) != null ;