Buggy code:
public class ImportResolver { private static final Pattern SEMICOLON_PATTERN = Pattern . compile ( ";" ) ; private static final Pattern DOT_PATTERN = Pattern . compile ( "\\." ) ; private static final String JAVA_LANG = "java.lang" ; private static final String DOT = "." ; private String source ; private CompilationUnit compilationUnit ; private IJavaProject javaProject ; public String resolve ( ) { } protected boolean inPackage ( final String packageName , final String qualifiedName ) { } protected String updateSource ( final List < String > allImportedNames , final List < ImportDeclaration > newImports , final AST ast , final String packageName ) throws BadLocationException { } protected List < ImportDeclaration > sortImports ( final List < ImportDeclaration > imports ) { } private List < String > importedNonQualifiedNames ( final List < ImportDeclaration > importDeclarations ) { } protected String getCorrectQualifiedName ( final String qualifiedName ) { } protected String getLastSegment ( final String qualifiedName ) { } protected List < String > cleanQualifiedNames ( final List < String > qualifiedNames ) { } private boolean isJavaLangClass ( String className ) { } protected List < ImportDeclaration > determineCurrentNeededImports ( final List < ImportDeclaration > currentImports , final List < String > qualifiedNames ) { } public String getSource ( ) { } public void setSource ( final String source ) { <START_BUG> final ASTParser parser = ASTParser . newParser ( AST . JLS8 ) ; <END_BUG> parser . setKind ( ASTParser . K_COMPILATION_UNIT ) ; parser . setSource ( source . toCharArray ( ) ) ; compilationUnit = ( ( CompilationUnit ) ( parser . createAST ( null ) ) ) ; final IProblem [ ] problems = compilationUnit . getProblems ( ) ; if ( ( problems != null ) && ( ( problems . length ) > 0 ) ) { final StringBuilder sb = new StringBuilder ( ) ; for ( final IProblem problem : problems ) { sb . append ( ( ( ( ( problem . getSourceLineNumber ( ) ) + ":<seq2seq4repair_space>" ) + ( problem . getMessage ( ) ) ) + "\n" ) ) ; } throw new IllegalStateException ( ( ( source + "\n" ) + ( sb . toString ( ) ) ) ) ; } this . source = source ; } public CompilationUnit getCompilationUnit ( ) { } public IJavaProject getJavaProject ( ) { } public void setJavaProject ( final IJavaProject javaProject ) { } protected class ImportChangeCollector extends ASTVisitor { private List < String > importedNames ; private AST ast ; private ASTRewrite astRewriter ; private String packageName ; public ImportChangeCollector ( ) { } @ Override public boolean visit ( final QualifiedName node ) { } @ Override public boolean visit ( final ImportDeclaration node ) { } public void setImportedNames ( final List < String > importedNames ) { } public void setAst ( final AST ast ) { } public void setAstRewriter ( final ASTRewrite astRewriter ) { } public void setPackageName ( final String packageName ) { } } protected class ImportDeclarationComparator implements Comparator < ImportDeclaration > { public int compare ( final ImportDeclaration id0 , final ImportDeclaration id1 ) { } } private class QualifiedNameSorter implements Comparator < String > { private final String packageName ; private QualifiedNameSorter ( String packageName ) { } public int compare ( String qName1 , String qName2 ) { } } }

Fix:
final ASTParser parser = ASTParser . newParser ( GeneratorUtils . getASTLevel ( ) ) ;