Buggy code:
public class ASTParser { public static final int K_EXPRESSION = 1 ; public static final int K_STATEMENTS = 2 ; public static final int K_CLASS_BODY_DECLARATIONS = 4 ; public static final int K_COMPILATION_UNIT = 8 ; public static ASTParser newParser ( int level ) { } private final int apiLevel ; private int astKind ; private Map compilerOptions ; private boolean resolveBindings ; private boolean partial = false ; private int focalPointPosition ; private char [ ] rawSource = null ; private ICompilationUnit compilationUnitSource = null ; private IClassFile classFileSource = null ; private int sourceOffset = 0 ; private int sourceLength = - 1 ; private WorkingCopyOwner workingCopyOwner = DefaultWorkingCopyOwner . PRIMARY ; private IJavaProject project = null ; private String unitName = null ; ASTParser ( int level ) { } private void initializeDefaults ( ) { } public void setCompilerOptions ( Map options ) { } public void setResolveBindings ( boolean bindings ) { } public void setFocalPosition ( int position ) { } public void setKind ( int kind ) { } public void setSource ( char [ ] source ) { } public void setSource ( ICompilationUnit source ) { } public void setSource ( IClassFile source ) { } public void setSourceRange ( int offset , int length ) { } public void setWorkingCopyOwner ( WorkingCopyOwner owner ) { } public void setUnitName ( String unitName ) { } public void setProject ( IJavaProject project ) { } public ASTNode createAST ( IProgressMonitor monitor ) { } public void createASTs ( ICompilationUnit [ ] compilationUnits , String [ ] bindingKeys , ASTRequestor requestor , IProgressMonitor monitor ) { } private ASTNode internalCreateAST ( IProgressMonitor monitor ) { boolean needToResolveBindings = this . resolveBindings ; switch ( this . astKind ) { case ASTParser . K_CLASS_BODY_DECLARATIONS : case ASTParser . K_EXPRESSION : case ASTParser . K_STATEMENTS : if ( ( this . rawSource ) != null ) { if ( ( ( this . sourceOffset ) + ( this . sourceLength ) ) > ( this . rawSource . length ) ) { throw new IllegalStateException ( ) ; } return internalCreateASTForKind ( ) ; } break ; case ASTParser . K_COMPILATION_UNIT : CompilationUnitDeclaration compilationUnitDeclaration = null ; try { NodeSearcher searcher = null ; org . eclipse . jdt . internal . compiler . env . ICompilationUnit sourceUnit = null ; if ( ( this . compilationUnitSource ) != null ) { sourceUnit = ( ( org . eclipse . jdt . internal . compiler . env . ICompilationUnit ) ( this . compilationUnitSource ) ) ; sourceUnit = new BasicCompilationUnit ( sourceUnit . getContents ( ) , sourceUnit . getPackageName ( ) , new String ( sourceUnit . getFileName ( ) ) , this . project ) ; } else if ( ( this . classFileSource ) != null ) { try { String sourceString = this . classFileSource . getSource ( ) ; if ( sourceString == null ) { throw new IllegalStateException ( ) ; } PackageFragment packageFragment = ( ( PackageFragment ) ( this . classFileSource . getParent ( ) ) ) ; BinaryType type = ( ( BinaryType ) ( this . classFileSource . getType ( ) ) ) ; IBinaryType binaryType = ( ( IBinaryType ) ( type . getElementInfo ( ) ) ) ; <START_BUG> String fileName = type . sourceFileName ( binaryType ) ; <END_BUG> sourceUnit = new BasicCompilationUnit ( sourceString . toCharArray ( ) , Util . toCharArrays ( packageFragment . names ) , fileName , this . project ) ; } catch ( JavaModelException e ) { throw new IllegalStateException ( ) ; } } else if ( ( this . rawSource ) != null ) { needToResolveBindings = ( ( ( this . unitName ) != null ) && ( ( this . project ) != null ) ) && ( ( this . compilerOptions ) != null ) ; sourceUnit = new BasicCompilationUnit ( this . rawSource , null , ( ( this . unitName ) == null ? "" : this . unitName ) , this . project ) ; } else { throw new IllegalStateException ( ) ; } if ( this . partial ) { searcher = new NodeSearcher ( this . focalPointPosition ) ; } if ( needToResolveBindings && ( ( this . project ) != null ) ) { try { compilationUnitDeclaration = CompilationUnitResolver . resolve ( sourceUnit , this . project , searcher , this . compilerOptions , this . workingCopyOwner , monitor ) ; } catch ( JavaModelException e ) { compilationUnitDeclaration = CompilationUnitResolver . parse ( sourceUnit , searcher , this . compilerOptions ) ; needToResolveBindings = false ; } } else { compilationUnitDeclaration = CompilationUnitResolver . parse ( sourceUnit , searcher , this . compilerOptions ) ; needToResolveBindings = false ; } return CompilationUnitResolver . convert ( compilationUnitDeclaration , sourceUnit . getContents ( ) , this . apiLevel , this . compilerOptions , needToResolveBindings , ( ( this . compilationUnitSource ) == null ? this . workingCopyOwner : this . compilationUnitSource . getOwner ( ) ) , ( needToResolveBindings ? new DefaultBindingResolver . BindingTables ( ) : null ) , monitor ) ; } finally { if ( ( compilationUnitDeclaration != null ) && ( this . resolveBindings ) ) { compilationUnitDeclaration . cleanUp ( ) ; } } } throw new IllegalStateException ( ) ; } private ASTNode internalCreateASTForKind ( ) { } private void propagateErrors ( ASTNode astNode , IProblem [ ] problems ) { } private void rootNodeToCompilationUnit ( AST ast , CompilationUnit compilationUnit , ASTNode node , RecordedParsingInformation recordedParsingInformation ) { } }

Fix:
String fileName = new String ( binaryType . getFileName ( ) ) ;